@gloom-sh/terminal 0.20.20 → 0.20.21

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 (365) hide show
  1. package/package.json +3 -1
  2. package/src/api-client/data.ts +1 -1
  3. package/src/api-client/equity-screener.ts +17 -0
  4. package/src/api-client/futures-curve.ts +5 -0
  5. package/src/api-client/market-discovery.ts +8 -0
  6. package/src/api-client/members.ts +2 -0
  7. package/src/api-client/paths.ts +3 -0
  8. package/src/api-client/perps.ts +20 -0
  9. package/src/api-client/request.ts +53 -7
  10. package/src/api-client/types/filings-and-calls.ts +2 -0
  11. package/src/app/pane-runtime/plugin-bindings.ts +6 -4
  12. package/src/app/pro-welcome/model.ts +15 -11
  13. package/src/app/pro-welcome/row.tsx +3 -3
  14. package/src/app/pro-welcome/use-pro-welcome.ts +2 -2
  15. package/src/app/runtime/startup.ts +3 -2
  16. package/src/app.tsx +3 -2
  17. package/src/capabilities/asset-data-inputs.ts +5 -0
  18. package/src/capabilities/factories.ts +8 -3
  19. package/src/capabilities/registry.ts +1 -0
  20. package/src/capabilities/types.ts +1 -0
  21. package/src/cli/commands/market.ts +68 -35
  22. package/src/cli/commands/options-chain.ts +2 -2
  23. package/src/cli/commands/overview.ts +10 -9
  24. package/src/cli/commands/ticker.ts +19 -4
  25. package/src/cli/desktop-pane-shot.ts +11 -3
  26. package/src/cli/export-source.ts +35 -2
  27. package/src/cli/glossary.ts +3 -2
  28. package/src/cli/helpers.ts +2 -1
  29. package/src/cli/history-demergers.ts +41 -10
  30. package/src/cli/history-rows.ts +3 -1
  31. package/src/cli/known-gaps.ts +21 -7
  32. package/src/cli/listing-arg.ts +22 -11
  33. package/src/cli/pane-functions/capabilities.ts +4 -9
  34. package/src/cli/pane-functions/catalog-snapshot.json +29 -29
  35. package/src/cli/pane-functions/catalog.ts +1 -18
  36. package/src/cli/pane-functions/data.ts +8 -4
  37. package/src/cli/pane-functions/financial-ratio-shot.ts +20 -5
  38. package/src/cli/pane-functions/freshness.ts +57 -12
  39. package/src/cli/pane-functions/function-help.ts +2 -2
  40. package/src/cli/pane-functions/headless.ts +6 -0
  41. package/src/cli/pane-functions/index.ts +11 -4
  42. package/src/cli/pane-functions/market-session.ts +25 -0
  43. package/src/cli/pane-functions/report-notices.ts +10 -0
  44. package/src/cli/pane-functions/resolver.ts +75 -3
  45. package/src/cli/pane-functions/screenshot-bridge.ts +1 -0
  46. package/src/cli/pane-functions/screenshot-data-evidence.ts +1 -0
  47. package/src/cli/pane-functions/screenshot-payload.ts +38 -5
  48. package/src/cli/pane-functions/screenshot-render.ts +20 -7
  49. package/src/cli/perpetual-contract.ts +14 -1
  50. package/src/cli/report-tables.ts +11 -2
  51. package/src/cli/result.ts +6 -1
  52. package/src/components/chart-table/layout.ts +8 -4
  53. package/src/components/command-bar/list/model.ts +2 -0
  54. package/src/components/command-bar/pane-templates/items.ts +5 -25
  55. package/src/components/command-bar/panel/index.tsx +7 -4
  56. package/src/components/command-bar/routes/root/provider-search.ts +4 -4
  57. package/src/components/command-bar/routes/root/results.ts +6 -2
  58. package/src/components/command-bar/routes/ticker-search/results.ts +19 -0
  59. package/src/components/command-bar/routes/ticker-search/route.ts +3 -3
  60. package/src/components/command-bar/routes/ticker-search/title.ts +23 -0
  61. package/src/components/command-bar/routing/list-state.ts +17 -5
  62. package/src/components/command-bar/selection-runtime.ts +3 -2
  63. package/src/components/command-bar/surface/index.tsx +2 -0
  64. package/src/components/command-bar/workflow/alert.ts +6 -4
  65. package/src/components/command-bar/workflow/collection-actions.ts +2 -1
  66. package/src/components/layout/pane/footer/index.tsx +1 -0
  67. package/src/components/layout/pane/footer/model.ts +20 -7
  68. package/src/components/layout/pane/title.ts +11 -2
  69. package/src/components/price-selector-dialog.tsx +8 -4
  70. package/src/components/ticker/badge/list.tsx +4 -3
  71. package/src/components/ticker/list-table-view.tsx +12 -1
  72. package/src/components/ui/query-bar.tsx +20 -14
  73. package/src/data/cached-query.ts +20 -4
  74. package/src/data/news-pane-snapshots.ts +2 -1
  75. package/src/data/plugin-cache.ts +5 -1
  76. package/src/data/saved-copies.ts +68 -2
  77. package/src/docs/snapshot.json +65 -14
  78. package/src/docs/topics.ts +11 -9
  79. package/src/i18n/es.ts +1 -0
  80. package/src/i18n/ja.ts +1 -0
  81. package/src/i18n/ko.ts +1 -0
  82. package/src/i18n/zh-cn.ts +1 -0
  83. package/src/i18n/zh-tw.ts +1 -0
  84. package/src/market-data/coordinator/index.ts +25 -5
  85. package/src/market-data/depositary-pair.ts +27 -10
  86. package/src/market-data/futures-roll-returns.ts +54 -7
  87. package/src/market-data/fx-closes.ts +14 -0
  88. package/src/market-data/market/futures-product-hours.ts +113 -0
  89. package/src/market-data/market/futures-week.ts +2 -0
  90. package/src/market-data/market/globex-day.ts +9 -2
  91. package/src/market-data/market/status.ts +32 -25
  92. package/src/market-data/market/venue-session.ts +18 -0
  93. package/src/market-data/options-alternatives.ts +49 -7
  94. package/src/market-data/perpetual-open-interest.ts +41 -0
  95. package/src/market-data/quotes/contributions.ts +4 -2
  96. package/src/market-data/quotes/export-identity.ts +11 -3
  97. package/src/market-data/quotes/freshness.ts +3 -2
  98. package/src/market-data/quotes/resolution.ts +9 -2
  99. package/src/market-data/quotes/tick-range.ts +22 -1
  100. package/src/market-data/quotes/time.ts +34 -4
  101. package/src/market-data/split-terms.ts +3 -2
  102. package/src/news/aggregator.ts +1 -0
  103. package/src/news/news-model.ts +12 -2
  104. package/src/news/types.ts +15 -0
  105. package/src/plugins/builtin/alerts/alert-engine.ts +2 -0
  106. package/src/plugins/builtin/alerts/cli-forms.ts +3 -2
  107. package/src/plugins/builtin/alerts/cli-move.ts +5 -2
  108. package/src/plugins/builtin/alerts/cli.ts +50 -25
  109. package/src/plugins/builtin/alerts/command.ts +51 -3
  110. package/src/plugins/builtin/alerts/event-rows.ts +1 -1
  111. package/src/plugins/builtin/alerts/events-pane.tsx +1 -1
  112. package/src/plugins/builtin/alerts/format.ts +67 -8
  113. package/src/plugins/builtin/alerts/headless.ts +22 -6
  114. package/src/plugins/builtin/alerts/index.tsx +26 -25
  115. package/src/plugins/builtin/alerts/move-checks.ts +1 -0
  116. package/src/plugins/builtin/alerts/pane.tsx +15 -6
  117. package/src/plugins/builtin/alerts/pro-rules.ts +9 -4
  118. package/src/plugins/builtin/alerts/quotes.ts +10 -5
  119. package/src/plugins/builtin/alerts/session.ts +28 -0
  120. package/src/plugins/builtin/alerts/types.ts +1 -0
  121. package/src/plugins/builtin/analytics/pane-model.ts +2 -1
  122. package/src/plugins/builtin/analytics/risk-model.ts +2 -2
  123. package/src/plugins/builtin/attention/headless.ts +2 -2
  124. package/src/plugins/builtin/attention/model.ts +7 -2
  125. package/src/plugins/builtin/attention/pane.tsx +2 -1
  126. package/src/plugins/builtin/awards/headless.ts +1 -1
  127. package/src/plugins/builtin/broker-trading/ticket.tsx +13 -5
  128. package/src/plugins/builtin/buildout/detail/company.tsx +0 -1
  129. package/src/plugins/builtin/buildout/detail/ui.tsx +7 -5
  130. package/src/plugins/builtin/buildout/model/normalizers.ts +0 -1
  131. package/src/plugins/builtin/buildout/model/types.ts +0 -1
  132. package/src/plugins/builtin/buildout/pane/index.tsx +9 -0
  133. package/src/plugins/builtin/buildout/pane/status.tsx +11 -0
  134. package/src/plugins/builtin/catalysts/headless.ts +1 -1
  135. package/src/plugins/builtin/chart-composer/headless.ts +14 -6
  136. package/src/plugins/builtin/chart-composer/pane.tsx +2 -1
  137. package/src/plugins/builtin/chart-composer/session-history.ts +14 -2
  138. package/src/plugins/builtin/chat/controller/index.ts +5 -3
  139. package/src/plugins/builtin/chat/controller/session-runtime.ts +18 -8
  140. package/src/plugins/builtin/chat/index.tsx +1 -1
  141. package/src/plugins/builtin/cloud/auth-actions.tsx +4 -2
  142. package/src/plugins/builtin/cloud/mcp-connect/dialog.tsx +4 -1
  143. package/src/plugins/builtin/cloud/thesis/ticker-tab.tsx +2 -1
  144. package/src/plugins/builtin/company-attention/headless.ts +2 -1
  145. package/src/plugins/builtin/company-kpis/headless.ts +1 -1
  146. package/src/plugins/builtin/correlation/headless.ts +3 -3
  147. package/src/plugins/builtin/correlation/history.ts +1 -0
  148. package/src/plugins/builtin/correlation/index.tsx +7 -5
  149. package/src/plugins/builtin/correlation/matrix/selection.ts +21 -3
  150. package/src/plugins/builtin/correlation/relationship/model.ts +5 -0
  151. package/src/plugins/builtin/correlation/relationship/pane.tsx +3 -2
  152. package/src/plugins/builtin/correlation/relationship/view-model.ts +3 -2
  153. package/src/plugins/builtin/credit-documents/headless.ts +1 -1
  154. package/src/plugins/builtin/dividend-yield/client.ts +81 -10
  155. package/src/plugins/builtin/dividend-yield/headless.ts +21 -10
  156. package/src/plugins/builtin/dividend-yield/model.ts +1 -1
  157. package/src/plugins/builtin/dividend-yield/pane.tsx +9 -5
  158. package/src/plugins/builtin/dividend-yield/ranking.ts +15 -5
  159. package/src/plugins/builtin/dividend-yield/reference-price.ts +3 -0
  160. package/src/plugins/builtin/dividend-yield/types.ts +12 -0
  161. package/src/plugins/builtin/dividend-yield/view.ts +30 -7
  162. package/src/plugins/builtin/doe/headless.ts +1 -1
  163. package/src/plugins/builtin/doe/pane.tsx +16 -7
  164. package/src/plugins/builtin/earnings-calls/data.ts +8 -5
  165. package/src/plugins/builtin/earnings-ripple/headless.ts +1 -1
  166. package/src/plugins/builtin/econ/calendar-model.ts +1 -1
  167. package/src/plugins/builtin/econ/index.tsx +26 -18
  168. package/src/plugins/builtin/equity-screener/client.ts +1 -1
  169. package/src/plugins/builtin/equity-screener/headless.ts +149 -31
  170. package/src/plugins/builtin/equity-screener/live.ts +23 -5
  171. package/src/plugins/builtin/equity-screener/model.ts +27 -12
  172. package/src/plugins/builtin/equity-screener/pane.tsx +5 -5
  173. package/src/plugins/builtin/exposure/headless.ts +1 -1
  174. package/src/plugins/builtin/exposure/holdings.ts +2 -2
  175. package/src/plugins/builtin/futures/index.tsx +29 -1
  176. package/src/plugins/builtin/futures/model.ts +93 -10
  177. package/src/plugins/builtin/futures/returns.ts +54 -1
  178. package/src/plugins/builtin/futures/table.tsx +14 -2
  179. package/src/plugins/builtin/futures/use-front-returns.ts +20 -3
  180. package/src/plugins/builtin/futures-curve/client.ts +1 -1
  181. package/src/plugins/builtin/futures-curve/headless.ts +9 -3
  182. package/src/plugins/builtin/futures-curve/model.ts +19 -5
  183. package/src/plugins/builtin/futures-curve/pane.tsx +12 -6
  184. package/src/plugins/builtin/gpu/headless.ts +1 -1
  185. package/src/plugins/builtin/gpu/model.ts +1 -1
  186. package/src/plugins/builtin/help/function-index.ts +16 -8
  187. package/src/plugins/builtin/help/functions-table.tsx +6 -4
  188. package/src/plugins/builtin/help/shortcut-model.ts +7 -2
  189. package/src/plugins/builtin/holders/headless.ts +16 -5
  190. package/src/plugins/builtin/holders/pane.tsx +43 -5
  191. package/src/plugins/builtin/insider/client.ts +118 -11
  192. package/src/plugins/builtin/insider/filing-stories.ts +36 -20
  193. package/src/plugins/builtin/insider/issuer.ts +5 -2
  194. package/src/plugins/builtin/iv-history/headless.ts +2 -0
  195. package/src/plugins/builtin/macro-day/client.ts +2 -3
  196. package/src/plugins/builtin/macro-day/comparison.ts +58 -0
  197. package/src/plugins/builtin/macro-day/headless.ts +47 -3
  198. package/src/plugins/builtin/macro-day/index.tsx +32 -9
  199. package/src/plugins/builtin/macro-day/model.ts +1 -1
  200. package/src/plugins/builtin/macro-day/pane.tsx +99 -12
  201. package/src/plugins/builtin/market-heatmap/index.tsx +2 -2
  202. package/src/plugins/builtin/market-movers/footer.ts +29 -3
  203. package/src/plugins/builtin/market-movers/headless.ts +12 -5
  204. package/src/plugins/builtin/market-movers/index.tsx +3 -3
  205. package/src/plugins/builtin/market-movers/session-body.tsx +6 -3
  206. package/src/plugins/builtin/market-valuation/detail.tsx +3 -3
  207. package/src/plugins/builtin/market-valuation/headless.ts +6 -6
  208. package/src/plugins/builtin/market-valuation/pane.tsx +2 -3
  209. package/src/plugins/builtin/market-valuation/view.ts +6 -8
  210. package/src/plugins/builtin/members/client.ts +9 -2
  211. package/src/plugins/builtin/members/headless.ts +8 -10
  212. package/src/plugins/builtin/members/model.ts +29 -17
  213. package/src/plugins/builtin/members/pane.tsx +10 -12
  214. package/src/plugins/builtin/money-markets/headless.ts +1 -1
  215. package/src/plugins/builtin/news/headless.ts +4 -0
  216. package/src/plugins/builtin/news/index.tsx +3 -1
  217. package/src/plugins/builtin/news/wire/industry-pane.tsx +2 -1
  218. package/src/plugins/builtin/news/wire/news/preset-pane.tsx +1 -1
  219. package/src/plugins/builtin/news/wire/persisted-articles.ts +8 -4
  220. package/src/plugins/builtin/notes/headless.ts +7 -0
  221. package/src/plugins/builtin/notes/index.tsx +1 -1
  222. package/src/plugins/builtin/notes/quick-notes-pane.tsx +18 -2
  223. package/src/plugins/builtin/options/view.tsx +7 -6
  224. package/src/plugins/builtin/options-positioning/headless.ts +4 -4
  225. package/src/plugins/builtin/options-positioning/pane.tsx +7 -3
  226. package/src/plugins/builtin/options-scenario/client.ts +20 -4
  227. package/src/plugins/builtin/options-scenario/headless.ts +1 -1
  228. package/src/plugins/builtin/pe-band/client.ts +5 -9
  229. package/src/plugins/builtin/pe-band/headless.ts +11 -13
  230. package/src/plugins/builtin/pe-band/model.ts +39 -60
  231. package/src/plugins/builtin/pe-band/pane.tsx +14 -15
  232. package/src/plugins/builtin/perps/equity-row.tsx +3 -1
  233. package/src/plugins/builtin/perps/freshness.ts +16 -9
  234. package/src/plugins/builtin/perps/headless.ts +4 -1
  235. package/src/plugins/builtin/perps/markets-section.tsx +16 -10
  236. package/src/plugins/builtin/perps/model.ts +33 -2
  237. package/src/plugins/builtin/perps/pane.tsx +3 -2
  238. package/src/plugins/builtin/perps/status-line.ts +12 -3
  239. package/src/plugins/builtin/perps/venue-markets.ts +38 -0
  240. package/src/plugins/builtin/plugin-marketplace/pane.tsx +4 -3
  241. package/src/plugins/builtin/portfolio-list/cell-version.ts +1 -1
  242. package/src/plugins/builtin/portfolio-list/cli/render.ts +46 -7
  243. package/src/plugins/builtin/portfolio-list/headless.ts +31 -8
  244. package/src/plugins/builtin/portfolio-list/settings.ts +3 -0
  245. package/src/plugins/builtin/portfolio-list/table.tsx +7 -1
  246. package/src/plugins/builtin/power/headless.ts +1 -1
  247. package/src/plugins/builtin/realized-vol/headless.ts +1 -1
  248. package/src/plugins/builtin/research/corporate-actions-pane.tsx +27 -13
  249. package/src/plugins/builtin/scanner/feed.ts +7 -4
  250. package/src/plugins/builtin/scanner/flow-pane.tsx +8 -4
  251. package/src/plugins/builtin/scanner/headless.ts +57 -26
  252. package/src/plugins/builtin/scanner/hilo-pane.tsx +6 -3
  253. package/src/plugins/builtin/scanner/lock-note.ts +3 -2
  254. package/src/plugins/builtin/scanner/us-session.ts +9 -0
  255. package/src/plugins/builtin/seasonality/client.ts +46 -10
  256. package/src/plugins/builtin/seasonality/headless.ts +29 -11
  257. package/src/plugins/builtin/seasonality/model.ts +101 -24
  258. package/src/plugins/builtin/seasonality/pane.tsx +10 -6
  259. package/src/plugins/builtin/sec/filing-content.ts +13 -0
  260. package/src/plugins/builtin/sec/index.tsx +16 -11
  261. package/src/plugins/builtin/sectors/client.ts +27 -5
  262. package/src/plugins/builtin/sectors/headless.ts +2 -1
  263. package/src/plugins/builtin/sectors/index.tsx +22 -10
  264. package/src/plugins/builtin/shared/cloud-resource.ts +3 -3
  265. package/src/plugins/builtin/shared/extended-print.ts +38 -0
  266. package/src/plugins/builtin/shared/pro-feature-wall.tsx +1 -1
  267. package/src/plugins/builtin/shared/report-freshness.ts +7 -3
  268. package/src/plugins/builtin/shared/scanner-capture.ts +16 -3
  269. package/src/plugins/builtin/shared/ticker-company.ts +17 -8
  270. package/src/plugins/builtin/shared/use-quote-board.ts +11 -4
  271. package/src/plugins/builtin/social-mentions/client.ts +7 -3
  272. package/src/plugins/builtin/social-mentions/outliers.tsx +9 -2
  273. package/src/plugins/builtin/thirteenf/api.ts +24 -3
  274. package/src/plugins/builtin/thirteenf/data.ts +21 -8
  275. package/src/plugins/builtin/thirteenf/headless.ts +7 -3
  276. package/src/plugins/builtin/thirteenf/signals-pane.tsx +10 -3
  277. package/src/plugins/builtin/thirteenf/signals.ts +22 -1
  278. package/src/plugins/builtin/ticker-detail/adr-pair/model.ts +4 -2
  279. package/src/plugins/builtin/ticker-detail/financials/model.ts +7 -0
  280. package/src/plugins/builtin/ticker-detail/financials/ratio-table.tsx +15 -6
  281. package/src/plugins/builtin/ticker-detail/financials/ratios.ts +5 -4
  282. package/src/plugins/builtin/ticker-detail/financials/tab.tsx +14 -5
  283. package/src/plugins/builtin/ticker-detail/headless.ts +32 -26
  284. package/src/plugins/builtin/ticker-detail/index.tsx +1 -1
  285. package/src/plugins/builtin/ticker-detail/overview/components.tsx +8 -3
  286. package/src/plugins/builtin/ticker-detail/overview/model.ts +28 -5
  287. package/src/plugins/builtin/ticker-detail/overview/pane.tsx +14 -1
  288. package/src/plugins/builtin/ticker-detail/overview-tab.tsx +9 -8
  289. package/src/plugins/builtin/ticker-detail/pane.tsx +16 -9
  290. package/src/plugins/builtin/ticker-detail/quote-monitor/card.tsx +41 -23
  291. package/src/plugins/builtin/ticker-detail/quote-monitor/rows.ts +30 -13
  292. package/src/plugins/builtin/ticker-detail/settings.ts +9 -2
  293. package/src/plugins/builtin/time-sales/headless.ts +49 -13
  294. package/src/plugins/builtin/time-sales/model.ts +2 -2
  295. package/src/plugins/builtin/time-sales/window.ts +84 -10
  296. package/src/plugins/builtin/vol-surface/charts.tsx +4 -2
  297. package/src/plugins/builtin/vol-surface/events.ts +12 -5
  298. package/src/plugins/builtin/vol-surface/headless.ts +1 -1
  299. package/src/plugins/builtin/vol-surface/pane.tsx +15 -7
  300. package/src/plugins/builtin/world-indices/footer.ts +1 -1
  301. package/src/plugins/builtin/world-venue-map/chokepoint-report.ts +3 -1
  302. package/src/plugins/builtin/world-venue-map/headless.ts +27 -13
  303. package/src/plugins/builtin/yield-curve/client.ts +3 -1
  304. package/src/plugins/duplicates.ts +60 -0
  305. package/src/plugins/loader.ts +12 -3
  306. package/src/plugins/marketplace/model.ts +10 -1
  307. package/src/portfolio/column-values.ts +52 -5
  308. package/src/react/async-resource.ts +8 -7
  309. package/src/renderers/browser/bundled-plugins.ts +2 -1
  310. package/src/renderers/dom/build-assets.ts +20 -0
  311. package/src/renderers/dom/data-table/index.tsx +36 -2
  312. package/src/renderers/dom/es2023-array-methods.ts +57 -0
  313. package/src/renderers/dom/host/surface-fit.ts +64 -13
  314. package/src/renderers/dom/styles.css +6 -1
  315. package/src/renderers/electrobun/bun/external-plugins.ts +16 -6
  316. package/src/renderers/electrobun/shared/protocol.ts +2 -0
  317. package/src/renderers/electrobun/view/cli-pane-shot-entry.tsx +31 -7
  318. package/src/renderers/electrobun/view/cli-pane-shot-frame.tsx +15 -8
  319. package/src/renderers/electrobun/view/external-plugins.ts +1 -0
  320. package/src/renderers/electrobun/view/remote/asset-data-client.ts +1 -0
  321. package/src/series/types.ts +1 -0
  322. package/src/sources/gloomberb-cloud/fred-attribution.ts +6 -5
  323. package/src/sources/gloomberb-cloud/index.ts +42 -5
  324. package/src/sources/gloomberb-cloud/news.ts +15 -2
  325. package/src/sources/gloomberb-cloud/normalizers.ts +9 -0
  326. package/src/sources/history-result.ts +2 -1
  327. package/src/sources/history-retention.ts +14 -2
  328. package/src/sources/listing-symbols.ts +1 -1
  329. package/src/sources/provider-router/cache.ts +32 -3
  330. package/src/sources/provider-router/cached-routes.ts +25 -0
  331. package/src/sources/provider-router/connection-health.ts +1 -0
  332. package/src/sources/provider-router/history.ts +2 -2
  333. package/src/sources/provider-router/index.ts +14 -0
  334. package/src/sources/provider-router/sec-filings-page.ts +25 -0
  335. package/src/sources/sec-edgar/content.ts +67 -36
  336. package/src/tickers/listing-fate.ts +28 -0
  337. package/src/tickers/search/home-listing.ts +3 -0
  338. package/src/tickers/search/index-root-lead.ts +40 -0
  339. package/src/tickers/terminal-codes.ts +7 -4
  340. package/src/time-series/base-series.ts +17 -8
  341. package/src/time-series/fundamentals/historical-valuation.ts +2 -2
  342. package/src/time-series/fundamentals/series.ts +15 -12
  343. package/src/time-series/history-acquisition.ts +2 -0
  344. package/src/time-series/market.ts +3 -1
  345. package/src/time-series/price-comparison.ts +3 -1
  346. package/src/time-series/resolve-context.ts +8 -0
  347. package/src/time-series/resolve.ts +50 -10
  348. package/src/time-series/types.ts +1 -0
  349. package/src/time-series/use-chart-resolution.ts +2 -2
  350. package/src/time-series/valuation-currency.ts +40 -12
  351. package/src/types/data-provider.ts +30 -1
  352. package/src/types/financials.ts +23 -0
  353. package/src/types/headless.ts +23 -0
  354. package/src/types/instrument.ts +1 -0
  355. package/src/utils/crypto-pair.ts +16 -0
  356. package/src/utils/exchange-announcements.ts +2 -1
  357. package/src/utils/exchange-notation.generated.ts +58 -1
  358. package/src/utils/exchanges.ts +43 -1
  359. package/src/utils/format.ts +37 -2
  360. package/src/utils/function-search.ts +38 -0
  361. package/src/utils/fuzzy-search.ts +10 -6
  362. package/src/utils/option-choice.ts +15 -0
  363. package/src/utils/price-history.ts +15 -1
  364. package/src/utils/reason-codes.ts +6 -3
  365. package/src/utils/trailing-dividend.ts +241 -28
