gloomberb 0.10.4 → 0.11.0
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.
- package/LICENSE +1 -1
- package/README.md +30 -3
- package/README.zh-CN.md +1 -1
- package/package.json +5 -5
- package/src/api-client/auth.ts +34 -0
- package/src/api-client/data.ts +25 -0
- package/src/api-client/index.test.ts +81 -0
- package/src/api-client/index.ts +37 -0
- package/src/api-client/request.test.ts +30 -0
- package/src/api-client/request.ts +44 -20
- package/src/api-client/socket-health.test.ts +79 -0
- package/src/api-client/socket.ts +108 -5
- package/src/api-client/types.ts +139 -0
- package/src/app/global-shortcuts.test.tsx +144 -9
- package/src/app/global-shortcuts.ts +33 -11
- package/src/app/runtime/broker-import.ts +39 -5
- package/src/app/runtime/startup.ts +7 -1
- package/src/app/runtime/update.ts +26 -1
- package/src/app.tsx +36 -19
- package/src/brokers/broker-ticker-sync.ts +3 -8
- package/src/brokers/sync-broker-instance.test.ts +59 -0
- package/src/brokers/sync-broker-instance.ts +37 -13
- package/src/capabilities/chart-series.ts +318 -0
- package/src/capabilities/factories.ts +46 -0
- package/src/capabilities/index.ts +1 -0
- package/src/capabilities/registry.test.ts +135 -0
- package/src/capabilities/registry.ts +31 -4
- package/src/capabilities/types.ts +52 -0
- package/src/cli/commands/overview.ts +2 -2
- package/src/cli/desktop-pane-shot.ts +2 -0
- package/src/cli/entry.ts +11 -1
- package/src/cli/native-smoke.ts +5 -0
- package/src/cli/pane-functions/catalog.ts +4 -0
- package/src/cli/pane-functions/data.ts +6 -1
- package/src/cli/pane-functions/discovery.ts +76 -10
- package/src/cli/pane-functions/report.test.ts +76 -0
- package/src/cli/pane-functions/report.ts +7 -1
- package/src/cli/pane-functions/resolver.ts +4 -1
- package/src/cli/pane-functions/screenshot.test.ts +56 -3
- package/src/cli/pane-functions/screenshot.ts +68 -5
- package/src/components/chart/composite/composite-chart.test.tsx +54 -0
- package/src/components/chart/composite/composite-chart.tsx +92 -15
- package/src/components/chart/composite/downsample.test.ts +136 -0
- package/src/components/chart/composite/downsample.ts +208 -0
- package/src/components/chart/composite/panel-series.test.ts +66 -0
- package/src/components/chart/composite/panel-series.ts +101 -0
- package/src/components/chart/multi-line/renderer.ts +1 -0
- package/src/components/chart/native/kitty/index.test.ts +25 -3
- package/src/components/chart/native/kitty/support.ts +37 -3
- package/src/components/chart/native/use-chart-text-fallback.ts +19 -0
- package/src/components/chart/static/chart/surface.tsx +43 -12
- package/src/components/chart/static/multi-line-chart-surface.tsx +41 -5
- package/src/components/command-bar/commands/direct/index.ts +18 -0
- package/src/components/command-bar/commands/registry.ts +14 -0
- package/src/components/command-bar/routes/root/article-results.test.ts +83 -0
- package/src/components/command-bar/routes/root/article-results.ts +55 -0
- package/src/components/command-bar/routes/root/command-items.ts +3 -0
- package/src/components/command-bar/routes/root/provider-search.ts +7 -3
- package/src/components/command-bar/routes/root/results.ts +38 -11
- package/src/components/command-bar/routes/root/runtime.ts +6 -2
- package/src/components/command-bar/routes/ticker-search/actions.ts +1 -1
- package/src/components/command-bar/routes/ticker-search/results.test.ts +34 -0
- package/src/components/command-bar/routes/ticker-search/results.ts +4 -6
- package/src/components/command-bar/routes/ticker-search/route.ts +2 -2
- package/src/components/command-bar/routing/list-state.ts +2 -1
- package/src/components/command-bar/surface/assist.test.tsx +13 -6
- package/src/components/command-bar/surface/index.test.tsx +65 -0
- package/src/components/command-bar/surface/index.tsx +35 -0
- package/src/components/command-bar/view-model.test.ts +43 -0
- package/src/components/command-bar/view-model.ts +41 -4
- package/src/components/command-bar/workflow/collection-actions.test.ts +94 -0
- package/src/components/command-bar/workflow/collection-actions.ts +14 -3
- package/src/components/command-bar/workflow/ops.test.ts +136 -0
- package/src/components/command-bar/workflow/ops.ts +71 -1
- package/src/components/index.ts +1 -1
- package/src/components/layout/header.test.tsx +35 -0
- package/src/components/layout/header.tsx +101 -9
- package/src/components/layout/pane/cycle-order.test.ts +0 -1
- package/src/components/layout/pane/footer/index.test.tsx +19 -19
- package/src/components/layout/pane/header.tsx +2 -13
- package/src/components/layout/shell/index.tsx +3 -0
- package/src/components/layout/status-bar.test.tsx +36 -1
- package/src/components/layout/status-bar.tsx +48 -2
- package/src/components/onboarding/account-step/chooser-panel.tsx +27 -50
- package/src/components/onboarding/account-step/form-panel.tsx +85 -29
- package/src/components/onboarding/account-step/index.tsx +10 -1
- package/src/components/onboarding/account-step/model.ts +3 -3
- package/src/components/onboarding/account-step/qr-panel.tsx +68 -0
- package/src/components/onboarding/account-step/signed-in-panel.tsx +4 -7
- package/src/components/onboarding/onboarding-frame.tsx +517 -0
- package/src/components/onboarding/onboarding-steps.tsx +0 -264
- package/src/components/onboarding/onboarding-wizard.test.tsx +626 -200
- package/src/components/onboarding/onboarding-wizard.tsx +848 -266
- package/src/components/onboarding/portfolio-step/broker-fields-panel.tsx +81 -51
- package/src/components/onboarding/portfolio-step/broker-setup-panel.tsx +14 -20
- package/src/components/onboarding/portfolio-step/broker-sync-panel.tsx +8 -11
- package/src/components/onboarding/portfolio-step/choose-panel.tsx +18 -22
- package/src/components/onboarding/portfolio-step/index.tsx +3 -0
- package/src/components/onboarding/portfolio-step/types.ts +3 -0
- package/src/components/onboarding/wizard-account.ts +38 -3
- package/src/components/onboarding/wizard-broker-sync.ts +45 -67
- package/src/components/onboarding/wizard-model.ts +18 -2
- package/src/components/ui/data-table/opentui/index.tsx +29 -9
- package/src/components/ui/data-table/types.ts +2 -0
- package/src/components/ui/external-link.tsx +4 -2
- package/src/components/ui/loading.tsx +1 -1
- package/src/components/ui/status.tsx +76 -4
- package/src/components/ui/table-layout.test.ts +24 -0
- package/src/components/ui/table-layout.ts +90 -23
- package/src/components/ui/tabs.tsx +86 -4
- package/src/core/app-services.ts +14 -3
- package/src/core/connection-health.test.ts +143 -0
- package/src/core/connection-health.ts +295 -0
- package/src/core/state/app/layout-reducer.ts +34 -0
- package/src/core/state/app/layout.ts +21 -0
- package/src/core/state/app/state.ts +10 -0
- package/src/core/state/app/types.ts +7 -1
- package/src/data/config/chart-settings.ts +11 -2
- package/src/data/config/store/index.test.ts +83 -9
- package/src/data/config/store/migrations.ts +16 -0
- package/src/data/config/store/normalize.ts +59 -1
- package/src/data/fred-series.ts +8 -2
- package/src/i18n/es.ts +126 -0
- package/src/i18n/ja.ts +126 -0
- package/src/i18n/ko.ts +126 -0
- package/src/i18n/zh-cn.ts +126 -0
- package/src/i18n/zh-tw.ts +126 -0
- package/src/market-data/coordinator/chart.ts +3 -2
- package/src/market-data/hooks.tsx +3 -2
- package/src/market-data/market/status.test.ts +12 -0
- package/src/market-data/market/status.ts +34 -17
- package/src/news/aggregator.test.ts +39 -0
- package/src/news/aggregator.ts +78 -22
- package/src/news/hooks.ts +4 -0
- package/src/notifications/app-notifier.test.ts +28 -6
- package/src/notifications/app-notifier.ts +24 -5
- package/src/plugins/broker-sync/broker-sync.test.ts +130 -0
- package/src/plugins/broker-sync/native-loader.ts +10 -0
- package/src/plugins/broker-sync/normalize.ts +271 -0
- package/src/plugins/broker-sync/public.ts +122 -0
- package/src/plugins/broker-sync/robinhood-native.ts +367 -0
- package/src/plugins/broker-sync/robinhood.ts +114 -0
- package/src/plugins/broker-sync/simplefin-native.ts +201 -0
- package/src/plugins/broker-sync/simplefin.ts +70 -0
- package/src/plugins/builtin/account-management/footer.ts +8 -19
- package/src/plugins/builtin/account-management/pane.tsx +13 -8
- package/src/plugins/builtin/ai/pi/host.ts +6 -5
- package/src/plugins/builtin/ai/providers.ts +1 -1
- package/src/plugins/builtin/ai/screener/footer.ts +0 -7
- package/src/plugins/builtin/ai/screener/pane.test.tsx +2 -1
- package/src/plugins/builtin/ai/screener/pane.tsx +3 -1
- package/src/plugins/builtin/ai/screener/results-view.tsx +8 -0
- package/src/plugins/builtin/ai/screener/runner.ts +7 -3
- package/src/plugins/builtin/ai/workspace/pane.tsx +13 -2
- package/src/plugins/builtin/alerts/alert-engine.ts +13 -0
- package/src/plugins/builtin/alerts/constants.ts +2 -1
- package/src/plugins/builtin/alerts/index.tsx +67 -36
- package/src/plugins/builtin/alerts/pane.tsx +17 -65
- package/src/plugins/builtin/analytics/index.tsx +24 -11
- package/src/plugins/builtin/analytics/pane-model.ts +48 -14
- package/src/plugins/builtin/analytics/portfolio-selection.ts +19 -0
- package/src/plugins/builtin/analytics/view.tsx +5 -3
- package/src/plugins/builtin/broker-manager/detail.tsx +7 -2
- package/src/plugins/builtin/broker-manager/footer.ts +4 -9
- package/src/plugins/builtin/broker-manager/index.tsx +1 -6
- package/src/plugins/builtin/buildout/detail/ui.tsx +15 -4
- package/src/plugins/builtin/buildout/pane/header.tsx +1 -0
- package/src/plugins/builtin/changelog/index.tsx +60 -45
- package/src/plugins/builtin/chart-composer/catalog-inventory.test.ts +97 -0
- package/src/plugins/builtin/chart-composer/catalog-inventory.ts +366 -0
- package/src/plugins/builtin/chart-composer/chart-spec.ts +21 -1
- package/src/plugins/builtin/chart-composer/data-catalog-pane.tsx +307 -0
- package/src/plugins/builtin/chart-composer/editor/controller.ts +1 -1
- package/src/plugins/builtin/chart-composer/index.tsx +45 -5
- package/src/plugins/builtin/chart-composer/pane.tsx +7 -88
- package/src/plugins/builtin/chart-composer/presets.test.ts +48 -0
- package/src/plugins/builtin/chart-composer/presets.ts +69 -3
- package/src/plugins/builtin/chart-composer/quick-add.tsx +8 -5
- package/src/plugins/builtin/chart-composer/semantic.ts +18 -14
- package/src/plugins/builtin/chart-composer/series-catalog.test.ts +39 -0
- package/src/plugins/builtin/chart-composer/series-catalog.ts +104 -3
- package/src/plugins/builtin/chart-composer/shortcuts.test.ts +10 -10
- package/src/plugins/builtin/chart-composer/shortcuts.ts +4 -12
- package/src/plugins/builtin/chart-composer/use-series-catalog.ts +230 -23
- package/src/plugins/builtin/chat/chat.test.tsx +22 -0
- package/src/plugins/builtin/chat/content/composer.tsx +6 -4
- package/src/plugins/builtin/chat/content/index.tsx +7 -0
- package/src/plugins/builtin/chat/content/snapshot.ts +9 -2
- package/src/plugins/builtin/chat/content/transcript.tsx +10 -0
- package/src/plugins/builtin/chat/controller/channel-actions.ts +11 -1
- package/src/plugins/builtin/chat/controller/channels.ts +13 -3
- package/src/plugins/builtin/chat/controller/index.ts +61 -7
- package/src/plugins/builtin/chat/controller/lifecycle.ts +3 -0
- package/src/plugins/builtin/chat/controller/message-loading.ts +5 -1
- package/src/plugins/builtin/chat/controller/messages.ts +3 -1
- package/src/plugins/builtin/chat/controller/notifications.ts +32 -11
- package/src/plugins/builtin/chat/controller/state.ts +7 -0
- package/src/plugins/builtin/chat/controller/view.ts +1 -0
- package/src/plugins/builtin/chat/controller.test.ts +117 -28
- package/src/plugins/builtin/cloud/auth-commands.ts +18 -0
- package/src/plugins/builtin/cloud/device-signin-dialog.tsx +243 -0
- package/src/plugins/builtin/cloud/device-signin.test.ts +217 -0
- package/src/plugins/builtin/cloud/device-signin.ts +240 -0
- package/src/plugins/builtin/cloud/plugin.tsx +7 -1
- package/src/plugins/builtin/cloud-tweets/table.tsx +57 -10
- package/src/plugins/builtin/composite-plugins.ts +39 -5
- package/src/plugins/builtin/congress-trades/detail.tsx +2 -4
- package/src/plugins/builtin/congress-trades/footer.ts +7 -16
- package/src/plugins/builtin/congress-trades/pane.tsx +12 -20
- package/src/plugins/builtin/connections/index.ts +53 -0
- package/src/plugins/builtin/connections/pane.test.tsx +79 -0
- package/src/plugins/builtin/connections/pane.tsx +258 -0
- package/src/plugins/builtin/correlation/index.test.tsx +2 -1
- package/src/plugins/builtin/correlation/index.tsx +58 -19
- package/src/plugins/builtin/correlation/matrix/model.ts +18 -7
- package/src/plugins/builtin/correlation/relationship/pane.tsx +43 -19
- package/src/plugins/builtin/correlation/settings.ts +1 -1
- package/src/plugins/builtin/credit-conditions/client.test.ts +80 -0
- package/src/plugins/builtin/credit-conditions/client.ts +105 -0
- package/src/plugins/builtin/credit-conditions/index.test.tsx +111 -0
- package/src/plugins/builtin/credit-conditions/index.tsx +227 -0
- package/src/plugins/builtin/credit-conditions/model.test.ts +43 -0
- package/src/plugins/builtin/credit-conditions/model.ts +64 -0
- package/src/plugins/builtin/debug/index.tsx +11 -6
- package/src/plugins/builtin/dividend-yield/client.test.ts +58 -0
- package/src/plugins/builtin/dividend-yield/client.ts +252 -0
- package/src/plugins/builtin/dividend-yield/index.tsx +61 -0
- package/src/plugins/builtin/dividend-yield/model.ts +83 -0
- package/src/plugins/builtin/dividend-yield/pane.tsx +305 -0
- package/src/plugins/builtin/dividend-yield/types.ts +22 -0
- package/src/plugins/builtin/earnings/data/cache.test.ts +10 -7
- package/src/plugins/builtin/earnings/data/cache.ts +23 -9
- package/src/plugins/builtin/earnings/index.tsx +57 -6
- package/src/plugins/builtin/econ/calendar-model.test.ts +37 -3
- package/src/plugins/builtin/econ/calendar-model.ts +32 -26
- package/src/plugins/builtin/econ/fred-cache.test.ts +8 -1
- package/src/plugins/builtin/econ/fred-series-map.ts +18 -0
- package/src/plugins/builtin/econ/index.test.tsx +105 -0
- package/src/plugins/builtin/econ/index.tsx +95 -52
- package/src/plugins/builtin/fear-greed/cache.test.ts +18 -3
- package/src/plugins/builtin/fear-greed/cache.ts +18 -6
- package/src/plugins/builtin/fear-greed/charts.tsx +9 -2
- package/src/plugins/builtin/fear-greed/format.ts +0 -9
- package/src/plugins/builtin/fear-greed/pane.tsx +21 -21
- package/src/plugins/builtin/futures/contracts.ts +100 -0
- package/src/plugins/builtin/futures/index.tsx +298 -0
- package/src/plugins/builtin/futures/model.test.ts +129 -0
- package/src/plugins/builtin/futures/model.ts +136 -0
- package/src/plugins/builtin/futures/pane.test.tsx +239 -0
- package/src/plugins/builtin/futures/table.test.ts +155 -0
- package/src/plugins/builtin/futures/table.tsx +241 -0
- package/src/plugins/builtin/fx-matrix/index.tsx +160 -134
- package/src/plugins/builtin/fx-matrix/pairs.ts +12 -1
- package/src/plugins/builtin/fx-matrix/pane.test.tsx +109 -0
- package/src/plugins/builtin/help/components.tsx +1 -30
- package/src/plugins/builtin/help/index.tsx +5 -25
- package/src/plugins/builtin/holders/pane.tsx +17 -12
- package/src/plugins/builtin/holders/treemap.tsx +4 -2
- package/src/plugins/builtin/insider/index.tsx +20 -10
- package/src/plugins/builtin/ipo-calendar/cache.ts +101 -0
- package/src/plugins/builtin/ipo-calendar/client.test.ts +31 -0
- package/src/plugins/builtin/ipo-calendar/client.ts +296 -0
- package/src/plugins/builtin/ipo-calendar/index.tsx +65 -0
- package/src/plugins/builtin/ipo-calendar/model.ts +145 -0
- package/src/plugins/builtin/ipo-calendar/pane.tsx +328 -0
- package/src/plugins/builtin/ipo-calendar/types.ts +19 -0
- package/src/plugins/builtin/kelly-sizer/index.test.tsx +3 -3
- package/src/plugins/builtin/kelly-sizer/model.ts +8 -1
- package/src/plugins/builtin/kelly-sizer/pane.tsx +33 -15
- package/src/plugins/builtin/kelly-sizer/view.tsx +12 -5
- package/src/plugins/builtin/market-halts/client.ts +114 -0
- package/src/plugins/builtin/market-halts/index.tsx +29 -0
- package/src/plugins/builtin/market-halts/model.test.ts +187 -0
- package/src/plugins/builtin/market-halts/model.ts +291 -0
- package/src/plugins/builtin/market-halts/pane.tsx +256 -0
- package/src/plugins/builtin/market-heatmap/data.test.ts +1 -0
- package/src/plugins/builtin/market-heatmap/data.ts +12 -3
- package/src/plugins/builtin/market-heatmap/index.tsx +131 -46
- package/src/plugins/builtin/market-movers/index.tsx +145 -63
- package/src/plugins/builtin/market-movers/model.ts +19 -3
- package/src/plugins/builtin/market-movers/screener.test.ts +108 -0
- package/src/plugins/builtin/market-movers/screener.ts +168 -10
- package/src/plugins/builtin/news/index.tsx +78 -99
- package/src/plugins/builtin/news/wire/article-search.test.ts +72 -0
- package/src/plugins/builtin/news/wire/article-search.ts +140 -0
- package/src/plugins/builtin/news/wire/breaking/pane.tsx +18 -8
- package/src/plugins/builtin/news/wire/categories.ts +35 -0
- package/src/plugins/builtin/news/wire/default-feeds.ts +47 -1
- package/src/plugins/builtin/news/wire/feed-config.test.ts +10 -5
- package/src/plugins/builtin/news/wire/index.tsx +41 -4
- package/src/plugins/builtin/news/wire/industry-pane.tsx +38 -19
- package/src/plugins/builtin/news/wire/news/detail-view.tsx +10 -5
- package/src/plugins/builtin/news/wire/news/footer.ts +1 -0
- package/src/plugins/builtin/news/wire/news/preset-pane.tsx +15 -6
- package/src/plugins/builtin/news/wire/news/query-presets.ts +16 -2
- package/src/plugins/builtin/news/wire/news/table.test.tsx +54 -0
- package/src/plugins/builtin/news/wire/news/table.tsx +111 -17
- package/src/plugins/builtin/notes/files.test.ts +18 -0
- package/src/plugins/builtin/notes/files.ts +10 -4
- package/src/plugins/builtin/notes/index.tsx +4 -1
- package/src/plugins/builtin/notes/quick-notes-pane.test.tsx +182 -0
- package/src/plugins/builtin/notes/quick-notes-pane.tsx +74 -31
- package/src/plugins/builtin/notes/ticker-notes-tab.test.tsx +380 -0
- package/src/plugins/builtin/notes/ticker-notes-tab.tsx +97 -40
- package/src/plugins/builtin/options/calc-seed.test.ts +118 -0
- package/src/plugins/builtin/options/calc-seed.ts +52 -0
- package/src/plugins/builtin/options/footer.ts +4 -1
- package/src/plugins/builtin/options/index.tsx +22 -1
- package/src/plugins/builtin/options/live-quotes.ts +8 -0
- package/src/plugins/builtin/options/table.ts +3 -1
- package/src/plugins/builtin/options/view.test.tsx +5 -1
- package/src/plugins/builtin/options/view.tsx +112 -17
- package/src/plugins/builtin/options-calculator/index.tsx +35 -0
- package/src/plugins/builtin/options-calculator/model.test.ts +172 -0
- package/src/plugins/builtin/options-calculator/model.ts +273 -0
- package/src/plugins/builtin/options-calculator/pane.test.tsx +138 -0
- package/src/plugins/builtin/options-calculator/pane.tsx +218 -0
- package/src/plugins/builtin/plugin-module.test.ts +16 -2
- package/src/plugins/builtin/plugin-module.ts +5 -1
- package/src/plugins/builtin/polls/client.ts +57 -0
- package/src/plugins/builtin/polls/hooks.ts +20 -0
- package/src/plugins/builtin/polls/index.tsx +35 -0
- package/src/plugins/builtin/polls/normalize.test.ts +230 -0
- package/src/plugins/builtin/polls/normalize.ts +319 -0
- package/src/plugins/builtin/polls/pane.tsx +722 -0
- package/src/plugins/builtin/polls/types.ts +77 -0
- package/src/plugins/builtin/portfolio-list/header.tsx +15 -4
- package/src/plugins/builtin/portfolio-list/pane/index.tsx +7 -3
- package/src/plugins/builtin/portfolio-list/pane/supplemental.ts +1 -1
- package/src/plugins/builtin/portfolio-list/quick-add/index.tsx +2 -0
- package/src/plugins/builtin/portfolio-list/summary/index.tsx +2 -1
- package/src/plugins/builtin/research/analyst-pane.tsx +40 -67
- package/src/plugins/builtin/research/corporate-actions-pane.tsx +25 -19
- package/src/plugins/builtin/research/index.test.ts +6 -25
- package/src/plugins/builtin/research/index.tsx +11 -5
- package/src/plugins/builtin/research/relative-valuation-pane.tsx +86 -26
- package/src/plugins/builtin/scanner/denied.tsx +31 -0
- package/src/plugins/builtin/scanner/feed.ts +94 -0
- package/src/plugins/builtin/scanner/flow-model.test.ts +85 -0
- package/src/plugins/builtin/scanner/flow-model.ts +133 -0
- package/src/plugins/builtin/scanner/flow-pane.tsx +197 -0
- package/src/plugins/builtin/scanner/hilo-bars.tsx +121 -0
- package/src/plugins/builtin/scanner/hilo-model.test.ts +44 -0
- package/src/plugins/builtin/scanner/hilo-model.ts +75 -0
- package/src/plugins/builtin/scanner/hilo-pane.tsx +165 -0
- package/src/plugins/builtin/scanner/index.ts +109 -0
- package/src/plugins/builtin/scanner/waiting.tsx +11 -0
- package/src/plugins/builtin/sec/index.tsx +11 -7
- package/src/plugins/builtin/sectors/index.tsx +105 -81
- package/src/plugins/builtin/sectors/move-bar.tsx +43 -0
- package/src/plugins/builtin/sectors/sector-data.ts +18 -0
- package/src/plugins/builtin/sectors/sector-model.ts +13 -15
- package/src/plugins/builtin/shared/auto-refresh.ts +51 -0
- package/src/plugins/builtin/shared/cloud-upgrade.ts +29 -5
- package/src/plugins/builtin/shared/pane-footer.ts +16 -3
- package/src/plugins/builtin/shared/screener-live-quotes.test.ts +91 -0
- package/src/plugins/builtin/shared/screener-live-quotes.ts +134 -0
- package/src/plugins/builtin/shared/table-pane.ts +1 -5
- package/src/plugins/builtin/shared/use-quote-board.test.tsx +211 -0
- package/src/plugins/builtin/shared/use-quote-board.ts +195 -0
- package/src/plugins/builtin/short-interest/client.ts +124 -0
- package/src/plugins/builtin/short-interest/index.tsx +62 -0
- package/src/plugins/builtin/short-interest/model.ts +113 -0
- package/src/plugins/builtin/short-interest/pane.tsx +252 -0
- package/src/plugins/builtin/short-interest/types.ts +9 -0
- package/src/plugins/builtin/substack/article-detail.tsx +15 -1
- package/src/plugins/builtin/substack/pane-footer.ts +3 -22
- package/src/plugins/builtin/substack/pane.tsx +1 -2
- package/src/plugins/builtin/thirteenf/api.ts +4 -1
- package/src/plugins/builtin/thirteenf/model.ts +2 -0
- package/src/plugins/builtin/thirteenf/pane.tsx +6 -2
- package/src/plugins/builtin/ticker-detail/data-panes/historical-prices.tsx +10 -4
- package/src/plugins/builtin/ticker-detail/data-panes/provider-search.tsx +67 -11
- package/src/plugins/builtin/ticker-detail/financials/tab.tsx +15 -8
- package/src/plugins/builtin/ticker-detail/index.tsx +5 -21
- package/src/plugins/builtin/ticker-detail/overview/components.tsx +72 -32
- package/src/plugins/builtin/ticker-detail/overview-tab.tsx +0 -10
- package/src/plugins/builtin/ticker-detail/pane.tsx +4 -1
- package/src/plugins/builtin/ticker-detail/quote-monitor/card.test.tsx +70 -0
- package/src/plugins/builtin/ticker-detail/quote-monitor/card.tsx +34 -26
- package/src/plugins/builtin/ticker-detail/quote-monitor/index.tsx +96 -49
- package/src/plugins/builtin/ticker-detail/research-tabs.ts +32 -0
- package/src/plugins/builtin/ticker-research-backend-plugin.ts +2 -9
- package/src/plugins/builtin/ticker-research-plugin.ts +6 -0
- package/src/plugins/builtin/treasury-auctions/cache.test.ts +173 -0
- package/src/plugins/builtin/treasury-auctions/cache.ts +104 -0
- package/src/plugins/builtin/treasury-auctions/client.test.ts +181 -0
- package/src/plugins/builtin/treasury-auctions/client.ts +151 -0
- package/src/plugins/builtin/treasury-auctions/index.tsx +90 -0
- package/src/plugins/builtin/treasury-auctions/model.test.ts +147 -0
- package/src/plugins/builtin/treasury-auctions/model.ts +188 -0
- package/src/plugins/builtin/treasury-auctions/pane.test.tsx +170 -0
- package/src/plugins/builtin/treasury-auctions/pane.tsx +417 -0
- package/src/plugins/builtin/treasury-auctions/types.ts +59 -0
- package/src/plugins/builtin/tv/pane.tsx +67 -7
- package/src/plugins/builtin/tv/youtube-embed.test.ts +84 -0
- package/src/plugins/builtin/tv/youtube-embed.ts +173 -0
- package/src/plugins/builtin/tv/youtube-stream.ts +27 -2
- package/src/plugins/builtin/volatility/client.ts +87 -0
- package/src/plugins/builtin/volatility/index.test.tsx +107 -0
- package/src/plugins/builtin/volatility/index.tsx +193 -0
- package/src/plugins/builtin/volatility/model.test.ts +66 -0
- package/src/plugins/builtin/volatility/model.ts +113 -0
- package/src/plugins/builtin/world-indices/footer.ts +43 -23
- package/src/plugins/builtin/world-indices/index.tsx +44 -93
- package/src/plugins/builtin/world-indices/indices.ts +11 -2
- package/src/plugins/builtin/world-indices/model.ts +17 -24
- package/src/plugins/builtin/world-indices/pane.test.tsx +116 -0
- package/src/plugins/builtin/world-indices/table.tsx +82 -37
- package/src/plugins/builtin/yield-curve/index.tsx +16 -7
- package/src/plugins/builtin/yield-curve/treasury-data.test.ts +25 -0
- package/src/plugins/builtin/yield-curve/treasury-data.ts +16 -0
- package/src/plugins/catalog-backend.ts +8 -0
- package/src/plugins/catalog-ui.ts +8 -0
- package/src/plugins/event-bus.ts +1 -0
- package/src/plugins/ibkr/gateway/account-loaders.ts +1 -1
- package/src/plugins/ibkr/trade/tab/footer.ts +9 -23
- package/src/plugins/ibkr/trade/tab/index.tsx +1 -5
- package/src/plugins/ibkr/trading/pane-view.tsx +149 -87
- package/src/plugins/ibkr/trading/pane.tsx +2 -2
- package/src/plugins/ownership.ts +3 -0
- package/src/plugins/pane-manager/floating.ts +8 -2
- package/src/plugins/pane-manager.test.ts +13 -0
- package/src/plugins/prediction-markets/backend-plugin.ts +2 -0
- package/src/plugins/prediction-markets/capability.test.ts +281 -0
- package/src/plugins/prediction-markets/capability.ts +171 -0
- package/src/plugins/prediction-markets/chart.tsx +18 -26
- package/src/plugins/prediction-markets/columns.ts +3 -2
- package/src/plugins/prediction-markets/controller/catalog.ts +15 -12
- package/src/plugins/prediction-markets/controller/detail.ts +4 -0
- package/src/plugins/prediction-markets/controller/index.ts +0 -15
- package/src/plugins/prediction-markets/detail/book.tsx +3 -23
- package/src/plugins/prediction-markets/detail/overview.tsx +0 -18
- package/src/plugins/prediction-markets/detail/pane.tsx +36 -12
- package/src/plugins/prediction-markets/detail.test.tsx +1 -1
- package/src/plugins/prediction-markets/index.tsx +2 -0
- package/src/plugins/prediction-markets/metrics.ts +28 -18
- package/src/plugins/prediction-markets/navigation.ts +1 -0
- package/src/plugins/prediction-markets/pane.test.tsx +1 -1
- package/src/plugins/prediction-markets/pane.tsx +0 -1
- package/src/plugins/prediction-markets/services/fetch.ts +3 -2
- package/src/plugins/prediction-markets/services/kalshi/adapter.ts +82 -23
- package/src/plugins/prediction-markets/services/kalshi/normalize.ts +3 -1
- package/src/plugins/prediction-markets/services/kalshi/types.ts +14 -0
- package/src/plugins/prediction-markets/services/polymarket/adapter.ts +26 -14
- package/src/plugins/prediction-markets/services/polymarket/detail.ts +67 -18
- package/src/plugins/prediction-markets/test-helpers.tsx +0 -1
- package/src/plugins/prediction-markets/types.ts +3 -9
- package/src/plugins/registry/context.ts +6 -1
- package/src/plugins/registry/index.test.ts +2 -0
- package/src/plugins/registry/index.ts +53 -3
- package/src/plugins/runtime/context.tsx +4 -2
- package/src/plugins/runtime/index.tsx +9 -0
- package/src/remote/controller.test.ts +17 -4
- package/src/renderers/electrobun/bun/application-menu/index.ts +1 -1
- package/src/renderers/electrobun/bun/core-capabilities.ts +2 -2
- package/src/renderers/electrobun/bun/desktop/capability-bridge.test.ts +64 -0
- package/src/renderers/electrobun/bun/desktop/capability-bridge.ts +41 -7
- package/src/renderers/electrobun/bun/desktop/host-requests.ts +5 -2
- package/src/renderers/electrobun/bun/desktop/http-fetch.test.ts +33 -0
- package/src/renderers/electrobun/bun/desktop/http-fetch.ts +53 -6
- package/src/renderers/electrobun/bun/desktop/initialization.test.ts +27 -0
- package/src/renderers/electrobun/bun/desktop/initialization.ts +6 -1
- package/src/renderers/electrobun/bun/index.ts +1 -0
- package/src/renderers/electrobun/shared/protocol.ts +2 -0
- package/src/renderers/electrobun/view/app-services.ts +25 -2
- package/src/renderers/electrobun/view/build-assets.ts +5 -0
- package/src/renderers/electrobun/view/cli-pane-shot-entry.tsx +186 -65
- package/src/renderers/electrobun/view/cli-pane-shot-health.test.ts +25 -0
- package/src/renderers/electrobun/view/cli-pane-shot-health.ts +31 -0
- package/src/renderers/electrobun/view/data-table/index.tsx +10 -11
- package/src/renderers/electrobun/view/data-table/row.tsx +2 -0
- package/src/renderers/electrobun/view/desktop/controls.test.tsx +68 -0
- package/src/renderers/electrobun/view/desktop/controls.tsx +25 -1
- package/src/renderers/electrobun/view/host/box.test.tsx +80 -0
- package/src/renderers/electrobun/view/host/media-surface.tsx +70 -3
- package/src/renderers/electrobun/view/host/tabs.tsx +97 -5
- package/src/renderers/electrobun/view/host/text.tsx +5 -2
- package/src/renderers/electrobun/view/input-host.test.tsx +140 -0
- package/src/renderers/electrobun/view/input-host.tsx +4 -2
- package/src/renderers/electrobun/view/native-stubs/backend-rpc.ts +19 -1
- package/src/renderers/electrobun/view/native-stubs/broker-sync-native-loader.ts +7 -0
- package/src/renderers/electrobun/view/native-stubs/chart/kitty-support.ts +10 -0
- package/src/renderers/electrobun/view/remote/capability-invoker.test.ts +46 -0
- package/src/renderers/electrobun/view/remote/capability-invoker.ts +34 -13
- package/src/renderers/electrobun/view/remote/connection-health-backend.ts +19 -0
- package/src/renderers/electrobun/view/remote/connection-health.test.ts +44 -0
- package/src/renderers/electrobun/view/remote/connection-health.ts +49 -0
- package/src/renderers/electrobun/view/styles.css +5 -0
- package/src/renderers/opentui/dialog-host.tsx +279 -80
- package/src/renderers/opentui/host.tsx +15 -1
- package/src/renderers/opentui/terminal-media.test.ts +102 -0
- package/src/renderers/opentui/terminal-media.ts +142 -0
- package/src/renderers/opentui/test-utils.tsx +9 -6
- package/src/renderers/opentui/toast-host.tsx +136 -7
- package/src/renderers/opentui/ui-host.tsx +19 -3
- package/src/sources/provider-router/connection-health.test.ts +28 -0
- package/src/sources/provider-router/connection-health.ts +47 -0
- package/src/sources/provider-router/history.test.ts +53 -4
- package/src/sources/provider-router/history.ts +119 -14
- package/src/sources/provider-router/index.ts +12 -1
- package/src/sources/yahoo-finance/history.ts +2 -9
- package/src/sources/yahoo-finance/http.ts +1 -1
- package/src/sources/yahoo-finance/symbols.ts +1 -1
- package/src/sources/yahoo-finance/types.ts +19 -0
- package/src/state/app/context/index.test.tsx +101 -0
- package/src/state/app/context/index.tsx +10 -0
- package/src/state/config-save-scheduler.ts +1 -6
- package/src/state/persist-scheduler.test.ts +31 -0
- package/src/state/persist-scheduler.ts +21 -8
- package/src/sync/auth-transition.test.ts +36 -0
- package/src/sync/auth-transition.ts +22 -0
- package/src/sync/core-contributors.test.ts +58 -1
- package/src/sync/core-contributors.ts +39 -2
- package/src/sync/react.ts +9 -0
- package/src/test-support/plugin-runtime.ts +3 -0
- package/src/theme/font-scale.test.ts +14 -0
- package/src/theme/font-scale.ts +69 -0
- package/src/tickers/search/index.test.ts +284 -2
- package/src/tickers/search/index.ts +55 -18
- package/src/tickers/search/ranking.ts +143 -18
- package/src/tickers/search/types.ts +1 -0
- package/src/time-series/alignment.ts +15 -11
- package/src/time-series/field-catalog.ts +10 -0
- package/src/time-series/fundamentals.ts +19 -11
- package/src/time-series/hooks.ts +8 -2
- package/src/time-series/parsed-history-cache.ts +35 -0
- package/src/time-series/resolution.ts +10 -0
- package/src/time-series/resolve.test.ts +332 -3
- package/src/time-series/resolve.ts +225 -25
- package/src/time-series/spec-studies.test.ts +23 -0
- package/src/time-series/spec.ts +21 -2
- package/src/time-series/transforms.test.ts +76 -1
- package/src/time-series/transforms.ts +39 -8
- package/src/time-series/types.ts +9 -2
- package/src/time-series/use-chart-resolution.test.tsx +105 -1
- package/src/time-series/use-chart-resolution.ts +67 -13
- package/src/types/config.ts +30 -27
- package/src/types/media.ts +2 -0
- package/src/types/plugin.ts +8 -1
- package/src/ui/host.tsx +4 -0
- package/src/ui/pointer-drag.ts +12 -0
- package/src/ui/qr.test.ts +79 -0
- package/src/ui/qr.ts +82 -0
- package/src/updater/github-releases.test.ts +3 -3
- package/src/updater/github-releases.ts +1 -1
- package/src/updater.test.ts +117 -16
- package/src/updater.ts +32 -5
- package/src/utils/exchanges.ts +1 -0
- package/src/utils/external-url.test.ts +32 -0
- package/src/utils/external-url.ts +23 -0
- package/src/utils/sort-values.ts +31 -0
- package/src/utils/zoned-date-time.ts +67 -0
- package/src/components/onboarding/wizard-keyboard.ts +0 -306
- package/src/plugins/builtin/chart-composer/date-window-dialog.tsx +0 -120
|
@@ -19,12 +19,8 @@ export type CountryFilter = "all" | "US" | "G7" | "EU";
|
|
|
19
19
|
export const FILTER_CYCLE: ImpactFilter[] = ["all", "high", "medium", "low"];
|
|
20
20
|
export const COUNTRY_CYCLE: CountryFilter[] = ["all", "US", "G7", "EU"];
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const FLAG_MAP: Record<string, string> = {
|
|
25
|
-
US: "🇺🇸", GB: "🇬🇧", EU: "🇪🇺", JP: "🇯🇵", CA: "🇨🇦",
|
|
26
|
-
AU: "🇦🇺", CH: "🇨🇭", CN: "🇨🇳", NZ: "🇳🇿", SE: "🇸🇪", "--": "🌐",
|
|
27
|
-
};
|
|
22
|
+
/** The seven members plus the EU, which attends every summit. */
|
|
23
|
+
const G7_COUNTRIES = new Set(["US", "GB", "FR", "DE", "IT", "JP", "CA", "EU"]);
|
|
28
24
|
|
|
29
25
|
const DAY_NAMES = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"] as const;
|
|
30
26
|
const MONTH_NAMES = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"] as const;
|
|
@@ -48,7 +44,7 @@ type PersistedEconEvent = Omit<EconEvent, "date"> & { date: string };
|
|
|
48
44
|
export type EconCalendarCacheEntry = { data: EconEvent[]; fetchedAt: number; stale: boolean };
|
|
49
45
|
|
|
50
46
|
let econCalendarPersistence: PluginPersistence | null = null;
|
|
51
|
-
let activeFetch: Promise<
|
|
47
|
+
let activeFetch: Promise<EconCalendarLoadResult> | null = null;
|
|
52
48
|
|
|
53
49
|
export function attachEconCalendarPersistence(persistence: PluginPersistence): void {
|
|
54
50
|
econCalendarPersistence = persistence;
|
|
@@ -59,18 +55,15 @@ export function resetEconCalendarPersistence(): void {
|
|
|
59
55
|
activeFetch = null;
|
|
60
56
|
}
|
|
61
57
|
|
|
62
|
-
|
|
63
|
-
return FLAG_MAP[code] ?? code;
|
|
64
|
-
}
|
|
65
|
-
|
|
58
|
+
/** Words rather than dots: a three-wide column has no room for a legend. */
|
|
66
59
|
export function impactIndicator(impact: EconImpact): { text: string; color: string } {
|
|
67
60
|
switch (impact) {
|
|
68
61
|
case "high":
|
|
69
|
-
return { text: "
|
|
62
|
+
return { text: "HIGH", color: colors.negative };
|
|
70
63
|
case "medium":
|
|
71
|
-
return { text: "
|
|
64
|
+
return { text: "MED", color: colors.warning };
|
|
72
65
|
case "low":
|
|
73
|
-
return { text: "
|
|
66
|
+
return { text: "LOW", color: colors.textDim };
|
|
74
67
|
}
|
|
75
68
|
}
|
|
76
69
|
|
|
@@ -91,17 +84,18 @@ export function dayLabel(d: Date, today: Date): string {
|
|
|
91
84
|
const dateNum = d.getDate();
|
|
92
85
|
const suffix = `${dayName} ${monthName} ${dateNum}`;
|
|
93
86
|
|
|
94
|
-
if (dk === todayKey) return `TODAY
|
|
95
|
-
if (dk === dateKey(tomorrow)) return `TOMORROW
|
|
96
|
-
if (dk === dateKey(yesterday)) return `YESTERDAY
|
|
87
|
+
if (dk === todayKey) return `TODAY · ${suffix}`;
|
|
88
|
+
if (dk === dateKey(tomorrow)) return `TOMORROW · ${suffix}`;
|
|
89
|
+
if (dk === dateKey(yesterday)) return `YESTERDAY · ${suffix}`;
|
|
97
90
|
return suffix;
|
|
98
91
|
}
|
|
99
92
|
|
|
93
|
+
/**
|
|
94
|
+
* Each level selects exactly its own events. "At least this impact" made the
|
|
95
|
+
* lowest level identical to "all", which read as a broken filter.
|
|
96
|
+
*/
|
|
100
97
|
export function matchesImpact(event: EconEvent, filter: ImpactFilter): boolean {
|
|
101
|
-
|
|
102
|
-
if (filter === "high") return event.impact === "high";
|
|
103
|
-
if (filter === "medium") return event.impact === "medium" || event.impact === "high";
|
|
104
|
-
return true;
|
|
98
|
+
return filter === "all" || event.impact === filter;
|
|
105
99
|
}
|
|
106
100
|
|
|
107
101
|
export function matchesCountry(event: EconEvent, filter: CountryFilter): boolean {
|
|
@@ -179,22 +173,34 @@ export function getFreshCalendarCache(): EconCalendarCacheEntry | null {
|
|
|
179
173
|
return cached && !cached.stale ? cached : null;
|
|
180
174
|
}
|
|
181
175
|
|
|
176
|
+
export interface EconCalendarLoadResult extends EconCalendarCacheEntry {
|
|
177
|
+
/** Set when the network failed and cached events were served instead. */
|
|
178
|
+
refreshError?: string;
|
|
179
|
+
}
|
|
180
|
+
|
|
182
181
|
export async function loadCalendar(
|
|
183
182
|
force = false,
|
|
184
183
|
loader: () => Promise<EconEvent[]> = fetchEconCalendar,
|
|
185
|
-
): Promise<
|
|
184
|
+
): Promise<EconCalendarLoadResult> {
|
|
186
185
|
const cached = getCalendarCache();
|
|
187
|
-
if (!force && cached && !cached.stale) return cached
|
|
186
|
+
if (!force && cached && !cached.stale) return cached;
|
|
188
187
|
if (activeFetch) return activeFetch;
|
|
189
188
|
|
|
190
189
|
const fallback = cached ?? getCalendarCache({ allowExpired: true });
|
|
191
190
|
activeFetch = loader().then((data) => {
|
|
192
191
|
writeCache(data);
|
|
193
192
|
activeFetch = null;
|
|
194
|
-
return data;
|
|
195
|
-
}).catch((err) => {
|
|
193
|
+
return { data, fetchedAt: Date.now(), stale: false };
|
|
194
|
+
}).catch((err: unknown) => {
|
|
196
195
|
activeFetch = null;
|
|
197
|
-
|
|
196
|
+
// A failed refresh must not pass old events off as a fresh load.
|
|
197
|
+
if (fallback) {
|
|
198
|
+
return {
|
|
199
|
+
...fallback,
|
|
200
|
+
stale: true,
|
|
201
|
+
refreshError: err instanceof Error ? err.message : String(err),
|
|
202
|
+
};
|
|
203
|
+
}
|
|
198
204
|
throw err;
|
|
199
205
|
});
|
|
200
206
|
return activeFetch;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { afterEach, describe, expect, test } from "bun:test";
|
|
1
|
+
import { afterEach, beforeEach, describe, expect, test } from "bun:test";
|
|
2
2
|
import { MemoryPluginPersistence } from "../../../test-support/plugin-persistence";
|
|
3
3
|
import {
|
|
4
4
|
attachFredSeriesPersistence,
|
|
@@ -32,6 +32,13 @@ function makeSeries(value: number): FredSeriesData {
|
|
|
32
32
|
};
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
+
// Plugin activation in other test files attaches a live persistence to this
|
|
36
|
+
// module and never detaches it, so the cache these tests exercise depends on
|
|
37
|
+
// which file ran first. Establish the state instead of inheriting it.
|
|
38
|
+
beforeEach(() => {
|
|
39
|
+
resetFredSeriesPersistence();
|
|
40
|
+
});
|
|
41
|
+
|
|
35
42
|
afterEach(() => {
|
|
36
43
|
resetFredSeriesPersistence();
|
|
37
44
|
});
|
|
@@ -83,3 +83,21 @@ export function resolveFredMapping(eventTitle: string, country: string): FredMap
|
|
|
83
83
|
export function getRelatedTickers(eventTitle: string, country: string): string[] {
|
|
84
84
|
return resolveFredMapping(eventTitle, country)?.relatedTickers ?? [];
|
|
85
85
|
}
|
|
86
|
+
|
|
87
|
+
const FRED_CATALOG_SERIES: ReadonlyArray<{ seriesId: string; label: string }> = (() => {
|
|
88
|
+
const labels = new Map<string, string>();
|
|
89
|
+
for (const [key, mapping] of Object.entries(SERIES_MAP)) {
|
|
90
|
+
const existing = labels.get(mapping.seriesId);
|
|
91
|
+
if (existing == null || key.length < existing.length) {
|
|
92
|
+
labels.set(mapping.seriesId, key);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return [...labels.entries()].map(([seriesId, key]) => ({
|
|
96
|
+
seriesId,
|
|
97
|
+
label: key.replace(/\b\w/g, (char) => char.toUpperCase()),
|
|
98
|
+
}));
|
|
99
|
+
})();
|
|
100
|
+
|
|
101
|
+
export function listFredCatalogSeries(): ReadonlyArray<{ seriesId: string; label: string }> {
|
|
102
|
+
return FRED_CATALOG_SERIES;
|
|
103
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { afterEach, describe, expect, test } from "bun:test";
|
|
2
|
+
import { act } from "react";
|
|
3
|
+
import { testRender } from "../../../renderers/opentui/test-utils";
|
|
4
|
+
import { PaneFooterProvider } from "../../../components/layout/pane/footer";
|
|
5
|
+
import { AppContext, createInitialState, PaneInstanceProvider } from "../../../state/app/context";
|
|
6
|
+
import { createDefaultConfig } from "../../../types/config";
|
|
7
|
+
import { MemoryPluginPersistence } from "../../../test-support/plugin-persistence";
|
|
8
|
+
import { PluginRenderProvider, type PluginRuntimeAccess } from "../../runtime";
|
|
9
|
+
import { attachEconCalendarPersistence, resetEconCalendarPersistence } from "./calendar-model";
|
|
10
|
+
import { economicCalendarModule } from "./index";
|
|
11
|
+
|
|
12
|
+
const EconPane = economicCalendarModule.panes![0]!.component as (props: {
|
|
13
|
+
paneId: string;
|
|
14
|
+
paneType: string;
|
|
15
|
+
focused: boolean;
|
|
16
|
+
width: number;
|
|
17
|
+
height: number;
|
|
18
|
+
}) => React.ReactNode;
|
|
19
|
+
|
|
20
|
+
let setup: Awaited<ReturnType<typeof testRender>> | undefined;
|
|
21
|
+
|
|
22
|
+
function seedCalendar(): void {
|
|
23
|
+
const persistence = new MemoryPluginPersistence();
|
|
24
|
+
const now = Date.now();
|
|
25
|
+
persistence.seedResource("calendar", "global", [
|
|
26
|
+
{
|
|
27
|
+
id: "a",
|
|
28
|
+
date: new Date(now + 3_600_000).toISOString(),
|
|
29
|
+
time: "23:00",
|
|
30
|
+
country: "US",
|
|
31
|
+
event: "CPI m/m",
|
|
32
|
+
impact: "high",
|
|
33
|
+
actual: null,
|
|
34
|
+
forecast: "0.3%",
|
|
35
|
+
prior: "0.2%",
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
id: "b",
|
|
39
|
+
date: new Date(now - 90_000_000).toISOString(),
|
|
40
|
+
time: "14:00",
|
|
41
|
+
country: "FR",
|
|
42
|
+
event: "Retail Sales",
|
|
43
|
+
impact: "low",
|
|
44
|
+
actual: "1.1%",
|
|
45
|
+
forecast: "0.9%",
|
|
46
|
+
prior: "0.8%",
|
|
47
|
+
},
|
|
48
|
+
], { sourceKey: "gloomberb-cloud", schemaVersion: 1 });
|
|
49
|
+
attachEconCalendarPersistence(persistence);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
afterEach(async () => {
|
|
53
|
+
if (setup) {
|
|
54
|
+
await act(async () => setup?.renderer.destroy());
|
|
55
|
+
setup = undefined;
|
|
56
|
+
}
|
|
57
|
+
resetEconCalendarPersistence();
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
async function renderPane(width: number) {
|
|
61
|
+
const state = createInitialState(createDefaultConfig("/tmp/gloomberb-econ-test"));
|
|
62
|
+
setup = await testRender(
|
|
63
|
+
<AppContext value={{ state, dispatch: () => {} }}>
|
|
64
|
+
<PluginRenderProvider runtime={{} as unknown as PluginRuntimeAccess} pluginId="econ">
|
|
65
|
+
<PaneInstanceProvider paneId="econ-calendar">
|
|
66
|
+
<PaneFooterProvider>
|
|
67
|
+
{() => (
|
|
68
|
+
<EconPane paneId="econ-calendar" paneType="econ-calendar" focused width={width} height={24} />
|
|
69
|
+
)}
|
|
70
|
+
</PaneFooterProvider>
|
|
71
|
+
</PaneInstanceProvider>
|
|
72
|
+
</PluginRenderProvider>
|
|
73
|
+
</AppContext>,
|
|
74
|
+
{ width, height: 24 },
|
|
75
|
+
);
|
|
76
|
+
await act(async () => {
|
|
77
|
+
for (let index = 0; index < 6; index += 1) {
|
|
78
|
+
await Promise.resolve();
|
|
79
|
+
await setup!.renderOnce();
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
return setup.captureCharFrame();
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
describe("EconCalendarPane", () => {
|
|
86
|
+
// The column math has to leave room for gaps, padding, and the scrollbar
|
|
87
|
+
// lane; one column short silently clipped the last value of every row.
|
|
88
|
+
test("fits the last column instead of clipping released values", async () => {
|
|
89
|
+
seedCalendar();
|
|
90
|
+
const frame = await renderPane(110);
|
|
91
|
+
|
|
92
|
+
expect(frame).toContain("PRIOR");
|
|
93
|
+
expect(frame).toContain("0.2%");
|
|
94
|
+
expect(frame).toContain("0.8%");
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
test("separates days so a row's date is never ambiguous", async () => {
|
|
98
|
+
seedCalendar();
|
|
99
|
+
const frame = await renderPane(110);
|
|
100
|
+
|
|
101
|
+
expect(frame).toContain("TODAY");
|
|
102
|
+
expect(frame).toContain("YESTERDAY");
|
|
103
|
+
expect(frame).toContain("NOW");
|
|
104
|
+
});
|
|
105
|
+
});
|
|
@@ -1,7 +1,14 @@
|
|
|
1
|
-
import { Box } from "../../../ui";
|
|
1
|
+
import { Box, Text } from "../../../ui";
|
|
2
2
|
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
3
3
|
import { TextAttributes, type ScrollBoxRenderable } from "../../../ui";
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
DataTableStackView,
|
|
6
|
+
SegmentedControl,
|
|
7
|
+
type DataTableCell,
|
|
8
|
+
type PaneFooterSegment,
|
|
9
|
+
} from "../../../components";
|
|
10
|
+
import { usePluginPaneState } from "../../runtime";
|
|
11
|
+
import { useAutoRefresh } from "../shared/auto-refresh";
|
|
5
12
|
import type { PaneProps } from "../../../types/plugin";
|
|
6
13
|
import type { PluginModule } from "../plugin-module";
|
|
7
14
|
import { colors, blendHex } from "../../../theme/colors";
|
|
@@ -12,13 +19,11 @@ import {
|
|
|
12
19
|
FILTER_CYCLE,
|
|
13
20
|
attachEconCalendarPersistence,
|
|
14
21
|
actualColor,
|
|
15
|
-
countryFlag,
|
|
16
22
|
dateKey,
|
|
17
23
|
dayLabel,
|
|
18
24
|
formatCountdown,
|
|
19
25
|
formatStaleness,
|
|
20
26
|
getCalendarCache,
|
|
21
|
-
getFreshCalendarCache,
|
|
22
27
|
impactIndicator,
|
|
23
28
|
loadCalendar,
|
|
24
29
|
matchesCountry,
|
|
@@ -29,17 +34,26 @@ import {
|
|
|
29
34
|
type EconCalendarColumn,
|
|
30
35
|
type ImpactFilter,
|
|
31
36
|
} from "./calendar-model";
|
|
32
|
-
import { attachFredSeriesPersistence } from "../../../data/fred-series";
|
|
33
37
|
import { usePaneStatusFooter } from "../shared/pane-footer";
|
|
34
38
|
|
|
39
|
+
const IMPACT_LABELS: Record<ImpactFilter, string> = {
|
|
40
|
+
all: "All",
|
|
41
|
+
high: "High",
|
|
42
|
+
medium: "Med",
|
|
43
|
+
low: "Low",
|
|
44
|
+
};
|
|
45
|
+
|
|
35
46
|
function EconCalendarPane({ focused, width, height }: PaneProps) {
|
|
36
47
|
const [initialCache] = useState(() => getCalendarCache());
|
|
37
48
|
const [events, setEvents] = useState<EconEvent[]>(initialCache?.data ?? []);
|
|
38
|
-
const [loading, setLoading] = useState(
|
|
49
|
+
const [loading, setLoading] = useState(true);
|
|
50
|
+
const [settled, setSettled] = useState(false);
|
|
39
51
|
const [error, setError] = useState<string | null>(null);
|
|
52
|
+
const [stale, setStale] = useState(initialCache?.stale ?? false);
|
|
53
|
+
const [fetchedAt, setFetchedAt] = useState<number | null>(initialCache?.fetchedAt ?? null);
|
|
40
54
|
const [selectedIdx, setSelectedIdx] = useState(0);
|
|
41
|
-
const [impactFilter, setImpactFilter] =
|
|
42
|
-
const [countryFilter, setCountryFilter] =
|
|
55
|
+
const [impactFilter, setImpactFilter] = usePluginPaneState<ImpactFilter>("impactFilter", "all");
|
|
56
|
+
const [countryFilter, setCountryFilter] = usePluginPaneState<CountryFilter>("countryFilter", "all");
|
|
43
57
|
const [now, setNow] = useState(Date.now());
|
|
44
58
|
const [detailEvent, setDetailEvent] = useState<EconEvent | null>(null);
|
|
45
59
|
|
|
@@ -54,26 +68,29 @@ function EconCalendarPane({ focused, width, height }: PaneProps) {
|
|
|
54
68
|
setError(null);
|
|
55
69
|
|
|
56
70
|
try {
|
|
57
|
-
const
|
|
71
|
+
const result = await loadCalendar(force);
|
|
58
72
|
if (fetchGenRef.current !== gen) return;
|
|
59
|
-
setEvents(data);
|
|
73
|
+
setEvents(result.data);
|
|
74
|
+
setFetchedAt(result.fetchedAt);
|
|
75
|
+
setStale(result.stale);
|
|
76
|
+
setError(result.refreshError ?? null);
|
|
60
77
|
if (force) setSelectedIdx(0);
|
|
61
78
|
} catch (err) {
|
|
62
79
|
if (fetchGenRef.current !== gen) return;
|
|
63
80
|
setError(err instanceof Error ? err.message : String(err));
|
|
64
81
|
} finally {
|
|
65
|
-
if (fetchGenRef.current === gen)
|
|
82
|
+
if (fetchGenRef.current === gen) {
|
|
83
|
+
setLoading(false);
|
|
84
|
+
setSettled(true);
|
|
85
|
+
}
|
|
66
86
|
}
|
|
67
87
|
}, []);
|
|
68
88
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}
|
|
75
|
-
load();
|
|
76
|
-
}, [load]);
|
|
89
|
+
// loadCalendar serves a fresh cache without a request, so the pane can always
|
|
90
|
+
// ask and still follow the global cadence once the cache goes stale.
|
|
91
|
+
useEffect(() => { void load(); }, [load]);
|
|
92
|
+
const refresh = useCallback(() => { void load(false); }, [load]);
|
|
93
|
+
useAutoRefresh(stale ? null : fetchedAt, refresh);
|
|
77
94
|
|
|
78
95
|
// Tick every 30s to update staleness + countdown
|
|
79
96
|
useEffect(() => {
|
|
@@ -151,20 +168,22 @@ function EconCalendarPane({ focused, width, height }: PaneProps) {
|
|
|
151
168
|
// Next upcoming event for countdown
|
|
152
169
|
const nextEvent = nextUpcomingEventIdx >= 0 ? filtered[nextUpcomingEventIdx] : undefined;
|
|
153
170
|
const nextCountdown = nextEvent ? formatCountdown(nextEvent.date.getTime() - now) : null;
|
|
171
|
+
const selectImpactFilter = useCallback((value: ImpactFilter) => {
|
|
172
|
+
setImpactFilter(value);
|
|
173
|
+
setSelectedIdx(0);
|
|
174
|
+
}, [setImpactFilter]);
|
|
175
|
+
const selectCountryFilter = useCallback((value: CountryFilter) => {
|
|
176
|
+
setCountryFilter(value);
|
|
177
|
+
setSelectedIdx(0);
|
|
178
|
+
}, [setCountryFilter]);
|
|
154
179
|
const cycleImpactFilter = useCallback(() => {
|
|
155
|
-
setImpactFilter((prev) =>
|
|
156
|
-
const idx = FILTER_CYCLE.indexOf(prev);
|
|
157
|
-
return FILTER_CYCLE[(idx + 1) % FILTER_CYCLE.length]!;
|
|
158
|
-
});
|
|
180
|
+
setImpactFilter((prev) => FILTER_CYCLE[(FILTER_CYCLE.indexOf(prev) + 1) % FILTER_CYCLE.length]!);
|
|
159
181
|
setSelectedIdx(0);
|
|
160
|
-
}, []);
|
|
182
|
+
}, [setImpactFilter]);
|
|
161
183
|
const cycleCountryFilter = useCallback(() => {
|
|
162
|
-
setCountryFilter((prev) =>
|
|
163
|
-
const idx = COUNTRY_CYCLE.indexOf(prev);
|
|
164
|
-
return COUNTRY_CYCLE[(idx + 1) % COUNTRY_CYCLE.length]!;
|
|
165
|
-
});
|
|
184
|
+
setCountryFilter((prev) => COUNTRY_CYCLE[(COUNTRY_CYCLE.indexOf(prev) + 1) % COUNTRY_CYCLE.length]!);
|
|
166
185
|
setSelectedIdx(0);
|
|
167
|
-
}, []);
|
|
186
|
+
}, [setCountryFilter]);
|
|
168
187
|
|
|
169
188
|
const handleRootKeyDown = useCallback((event: {
|
|
170
189
|
name?: string;
|
|
@@ -193,19 +212,21 @@ function EconCalendarPane({ focused, width, height }: PaneProps) {
|
|
|
193
212
|
const columns = useMemo<EconCalendarColumn[]>(() => {
|
|
194
213
|
const timeWidth = 6;
|
|
195
214
|
const impactWidth = 4;
|
|
196
|
-
const flagWidth =
|
|
215
|
+
const flagWidth = 3;
|
|
197
216
|
const actualWidth = 9;
|
|
198
217
|
const forecastWidth = 10;
|
|
199
218
|
const priorWidth = 9;
|
|
200
219
|
const minEventWidth = 12;
|
|
201
220
|
const fixedWidth = timeWidth + impactWidth + flagWidth + actualWidth + forecastWidth + priorWidth;
|
|
221
|
+
// Padding, one gap per column boundary, and the vertical scrollbar lane;
|
|
222
|
+
// one column short of that clipped the PRIOR values at the right edge.
|
|
202
223
|
const columnCount = 7;
|
|
203
|
-
const eventWidth = Math.max(minEventWidth, width -
|
|
224
|
+
const eventWidth = Math.max(minEventWidth, width - 3 - columnCount - fixedWidth);
|
|
204
225
|
|
|
205
226
|
return [
|
|
206
227
|
{ id: "time", label: "TIME", width: timeWidth, align: "left" },
|
|
207
228
|
{ id: "impact", label: "IMP", width: impactWidth, align: "left" },
|
|
208
|
-
{ id: "country", label: "
|
|
229
|
+
{ id: "country", label: "CTY", width: flagWidth, align: "left" },
|
|
209
230
|
{ id: "event", label: "EVENT", width: eventWidth, align: "left" },
|
|
210
231
|
{ id: "actual", label: "ACTUAL", width: actualWidth, align: "right" },
|
|
211
232
|
{ id: "forecast", label: "FORECAST", width: forecastWidth, align: "right" },
|
|
@@ -213,9 +234,8 @@ function EconCalendarPane({ focused, width, height }: PaneProps) {
|
|
|
213
234
|
];
|
|
214
235
|
}, [width]);
|
|
215
236
|
const separatorBg = blendHex(colors.bg, colors.border, 0.3);
|
|
216
|
-
const
|
|
217
|
-
const
|
|
218
|
-
const emptyStateHint = !loading && !error
|
|
237
|
+
const staleness = fetchedAt ? formatStaleness(fetchedAt, now) : "";
|
|
238
|
+
const emptyStateHint = settled && !loading && !error
|
|
219
239
|
? [
|
|
220
240
|
impactFilter !== "all" ? `impact: ${impactFilter}` : null,
|
|
221
241
|
countryFilter !== "all" ? `country: ${countryFilter}` : null,
|
|
@@ -223,14 +243,9 @@ function EconCalendarPane({ focused, width, height }: PaneProps) {
|
|
|
223
243
|
: undefined;
|
|
224
244
|
|
|
225
245
|
const calendarStatus = useMemo<PaneFooterSegment[]>(() => [
|
|
226
|
-
...(
|
|
227
|
-
...(
|
|
228
|
-
|
|
229
|
-
id: "next",
|
|
230
|
-
parts: [{ text: `Next: ${nextEvent.event.length > 18 ? nextEvent.event.slice(0, 18).trimEnd() : nextEvent.event} ${nextCountdown}`, tone: "muted" as const }],
|
|
231
|
-
}] : []),
|
|
232
|
-
...(staleness ? [{ id: "stale", parts: [{ text: staleness, tone: "muted" as const }] }] : []),
|
|
233
|
-
], [countryFilter, impactFilter, nextCountdown, nextEvent?.event, staleness]);
|
|
246
|
+
...(stale ? [{ id: "stale", parts: [{ text: "STALE", tone: "warning" as const }] }] : []),
|
|
247
|
+
...(staleness ? [{ id: "updated", parts: [{ text: staleness, tone: "muted" as const }] }] : []),
|
|
248
|
+
], [stale, staleness]);
|
|
234
249
|
usePaneStatusFooter({
|
|
235
250
|
registrationId: "econ-calendar",
|
|
236
251
|
loading,
|
|
@@ -253,16 +268,17 @@ function EconCalendarPane({ focused, width, height }: PaneProps) {
|
|
|
253
268
|
};
|
|
254
269
|
}
|
|
255
270
|
if (row.kind === "now") {
|
|
256
|
-
|
|
257
|
-
|
|
271
|
+
// A filled band instead of repeated rule characters, so the desktop
|
|
272
|
+
// webview paints a real background rather than terminal glyphs.
|
|
258
273
|
return {
|
|
259
|
-
text:
|
|
274
|
+
text: " NOW ",
|
|
260
275
|
color: colors.warning,
|
|
261
|
-
|
|
276
|
+
backgroundColor: blendHex(colors.bg, colors.warning, 0.22),
|
|
277
|
+
attributes: TextAttributes.BOLD,
|
|
262
278
|
};
|
|
263
279
|
}
|
|
264
280
|
return null;
|
|
265
|
-
}, [separatorBg
|
|
281
|
+
}, [separatorBg]);
|
|
266
282
|
const renderCell = useCallback((
|
|
267
283
|
row: DisplayRow,
|
|
268
284
|
column: EconCalendarColumn,
|
|
@@ -285,7 +301,9 @@ function EconCalendarPane({ focused, width, height }: PaneProps) {
|
|
|
285
301
|
};
|
|
286
302
|
}
|
|
287
303
|
case "country":
|
|
288
|
-
|
|
304
|
+
// The ISO code, not a flag emoji: emoji widths do not match a fixed
|
|
305
|
+
// column and pushed the right-hand columns off the pane.
|
|
306
|
+
return { text: ev.country, color: selectedColor ?? colors.textMuted };
|
|
289
307
|
case "event":
|
|
290
308
|
return { text: ev.event, color: selectedColor ?? colors.text };
|
|
291
309
|
case "actual":
|
|
@@ -300,6 +318,31 @@ function EconCalendarPane({ focused, width, height }: PaneProps) {
|
|
|
300
318
|
}
|
|
301
319
|
}, []);
|
|
302
320
|
|
|
321
|
+
const selectedEvent = filtered[selectedIdx];
|
|
322
|
+
const filterControls = (
|
|
323
|
+
<Box height={1} flexDirection="row" paddingX={1} gap={2} overflow="hidden">
|
|
324
|
+
<SegmentedControl
|
|
325
|
+
options={FILTER_CYCLE.map((value) => ({ value, label: IMPACT_LABELS[value] }))}
|
|
326
|
+
value={impactFilter}
|
|
327
|
+
onChange={(value) => selectImpactFilter(value as ImpactFilter)}
|
|
328
|
+
/>
|
|
329
|
+
<SegmentedControl
|
|
330
|
+
options={COUNTRY_CYCLE.map((value) => ({ value, label: value === "all" ? "All" : value }))}
|
|
331
|
+
value={countryFilter}
|
|
332
|
+
onChange={(value) => selectCountryFilter(value as CountryFilter)}
|
|
333
|
+
/>
|
|
334
|
+
<Box flexGrow={1} />
|
|
335
|
+
{nextEvent && nextCountdown && width >= 88 && (
|
|
336
|
+
<Text fg={colors.textMuted}>
|
|
337
|
+
{`next ${nextEvent.event.slice(0, 16).trimEnd()} ${nextCountdown}`}
|
|
338
|
+
</Text>
|
|
339
|
+
)}
|
|
340
|
+
{selectedEvent && (
|
|
341
|
+
<Text fg={colors.textDim}>{dayLabel(selectedEvent.date, today)}</Text>
|
|
342
|
+
)}
|
|
343
|
+
</Box>
|
|
344
|
+
);
|
|
345
|
+
|
|
303
346
|
const detailContent = detailEvent ? (
|
|
304
347
|
<EconDetailView
|
|
305
348
|
event={detailEvent}
|
|
@@ -318,7 +361,8 @@ function EconCalendarPane({ focused, width, height }: PaneProps) {
|
|
|
318
361
|
onBack={() => setDetailEvent(null)}
|
|
319
362
|
detailContent={detailContent}
|
|
320
363
|
rootWidth={width}
|
|
321
|
-
rootHeight={height}
|
|
364
|
+
rootHeight={Math.max(1, height - 1)}
|
|
365
|
+
rootBefore={filterControls}
|
|
322
366
|
onRootKeyDown={handleRootKeyDown}
|
|
323
367
|
selection={{
|
|
324
368
|
kind: "index",
|
|
@@ -339,7 +383,7 @@ function EconCalendarPane({ focused, width, height }: PaneProps) {
|
|
|
339
383
|
onActivate={openDisplayRow}
|
|
340
384
|
renderSectionHeader={renderSectionHeader}
|
|
341
385
|
renderCell={renderCell}
|
|
342
|
-
emptyStateTitle={loading ? "Loading economic events..." : "No events"}
|
|
386
|
+
emptyStateTitle={loading || !settled ? "Loading economic events..." : "No events"}
|
|
343
387
|
emptyStateHint={emptyStateHint}
|
|
344
388
|
showHorizontalScrollbar={false}
|
|
345
389
|
/>
|
|
@@ -366,7 +410,6 @@ export const economicCalendarModule: PluginModule = {
|
|
|
366
410
|
}],
|
|
367
411
|
setup(ctx) {
|
|
368
412
|
attachEconCalendarPersistence(ctx.persistence);
|
|
369
|
-
attachFredSeriesPersistence(ctx.persistence);
|
|
370
413
|
},
|
|
371
414
|
dispose() {
|
|
372
415
|
resetEconCalendarPersistence();
|
|
@@ -68,8 +68,23 @@ describe("fear-greed cache", () => {
|
|
|
68
68
|
});
|
|
69
69
|
|
|
70
70
|
expect(calls).toBe(0);
|
|
71
|
-
expect(cached.
|
|
72
|
-
expect(cached.overall.
|
|
73
|
-
expect(cached.overall.
|
|
71
|
+
expect(cached.stale).toBe(false);
|
|
72
|
+
expect(cached.data.overall.score).toBe(64);
|
|
73
|
+
expect(cached.data.overall.updatedAt).toBeInstanceOf(Date);
|
|
74
|
+
expect(cached.data.overall.history[0]!.date).toBeInstanceOf(Date);
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
test("reports a failed refresh as stale instead of a fresh load", async () => {
|
|
78
|
+
const persistence = new MemoryPluginPersistence();
|
|
79
|
+
attachFearGreedPersistence(persistence);
|
|
80
|
+
await loadFearGreed(false, async () => makeFearGreedData(64));
|
|
81
|
+
|
|
82
|
+
const result = await loadFearGreed(true, async () => {
|
|
83
|
+
throw new Error("CNN unreachable");
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
expect(result.data.overall.score).toBe(64);
|
|
87
|
+
expect(result.stale).toBe(true);
|
|
88
|
+
expect(result.refreshError).toContain("CNN unreachable");
|
|
74
89
|
});
|
|
75
90
|
});
|
|
@@ -32,8 +32,13 @@ export type FearGreedCacheEntry = {
|
|
|
32
32
|
stale: boolean;
|
|
33
33
|
};
|
|
34
34
|
|
|
35
|
+
export interface FearGreedLoadResult extends FearGreedCacheEntry {
|
|
36
|
+
/** Set when the network failed and cached data was served instead. */
|
|
37
|
+
refreshError?: string;
|
|
38
|
+
}
|
|
39
|
+
|
|
35
40
|
let fearGreedPersistence: PluginPersistence | null = null;
|
|
36
|
-
let activeFetch: Promise<
|
|
41
|
+
let activeFetch: Promise<FearGreedLoadResult> | null = null;
|
|
37
42
|
|
|
38
43
|
export function attachFearGreedPersistence(persistence: PluginPersistence): void {
|
|
39
44
|
fearGreedPersistence = persistence;
|
|
@@ -118,10 +123,10 @@ export function getCachedFearGreedData(options?: { allowExpired?: boolean }): Fe
|
|
|
118
123
|
export async function loadFearGreed(
|
|
119
124
|
force = false,
|
|
120
125
|
loader: () => Promise<FearGreedData> = fetchFearGreedData,
|
|
121
|
-
): Promise<
|
|
126
|
+
): Promise<FearGreedLoadResult> {
|
|
122
127
|
const cached = getCachedFearGreedData();
|
|
123
128
|
if (!force && cached && !cached.stale) {
|
|
124
|
-
return cached
|
|
129
|
+
return cached;
|
|
125
130
|
}
|
|
126
131
|
if (activeFetch) return activeFetch;
|
|
127
132
|
|
|
@@ -129,10 +134,17 @@ export async function loadFearGreed(
|
|
|
129
134
|
activeFetch = loader()
|
|
130
135
|
.then((data) => {
|
|
131
136
|
writeCache(data);
|
|
132
|
-
return data;
|
|
137
|
+
return { data, fetchedAt: Date.now(), stale: false };
|
|
133
138
|
})
|
|
134
|
-
.catch((error) => {
|
|
135
|
-
|
|
139
|
+
.catch((error: unknown) => {
|
|
140
|
+
// A failed refresh must not be reported as a fresh load.
|
|
141
|
+
if (fallback) {
|
|
142
|
+
return {
|
|
143
|
+
...fallback,
|
|
144
|
+
stale: true,
|
|
145
|
+
refreshError: error instanceof Error ? error.message : String(error),
|
|
146
|
+
};
|
|
147
|
+
}
|
|
136
148
|
throw error;
|
|
137
149
|
})
|
|
138
150
|
.finally(() => {
|
|
@@ -237,12 +237,19 @@ function ChartStats({
|
|
|
237
237
|
secondaryValue?: number | null;
|
|
238
238
|
valueFormat: FearGreedValueFormat;
|
|
239
239
|
}) {
|
|
240
|
+
// The index history charts the score itself, so its "latest" repeats the score.
|
|
241
|
+
const latestText = formatIndicatorValue(latest, valueFormat);
|
|
242
|
+
const showLatest = latestText !== formatScore(score);
|
|
240
243
|
return (
|
|
241
244
|
<>
|
|
242
245
|
<Text fg={colors.textDim}>score </Text>
|
|
243
246
|
<Text fg={color} attributes={TextAttributes.BOLD}>{formatScore(score)}</Text>
|
|
244
|
-
|
|
245
|
-
|
|
247
|
+
{showLatest ? (
|
|
248
|
+
<>
|
|
249
|
+
<Text fg={colors.textDim}> latest </Text>
|
|
250
|
+
<Text fg={colors.text}>{latestText}</Text>
|
|
251
|
+
</>
|
|
252
|
+
) : null}
|
|
246
253
|
{secondaryLabel && secondaryValue != null ? (
|
|
247
254
|
<>
|
|
248
255
|
<Text fg={colors.textDim}> avg </Text>
|
|
@@ -85,12 +85,3 @@ export function formatUpdatedAt(date: Date | null): string {
|
|
|
85
85
|
const part = (type: Intl.DateTimeFormatPartTypes) => parts.find((entry) => entry.type === type)?.value ?? "";
|
|
86
86
|
return `Last updated ${part("month")} ${part("day")} at ${part("hour")}:${part("minute")} ${part("dayPeriod")} ET`;
|
|
87
87
|
}
|
|
88
|
-
|
|
89
|
-
export function formatAge(ms: number): string {
|
|
90
|
-
const secs = Math.max(0, Math.floor(ms / 1000));
|
|
91
|
-
if (secs < 60) return `${secs}s ago`;
|
|
92
|
-
const mins = Math.floor(secs / 60);
|
|
93
|
-
if (mins < 60) return `${mins}m ago`;
|
|
94
|
-
const hours = Math.floor(mins / 60);
|
|
95
|
-
return `${hours}h ago`;
|
|
96
|
-
}
|