@@ -1,6 +1,7 @@
1
1
  import { apiClient } from "../../../api-client";
2
2
  import type { SwapCurvePayload, SwapTenor } from "../../../api-client/swap-curve";
3
3
  import { createPluginCache, savedCopyForTransientFailure, type PluginCacheResult } from "../../../data/plugin-cache";
4
+ import { stampRetrievedAt, withSavedCopyMarkOf } from "../../../data/saved-copies";
4
5
  import { cachedCloudResource, loadCloudResource, unavailableOnServer } from "../shared/cloud-resource";
5
6
  import { validateSwapCurve } from "./swaps-model";
6
7
  import { loadCurveData, type CurveData, type CurveId } from "./curves";
@@ -56,7 +57,8 @@ const curveKey = (curve: CurveId, requestedDate: string) => `${curve}:${requeste
56
57
  */
57
58
  function answer<T>(result: PluginCacheResult<T>): SavedCopyAnswer<T> {
58
59
  const saved = savedCopyForTransientFailure(result).source === "stale-fallback";
59
- return { data: result.data, savedAt: saved ? result.fetchedAt : null };
60
+ const value = { data: result.data, savedAt: saved ? result.fetchedAt : null };
61
+ return saved ? withSavedCopyMarkOf(value, result) : stampRetrievedAt(value, result.fetchedAt);
60
62
  }
61
63
 
62
64
  /** The curve on the date (its latest without one), or the copy an earlier read saved when it cannot be read. */
@@ -0,0 +1,60 @@
1
+ import type { GloomPlugin } from "../types/plugin";
2
+ import { debugLog } from "../utils/debug-log";
3
+ import { compareSemver } from "../utils/semver";
4
+ import type { LoadedExternalPlugin } from "./loader";
5
+
6
+ const duplicatesLog = debugLog.createLogger("plugin-loader");
7
+
8
+ function copyName(entry: LoadedExternalPlugin): string {
9
+ return entry.directory ?? entry.path;
10
+ }
11
+
12
+ /** Whether the host would register the entry, which is when its id can collide with another's. */
13
+ function registers(entry: LoadedExternalPlugin): boolean {
14
+ return !entry.error && !entry.unsupportedTarget && !entry.needsRestart;
15
+ }
16
+
17
+ /**
18
+ * Negative when `a` is the copy to keep: a linked checkout over a copy, then
19
+ * the higher version, then the folder name that sorts first.
20
+ */
21
+ function compareCopies(a: LoadedExternalPlugin, b: LoadedExternalPlugin): number {
22
+ if (!!a.linked !== !!b.linked) return a.linked ? -1 : 1;
23
+ const byVersion = compareSemver(b.plugin.version, a.plugin.version);
24
+ if (byVersion) return byVersion;
25
+ const left = copyName(a);
26
+ const right = copyName(b);
27
+ return left < right ? -1 : left > right ? 1 : 0;
28
+ }
29
+
30
+ /**
31
+ * Keeps one folder of each plugin id that more than one loaded plugin
32
+ * declares. A second copy (a download beside a marketplace install, a dev
33
+ * link beside a clone) would otherwise fail to register on the id the first
34
+ * took, on every launch. The others come back with `duplicateOf` and an
35
+ * `error` naming the folder that loads instead, so nothing registers them,
36
+ * and the Plugins pane lists them. Only plugins that loaded compete, so a
37
+ * copy that failed to import never hides one that works. Folders are left as
38
+ * they are.
39
+ */
40
+ export function skipDuplicatePluginIds(entries: LoadedExternalPlugin[]): LoadedExternalPlugin[] {
41
+ const kept = new Map<string, LoadedExternalPlugin>();
42
+ for (const entry of entries) {
43
+ if (!registers(entry)) continue;
44
+ const current = kept.get(entry.plugin.id);
45
+ if (!current || compareCopies(entry, current) < 0) kept.set(entry.plugin.id, entry);
46
+ }
47
+ return entries.map((entry) => {
48
+ const winner = registers(entry) ? kept.get(entry.plugin.id) : undefined;
49
+ if (!winner || winner === entry) return entry;
50
+ const loadsInstead = copyName(winner);
51
+ duplicatesLog.info(`Skipped ${copyName(entry)}: ${entry.plugin.id} loads from ${loadsInstead} instead`);
52
+ return {
53
+ ...entry,
54
+ // Named after its folder, as a plugin that failed to import is: two rows of one name would not say which is which.
55
+ plugin: { id: copyName(entry), name: copyName(entry), version: entry.plugin.version ?? "" } as GloomPlugin,
56
+ error: `The ${loadsInstead} folder has the same plugin id (${entry.plugin.id}) and loads instead.`,
57
+ duplicateOf: loadsInstead,
58
+ };
59
+ });
60
+ }
@@ -16,6 +16,7 @@ import {
16
16
  settleDependencyInstalls,
17
17
  } from "./dependencies";
18
18
  import { declaredPeerPlugins, describePeerLink, installedPeerPlugins, isLinkedPeerModule, linkHostPackages, relinkPeerPlugin } from "./host-link";
19
+ import { skipDuplicatePluginIds } from "./duplicates";
19
20
  import { importSiblingsFromTheirFolders } from "./peer-imports";
20
21
  import { refreshResolverFolders, rekeyedEntry, withoutRetryQuery } from "./peer-retry";
21
22
  import { redirectionGuard } from "./redirection-guard";
@@ -63,6 +64,11 @@ export interface LoadedExternalPlugin {
63
64
  * linked. Never registered; the next launch loads it.
64
65
  */
65
66
  needsRestart?: boolean;
67
+ /**
68
+ * Set on a folder whose plugin id another folder, named here, declares and
69
+ * loads instead (duplicates.ts). `error` says so, and nothing registers it.
70
+ */
71
+ duplicateOf?: string;
66
72
  }
67
73
 
68
74
  export function getPluginsDir(): string {
@@ -580,14 +586,17 @@ export async function listPluginDirectories(pluginsDir: string = PLUGINS_DIR): P
580
586
  return dirs;
581
587
  }
582
588
 
583
- export async function loadExternalPlugins(target: PluginTarget = "cli"): Promise<LoadedExternalPlugin[]> {
589
+ export async function loadExternalPlugins(
590
+ target: PluginTarget = "cli",
591
+ pluginsDir: string = PLUGINS_DIR,
592
+ ): Promise<LoadedExternalPlugin[]> {
584
593
  recordLaunchedVersion();
585
594
  const results: LoadedExternalPlugin[] = [];
586
- for (const pluginDir of await listPluginDirectories()) {
595
+ for (const pluginDir of await listPluginDirectories(pluginsDir)) {
587
596
  const loaded = await loadExternalPlugin(pluginDir, target);
588
597
  if (loaded) results.push(loaded);
589
598
  }
590
- return results;
599
+ return skipDuplicatePluginIds(results);
591
600
  }
592
601
 
593
602
  function isSymlink(path: string): boolean {
@@ -77,6 +77,8 @@ export interface InstalledPlugin {
77
77
  /** Set when the plugin is installed but cannot run on this renderer. */
78
78
  unsupportedTarget?: PluginTarget;
79
79
  loadError?: string;
80
+ /** Another folder, named here, declares this plugin's id and loads instead; this one is skipped. */
81
+ duplicateOf?: string;
80
82
  /** The checkout declares a newer Gloomberb than this one, so it was not loaded. */
81
83
  needsGloomberb?: string;
82
84
  /** Declares a `configSchema` and is missing a required value. */
@@ -132,6 +134,8 @@ export interface MarketplaceEntry {
132
134
  minGloomberb?: string;
133
135
  contributes?: RegistryPlugin["contributes"];
134
136
  loadError?: string;
137
+ /** The folder that loads in this one's place, when two declare the same plugin id. */
138
+ duplicateOf?: string;
135
139
  /** What the installed checkout declares it needs, when this Gloomberb is older. */
136
140
  needsGloomberb?: string;
137
141
  needsSetup: boolean;
@@ -293,6 +297,7 @@ export function mergeCatalog(options: {
293
297
  minGloomberb: plugin.minGloomberb,
294
298
  contributes: plugin.contributes,
295
299
  loadError: local?.loadError,
300
+ duplicateOf: local?.duplicateOf,
296
301
  needsGloomberb: local?.needsGloomberb,
297
302
  needsSetup: local?.needsSetup === true,
298
303
  hasSetup: local?.hasSetup === true,
@@ -324,7 +329,7 @@ export function mergeCatalog(options: {
324
329
  name: local.name,
325
330
  tagline: rowLine(local.source === "builtin"
326
331
  ? builtinTagline(local)
327
- : local.description ?? (local.linked ? "Linked from a local checkout" : "Installed outside the registry")),
332
+ : local.description ?? (local.duplicateOf ? `Duplicate of ${local.duplicateOf}` : local.linked ? "Linked from a local checkout" : "Installed outside the registry")),
328
333
  description: detailParagraph(local.description),
329
334
  categories: local.source === "builtin" ? [...BUILTIN_EDITORIAL[local.id]?.categories ?? []] : ["unlisted"],
330
335
  // Shipped by Gloom like every built-in, whether or not the feed lists it.
@@ -343,6 +348,7 @@ export function mergeCatalog(options: {
343
348
  installedCommit: local.commit,
344
349
  remoteCommit: remoteHeadFor(local),
345
350
  loadError: local.loadError,
351
+ duplicateOf: local.duplicateOf,
346
352
  needsGloomberb: local.needsGloomberb,
347
353
  needsSetup: local.needsSetup === true,
348
354
  hasSetup: local.hasSetup === true,
@@ -419,6 +425,7 @@ export function versionLabel(entry: MarketplaceEntry): string {
419
425
 
420
426
  export type MarketplaceStatusKind =
421
427
  | "failed"
428
+ | "duplicate"
422
429
  | "needs-restart"
423
430
  | "unsupported"
424
431
  | "needs-setup"
@@ -451,6 +458,8 @@ export function statusOf(entry: MarketplaceEntry): MarketplaceStatus {
451
458
  // Also before `failed`: an update landed over modules this session already
452
459
  // imported, so any error on the row is from the old code.
453
460
  if (entry.needsRestart) return { kind: "needs-restart", text: "needs restart" };
461
+ // Not a failure: the plugin loads, from the other folder.
462
+ if (entry.duplicateOf) return { kind: "duplicate", text: "duplicate" };
454
463
  if (entry.loadError) return { kind: "failed", text: "failed" };
455
464
  const unsupported = unsupportedLabel(entry);
456
465
  if (unsupported) return { kind: "unsupported", text: unsupported.toLowerCase() };
@@ -8,11 +8,12 @@ import type { AnalystResearchData, CorporateActionsData, MarketState, Quote, Tic
8
8
  import type { EarningsEvent } from "../types/data-provider";
9
9
  import type { TickerRecord } from "../types/ticker";
10
10
  import type { PeriodPnlRow } from "./period-pnl";
11
+ import type { ReportTime } from "../utils/utc-time";
11
12
  import { colors, priceColor, shownPriceColor } from "../theme/colors";
12
- import { formatQuoteAgeWithSource, resolveQuoteAgeTimestamp } from "../market-data/quotes/time";
13
+ import { formatQuoteAgeWithSource, QUOTE_BOOK_UNDATED, resolveQuoteAgeTimestamp } from "../market-data/quotes/time";
13
14
  import { delistingStateLabel } from "../market-data/quotes/delisting";
14
15
  import { formatFeedTime, formatShortDate, parseDisplayDate, type ShortDateOptions } from "../utils/datetime-format";
15
- import { MISSING_VALUE, convertCurrency, formatCompact, formatCompactAmount, formatNumber, formatPercentRaw } from "../utils/format";
16
+ import { MISSING_VALUE, convertCurrency, formatCompact, formatCompactAmount, formatNumber, formatPercentRaw, formatTradeSize } from "../utils/format";
16
17
  import {
17
18
  formatMarketCost,
18
19
  quoteFormatOptions,
@@ -34,6 +35,7 @@ import {
34
35
  marketPriceColor,
35
36
  marketStateDot,
36
37
  quoteDotMarketState,
38
+ quoteHeadlineTime,
37
39
  type ActiveQuoteDisplay,
38
40
  type SessionPriceDisplay,
39
41
  } from "../market-data/market/status";
@@ -71,6 +73,7 @@ import {
71
73
  import {
72
74
  getPortfolioValuationDisplay,
73
75
  getPortfolioValuationTime,
76
+ valuationTimeIso,
74
77
  valuesAtNominalPrice,
75
78
  valuesAtSettlement,
76
79
  type PortfolioValuationBasis,
@@ -405,6 +408,38 @@ function rowHeadlineDisplay(
405
408
  return session ? { ...traded, session } : traded;
406
409
  }
407
410
 
411
+ /**
412
+ * When a row's LAST was observed, its AS OF: in a book, the price its value
413
+ * uses (getPortfolioValuationTime); in a list that values nothing (no
414
+ * `valuationBasis`, a watchlist), the regular session `quote` heads it with
415
+ * (rowHeadlineDisplay), dated as `quote` dates it: once the session is over at
416
+ * its close, never at the after-hours print EXT% shows beside it.
417
+ */
418
+ function rowAsOfTime(
419
+ quote: Quote | undefined,
420
+ ctx: Pick<ColumnContext, "valuationBasis">,
421
+ metrics: PortfolioPositionMetrics,
422
+ settlement: Parameters<typeof getPortfolioValuationTime>[3],
423
+ ): ReportTime | null {
424
+ if (ctx.valuationBasis == null && quote && !quote.nominalPrice) {
425
+ const time = quoteHeadlineTime(quote);
426
+ return Number.isFinite(time) && time > 0 ? { time, dateOnly: false } : null;
427
+ }
428
+ return getPortfolioValuationTime(quote, ctx.valuationBasis, metrics, settlement);
429
+ }
430
+
431
+ /**
432
+ * A row's AS OF as an export writes it (an ISO instant in UTC, or the day of
433
+ * a close or settlement the venue gives no hour for): what a list's Export
434
+ * CSV dates each row by, so its as_of is its LAST's.
435
+ */
436
+ export function getRowAsOfIso(ticker: TickerRecord, financials: TickerFinancials | undefined, ctx: ColumnContext): string | null {
437
+ const sent = financials?.quote;
438
+ const { position: positionMetrics } = rowPositionMetrics(ticker, ctx, sent?.currency || ticker.metadata.currency || "USD", sent);
439
+ const futures = positionMetrics.isFuture ? ctx.futuresTerms?.get(ticker.metadata.ticker) : undefined;
440
+ return valuationTimeIso(rowAsOfTime(futuresQuoteFromSettle(sent, futures), ctx, positionMetrics, futures?.settlement));
441
+ }
442
+
408
443
  /** CHG% as shown: the headline's, else the quote's own when no position price is usable. */
409
444
  function headlineChangePercent(
410
445
  headline: ActiveQuoteDisplay | null,
@@ -678,7 +713,17 @@ export function getColumnValue(
678
713
  }
679
714
  case "bid_ask_size": {
680
715
  if (!isFiniteNumber(quote?.bidSize) && !isFiniteNumber(quote?.askSize)) return { text: MISSING_VALUE };
681
- return { text: `${formatCompact(quote?.bidSize)}/${formatCompact(quote?.askSize)}` };
716
+ return { text: `${formatTradeSize(quote?.bidSize, { compact: true })}/${formatTradeSize(quote?.askSize, { compact: true })}` };
717
+ }
718
+ case "book_time": {
719
+ if (quote?.bid == null && quote?.ask == null) return { text: MISSING_VALUE };
720
+ const at = quote.bidAskTime;
721
+ // A book the source sent without its time says so, never borrows the trade's.
722
+ if (at == null || !Number.isFinite(at) || at <= 0) return { text: QUOTE_BOOK_UNDATED, color: colors.textDim };
723
+ return {
724
+ text: formatFeedTime(at, ctx.now, MISSING_VALUE, { utc: true, dayToday: true }),
725
+ value: new Date(at).toISOString(),
726
+ };
682
727
  }
683
728
  case "change_pct": {
684
729
  if (quote?.delisting) return { text: delistingStateLabel(quote.delisting), color: colors.warning };
@@ -848,7 +893,7 @@ export function getColumnValue(
848
893
  case "latency":
849
894
  return { text: formatQuoteAgeWithSource(quote, ctx.now, { seconds: true }) };
850
895
  case "as_of": {
851
- const time = getPortfolioValuationTime(quote, ctx.valuationBasis, positionMetrics, futures?.settlement);
896
+ const time = rowAsOfTime(quote, ctx, positionMetrics, futures?.settlement);
852
897
  if (!time) return { text: MISSING_VALUE };
853
898
  // In UTC, as the header says; a close the venue's calendar gives no hour for is dated by its day.
854
899
  // An export writes the date with it, as ISO: 16:49 alone says nothing of which day.
@@ -950,6 +995,8 @@ export function getSortValue(
950
995
  return isFiniteNumber(quote?.bidSize) || isFiniteNumber(quote?.askSize)
951
996
  ? (quote?.bidSize ?? 0) + (quote?.askSize ?? 0)
952
997
  : null;
998
+ case "book_time":
999
+ return quote?.bid != null || quote?.ask != null ? quote.bidAskTime ?? null : null;
953
1000
  case "change":
954
1001
  return quote?.delisting ? null : headlineQuote?.change ?? null;
955
1002
  case "change_pct":
@@ -1042,7 +1089,7 @@ export function getSortValue(
1042
1089
  case "latency":
1043
1090
  return quote ? ctx.now - (resolveQuoteAgeTimestamp(quote, ctx.now) ?? ctx.now) : null;
1044
1091
  case "as_of":
1045
- return getPortfolioValuationTime(quote, ctx.valuationBasis, positionMetrics, futures?.settlement)?.time ?? null;
1092
+ return rowAsOfTime(quote, ctx, positionMetrics, futures?.settlement)?.time ?? null;
1046
1093
  case PRICE_SPARKLINE_COLUMN_ID: {
1047
1094
  // The trend the sparkline draws: its window, closed by the live price.
1048
1095
  const history = followLiveSparklinePrice(financials?.priceHistory ?? [], quote, {
@@ -3,7 +3,7 @@ import { connectionHealth, recoversDataRequests } from "../core/connection-healt
3
3
  import { useSavedCopyFooter } from "../components/layout/pane/footer/registration";
4
4
  import { isPermanentClientError, isTransientFailure } from "../api-client/errors";
5
5
  import { afterSavedCopyFrame, deleteSavedCopy, readSavedCopy, savedCopyId, writeSavedCopy, type SavedCopyKey } from "../data/pane-saved-copies";
6
- import { savedCopyAt } from "../data/saved-copies";
6
+ import { retrievedAtOf, savedCopyAt } from "../data/saved-copies";
7
7
  import { reuseSavedData } from "../data/reuse-saved-data";
8
8
  import { logFailure } from "../utils/log-failure";
9
9
 
@@ -65,7 +65,7 @@ export function useAsyncResource<T>(
65
65
  const saved = savedKey ? readSavedCopy<T>(savedKey) : null;
66
66
  const data = loader ? saved?.value ?? options.initialData?.() ?? null : null;
67
67
  const savedAt = saved?.fetchedAt ?? savedCopyAt(data);
68
- return { owner: loader, ownerKey: savedId, retainWithin, data, savedAt, updatedAt: savedAt, loading: !!loader && !manual, error: null };
68
+ return { owner: loader, ownerKey: savedId, retainWithin, data, savedAt, updatedAt: savedAt ?? retrievedAtOf(data), loading: !!loader && !manual, error: null };
69
69
  };
70
70
  // `ownerKey`: the saved-copy key of the question the data answers. A new
71
71
  // loader for the same key (a session restored, a callback remade) asks the
@@ -106,7 +106,8 @@ export function useAsyncResource<T>(
106
106
  const data = await loader(force);
107
107
  if (isCurrent()) {
108
108
  const savedAt = savedCopyAt(data);
109
- const updatedAt = savedAt ?? Date.now();
109
+ // A copy read earlier and served again is as old as that read, not this load.
110
+ const updatedAt = savedAt ?? retrievedAtOf(data) ?? Date.now();
110
111
  const current = currentView.current;
111
112
  setState({
112
113
  owner: loader, ownerKey: keyId, retainWithin, loading: false, error: null, updatedAt, savedAt,
@@ -129,7 +130,7 @@ export function useAsyncResource<T>(
129
130
  ...current,
130
131
  data: discard ? null : current.data,
131
132
  updatedAt: discard ? null : current.updatedAt,
132
- savedAt: discard ? null : current.savedAt,
133
+ savedAt: discard ? null : current.savedAt ?? (!discardSaved && !current.placeholder && current.data !== null ? current.updatedAt : null),
133
134
  loading: false,
134
135
  error: message.trim() ? message : "Request failed",
135
136
  };
@@ -166,12 +167,12 @@ export function useAsyncResource<T>(
166
167
  // A load that failed is asked again once the data service (or the desktop
167
168
  // bridge) answers after an outage, so a pane recovers by itself instead of
168
169
  // keeping the failure.
169
- const failedRef = useRef(false);
170
- failedRef.current = !!loader && error !== null && !loading;
170
+ const recoveryRef = useRef<{ refresh: boolean } | null>(null);
171
+ recoveryRef.current = loader && !loading && (error !== null || savedCopyAt(data) !== null) ? { refresh: savedAt !== null } : null;
171
172
  useEffect(() => {
172
173
  if (manual || !loader) return;
173
174
  return connectionHealth.subscribeRecovery((sourceId) => {
174
- if (recoversDataRequests(sourceId) && failedRef.current) load();
175
+ if (recoversDataRequests(sourceId) && recoveryRef.current) load(recoveryRef.current.refresh);
175
176
  });
176
177
  }, [load, loader, manual]);
177
178
  const status: "error" | "loaded" | "loading" | "idle" = error !== null ? "error" : data !== null ? "loaded" : loading ? "loading" : "idle";
@@ -1,3 +1,4 @@
1
+ import { skipDuplicatePluginIds } from "../../plugins/duplicates";
1
2
  import { installPluginHostModules } from "../../plugins/host-modules";
2
3
  import type { LoadedExternalPlugin } from "../../plugins/loader";
3
4
  import { pluginFromModule } from "../../plugins/plugin-export";
@@ -87,5 +88,5 @@ export async function loadWebBundledPlugins(
87
88
  }
88
89
  }));
89
90
 
90
- return loaded;
91
+ return skipDuplicatePluginIds(loaded);
91
92
  }
@@ -45,6 +45,8 @@ interface ViewBundleOptions {
45
45
  * not keep them.
46
46
  */
47
47
  keepNames?: boolean;
48
+ /** Script text emitted ahead of everything else in the bundle. */
49
+ banner?: string;
48
50
  }
49
51
 
50
52
  /** Bun's minify setting: everything, or everything but identifiers when names are kept. */
@@ -65,6 +67,22 @@ const ELECTROBUN_VIEW_DIR = join(import.meta.dir, "..", "electrobun", "view");
65
67
  export const WORLD_MAP_DATA_SPECIFIER = "./natural-earth/index.chunk.js";
66
68
  const DOM_RENDERER_DIR = import.meta.dir;
67
69
 
70
+ /** Array methods that browsers before Chrome 110 and Firefox 115 lack, which `es2023-array-methods.ts` installs. */
71
+ export const ES2023_ARRAY_METHODS = ["toSorted", "toReversed", "toSpliced", "with", "findLast", "findLastIndex"] as const;
72
+
73
+ /** The array polyfill as a script for the top of a page bundle: bundled module code is not laid out in run order, so only the first line is certain to run first. */
74
+ export async function es2023ArrayMethodsScript(): Promise<string> {
75
+ const result = await Bun.build({
76
+ entrypoints: [join(DOM_RENDERER_DIR, "es2023-array-methods.ts")],
77
+ target: "browser",
78
+ format: "iife",
79
+ minify: true,
80
+ });
81
+ const script = result.outputs[0];
82
+ if (!result.success || !script) throw new Error("Failed to build the array polyfill");
83
+ return script.text();
84
+ }
85
+
68
86
  export function electrobunViewPath(...parts: string[]): string {
69
87
  return join(ELECTROBUN_VIEW_DIR, ...parts);
70
88
  }
@@ -86,6 +104,7 @@ export async function buildViewBundle({
86
104
  failureMessage,
87
105
  missingEntryMessage,
88
106
  keepNames,
107
+ banner,
89
108
  }: ViewBundleOptions): Promise<{ script: string; stylesheet: string | null }> {
90
109
  const chunks = new Map<string, string>();
91
110
  const result = await Bun.build({
@@ -96,6 +115,7 @@ export async function buildViewBundle({
96
115
  splitting: false,
97
116
  sourcemap,
98
117
  minify: minifyOption(keepNames),
118
+ banner,
99
119
  define: {
100
120
  "process.env.NODE_ENV": "\"production\"",
101
121
  __GLOOM_WORLD_MAP_DATA__: JSON.stringify(WORLD_MAP_DATA_SPECIFIER),
@@ -2,9 +2,11 @@
2
2
  import { useVirtualizer } from "@tanstack/react-virtual";
3
3
  import {
4
4
  useCallback,
5
+ useContext,
5
6
  useEffect,
6
7
  useLayoutEffect,
7
8
  useMemo,
9
+ useReducer,
8
10
  useRef,
9
11
  useState,
10
12
  type CSSProperties,
@@ -33,8 +35,10 @@ import {
33
35
  } from "../../../components/ui/table-layout";
34
36
  import { WEB_CELL_HEIGHT, WEB_CELL_WIDTH } from "../../../theme/font-scale";
35
37
  import { isLiveResizing, onLiveResizeEnd } from "../../../ui/live-resize";
38
+ import { LivePaneFrameContext } from "../../../ui/live-stretch";
36
39
  import { useScrollbarActivity } from "../scrollbar-activity";
37
40
  import { useHorizontalScrollEdges } from "../host/overflow-fade";
41
+ import { trackTable } from "../host/surface-fit";
38
42
  import {
39
43
  CSS_BG,
40
44
  CSS_PANEL,
@@ -81,8 +85,37 @@ function overflowFadeStyle(side: "left" | "right", offsetPx: number, bottomPx: n
81
85
  };
82
86
  }
83
87
 
88
+ /**
89
+ * The columns a table lays out, and the ref for its root. While a resize of
90
+ * its pane lays the table out at the frame's width on every frame
91
+ * (host/surface-fit.ts), it keeps the columns it had when the resize began:
92
+ * the pane renders a few times a second meanwhile, and columns it sizes from
93
+ * its width would move in whole cells at each of those, or overflow the
94
+ * width the body was last measured at. Once the resize ends, the table takes
95
+ * the columns the pane gives it at its final size.
96
+ */
97
+ function useResizeHeldColumns<C>(columns: C[]): { columns: C[]; rootRef: RefObject<HTMLDivElement | null> } {
98
+ const rootRef = useRef<HTMLDivElement | null>(null);
99
+ const pane = useContext(LivePaneFrameContext);
100
+ const followsRef = useRef(false);
101
+ const heldRef = useRef(columns);
102
+ const latestRef = useRef(columns);
103
+ latestRef.current = columns;
104
+ const [, settle] = useReducer((count: number) => count + 1, 0);
105
+ if (!followsRef.current || pane?.live() == null) heldRef.current = columns;
106
+ useLayoutEffect(() => {
107
+ const root = rootRef.current;
108
+ if (!root) return;
109
+ return trackTable(root, (follows) => {
110
+ followsRef.current = follows;
111
+ if (!follows && heldRef.current !== latestRef.current) settle();
112
+ });
113
+ }, []);
114
+ return { columns: heldRef.current, rootRef };
115
+ }
116
+
84
117
  export function WebDataTable<T, C extends DataTableColumn = DataTableColumn>({
85
- columns,
118
+ columns: paneColumns,
86
119
  items,
87
120
  sortColumnId,
88
121
  sortDirection,
@@ -129,6 +162,7 @@ export function WebDataTable<T, C extends DataTableColumn = DataTableColumn>({
129
162
  }: DataTableProps<T, C>) {
130
163
  const paneInstanceId = usePaneInstance()?.instanceId ?? null;
131
164
  const focusPane = useFocusOwningPane();
165
+ const { columns, rootRef: rootElementRef } = useResizeHeldColumns(paneColumns);
132
166
  const bodyElementRef = useRef<HTMLDivElement | null>(null);
133
167
  const contentElementRef = useRef<HTMLDivElement | null>(null);
134
168
  const { drag: columnDrag, startPress: pressMovableHeader } = useWebColumnDrag({
@@ -402,7 +436,7 @@ export function WebDataTable<T, C extends DataTableColumn = DataTableColumn>({
402
436
  };
403
437
 
404
438
  return (
405
- <div data-gloom-role="data-table" style={rootStyle}>
439
+ <div ref={rootElementRef} data-gloom-role="data-table" style={rootStyle}>
406
440
  {hiddenColumns ? <div style={{ flex: `0 0 ${disclosureHeight}px`, lineHeight: `${disclosureHeight}px`,
407
441
  paddingInline: "var(--gloom-space-sm)", color: CSS_TEXT_DIM,
408
442
  backgroundColor: CSS_PANEL, whiteSpace: "nowrap", overflow: "hidden", textOverflow: "ellipsis" }} title={hiddenColumns}>
@@ -0,0 +1,57 @@
1
+ // The ES2023 array methods for browsers before Chrome 110 and Firefox 115. Built onto the top of each web page's bundle (es2023ArrayMethodsScript), so it needs no exports.
2
+
3
+ type Indexed = { length: number; [index: number]: unknown };
4
+ type Predicate = (value: unknown, index: number, list: Indexed) => unknown;
5
+
6
+ // defineProperty, not assignment: natives are not enumerable, and `for...in` over an array must not see these.
7
+ function define(target: object, name: string, value: (this: any, ...args: any[]) => unknown): void {
8
+ if (typeof (target as Record<string, unknown>)[name] === "function") return;
9
+ Object.defineProperty(target, name, { value, writable: true, configurable: true });
10
+ }
11
+
12
+ function requirePredicate(predicate: unknown): asserts predicate is Predicate {
13
+ if (typeof predicate !== "function") throw new TypeError(`${String(predicate)} is not a function`);
14
+ }
15
+
16
+ function installShared(target: object, copy: (list: Indexed) => any): void {
17
+ define(target, "toSorted", function (compare) {
18
+ return copy(this).sort(compare);
19
+ });
20
+ define(target, "toReversed", function () {
21
+ return copy(this).reverse();
22
+ });
23
+ define(target, "with", function (index, value) {
24
+ const length = this.length;
25
+ const integer = Math.trunc(Number(index)) || 0;
26
+ const at = integer < 0 ? length + integer : integer;
27
+ if (at < 0 || at >= length) throw new RangeError(`Invalid index: ${String(index)}`);
28
+ const result = copy(this);
29
+ result[at] = value;
30
+ return result;
31
+ });
32
+ define(target, "findLast", function (predicate, thisArg) {
33
+ requirePredicate(predicate);
34
+ for (let index = this.length - 1; index >= 0; index--) {
35
+ const value = this[index];
36
+ if (predicate.call(thisArg, value, index, this)) return value;
37
+ }
38
+ return undefined;
39
+ });
40
+ define(target, "findLastIndex", function (predicate, thisArg) {
41
+ requirePredicate(predicate);
42
+ for (let index = this.length - 1; index >= 0; index--) {
43
+ if (predicate.call(thisArg, this[index], index, this)) return index;
44
+ }
45
+ return -1;
46
+ });
47
+ }
48
+
49
+ const copyArray = (list: Indexed) => Array.from(list);
50
+ installShared(Array.prototype, copyArray);
51
+ define(Array.prototype, "toSpliced", function (...args: Parameters<unknown[]["splice"]>) {
52
+ const result = copyArray(this);
53
+ result.splice(...args);
54
+ return result;
55
+ });
56
+ // The typed arrays share one prototype, and `slice` keeps the element type.
57
+ installShared(Object.getPrototypeOf(Int8Array.prototype), (list) => (list as Uint8Array).slice());