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
|
@@ -6,9 +6,11 @@ import type { TimeRange } from "../../time-series/range";
|
|
|
6
6
|
import {
|
|
7
7
|
isIntradayResolution,
|
|
8
8
|
normalizeChartResolutionSupport,
|
|
9
|
+
TIME_RANGE_ORDER,
|
|
9
10
|
type ChartResolutionSupport,
|
|
10
11
|
type ManualChartResolution,
|
|
11
12
|
} from "../../time-series/resolution";
|
|
13
|
+
import { clipPriceHistoryToRange } from "../../time-series/history-window";
|
|
12
14
|
import { repairIsolatedIntradayOhlcOutliers } from "../../time-series/history-quality";
|
|
13
15
|
import { canonicalExchange } from "../../utils/exchanges";
|
|
14
16
|
import { resolvePriceHistoryCurrencyUnit } from "../../utils/currency-units";
|
|
@@ -24,7 +26,7 @@ import {
|
|
|
24
26
|
type ProviderRouterCachePolicyKey,
|
|
25
27
|
} from "./cache";
|
|
26
28
|
import type { ProviderRouterCoreDeps, SourceResult } from "./route-types";
|
|
27
|
-
import { makeRouterRequestIdentity, type RouterRequestIdentity } from "./routing";
|
|
29
|
+
import { makeRouterRequestIdentity, scheduleRouterRevalidation, type RouterRequestIdentity } from "./routing";
|
|
28
30
|
|
|
29
31
|
type PriceHistoryCachePolicyKey = Extract<
|
|
30
32
|
ProviderRouterCachePolicyKey,
|
|
@@ -35,6 +37,8 @@ const PRICE_HISTORY_CACHE_VERSION = 4;
|
|
|
35
37
|
interface HistoryRequestDescriptor {
|
|
36
38
|
identity: RouterRequestIdentity;
|
|
37
39
|
cacheVariantKeys: string[];
|
|
40
|
+
exactCacheVariantKeys: string[];
|
|
41
|
+
requestedRange?: TimeRange;
|
|
38
42
|
context?: MarketDataRequestContext;
|
|
39
43
|
cachePolicyKey: PriceHistoryCachePolicyKey;
|
|
40
44
|
missingProviderError?: string;
|
|
@@ -68,22 +72,55 @@ function makeHistoryRequestIdentity(
|
|
|
68
72
|
variantParts: Array<[string, string | number | undefined | null]>;
|
|
69
73
|
fallbackVariantParts: Array<[string, string | number | undefined | null]>;
|
|
70
74
|
},
|
|
71
|
-
): Pick<HistoryRequestDescriptor, "identity" | "cacheVariantKeys"> {
|
|
75
|
+
): Pick<HistoryRequestDescriptor, "identity" | "cacheVariantKeys" | "exactCacheVariantKeys"> {
|
|
72
76
|
const identity = makeRouterRequestIdentity(deps, {
|
|
73
77
|
kind: input.kind,
|
|
74
78
|
ticker: input.ticker,
|
|
75
79
|
context: input.context,
|
|
76
80
|
variantParts: priceHistoryVariantParts(input.variantParts, input.exchange),
|
|
77
81
|
});
|
|
82
|
+
const cacheVariantKeys = [
|
|
83
|
+
identity.variantKey,
|
|
84
|
+
buildVariantKey(priceHistoryVariantParts(input.fallbackVariantParts, input.exchange)),
|
|
85
|
+
];
|
|
78
86
|
return {
|
|
79
87
|
identity,
|
|
80
|
-
cacheVariantKeys
|
|
81
|
-
|
|
82
|
-
buildVariantKey(priceHistoryVariantParts(input.fallbackVariantParts, input.exchange)),
|
|
83
|
-
],
|
|
88
|
+
cacheVariantKeys,
|
|
89
|
+
exactCacheVariantKeys: cacheVariantKeys,
|
|
84
90
|
};
|
|
85
91
|
}
|
|
86
92
|
|
|
93
|
+
function expandedHistoryCacheVariantKeys(
|
|
94
|
+
deps: Pick<ProviderRouterCoreDeps, "getEntityKey">,
|
|
95
|
+
input: {
|
|
96
|
+
ticker: string;
|
|
97
|
+
exchange: string;
|
|
98
|
+
context?: MarketDataRequestContext;
|
|
99
|
+
range: TimeRange;
|
|
100
|
+
resolution?: ManualChartResolution;
|
|
101
|
+
},
|
|
102
|
+
): string[] {
|
|
103
|
+
const start = TIME_RANGE_ORDER.indexOf(input.range);
|
|
104
|
+
const ranges = start >= 0 ? TIME_RANGE_ORDER.slice(start) : [input.range];
|
|
105
|
+
const keys: string[] = [];
|
|
106
|
+
for (const range of ranges) {
|
|
107
|
+
const { cacheVariantKeys } = makeHistoryRequestIdentity(deps, {
|
|
108
|
+
kind: "price-history",
|
|
109
|
+
ticker: input.ticker,
|
|
110
|
+
exchange: input.exchange,
|
|
111
|
+
context: input.context,
|
|
112
|
+
variantParts: input.resolution
|
|
113
|
+
? [["exchange", canonicalExchange(input.exchange)], ["range", range], ["resolution", input.resolution]]
|
|
114
|
+
: [["exchange", canonicalExchange(input.exchange)], ["range", range]],
|
|
115
|
+
fallbackVariantParts: input.resolution
|
|
116
|
+
? [["range", range], ["resolution", input.resolution]]
|
|
117
|
+
: [["range", range]],
|
|
118
|
+
});
|
|
119
|
+
keys.push(...cacheVariantKeys);
|
|
120
|
+
}
|
|
121
|
+
return [...new Set(keys)];
|
|
122
|
+
}
|
|
123
|
+
|
|
87
124
|
function normalizeRequestHistory(
|
|
88
125
|
points: PricePoint[],
|
|
89
126
|
request: Pick<HistoryRequestDescriptor, "cachePolicyKey">,
|
|
@@ -96,6 +133,7 @@ function normalizeRequestHistory(
|
|
|
96
133
|
|
|
97
134
|
export class ProviderRouterHistoryRoutes {
|
|
98
135
|
constructor(private readonly deps: ProviderRouterCoreDeps) {}
|
|
136
|
+
private readonly historyRefreshInFlight = new Map<string, Promise<unknown>>();
|
|
99
137
|
|
|
100
138
|
async getPriceHistory(
|
|
101
139
|
ticker: string,
|
|
@@ -114,6 +152,8 @@ export class ProviderRouterHistoryRoutes {
|
|
|
114
152
|
const intraday = isIntradayRange(range);
|
|
115
153
|
return this.executeHistoryRequest({
|
|
116
154
|
...identity,
|
|
155
|
+
cacheVariantKeys: expandedHistoryCacheVariantKeys(this.deps, { ticker, exchange, context, range }),
|
|
156
|
+
requestedRange: range,
|
|
117
157
|
context,
|
|
118
158
|
cachePolicyKey: intraday ? "priceHistoryIntraday" : "priceHistoryDaily",
|
|
119
159
|
missingProviderError: `No history provider available for ${ticker}`,
|
|
@@ -154,6 +194,14 @@ export class ProviderRouterHistoryRoutes {
|
|
|
154
194
|
const intraday = isIntradayResolution(resolution);
|
|
155
195
|
return this.executeHistoryRequest({
|
|
156
196
|
...identity,
|
|
197
|
+
cacheVariantKeys: expandedHistoryCacheVariantKeys(this.deps, {
|
|
198
|
+
ticker,
|
|
199
|
+
exchange,
|
|
200
|
+
context,
|
|
201
|
+
range: bufferRange,
|
|
202
|
+
resolution,
|
|
203
|
+
}),
|
|
204
|
+
requestedRange: bufferRange,
|
|
157
205
|
context,
|
|
158
206
|
cachePolicyKey: intraday ? "priceHistoryIntraday" : "priceHistoryDaily",
|
|
159
207
|
missingProviderError: `No resolution-aware history provider available for ${ticker}`,
|
|
@@ -296,8 +344,15 @@ export class ProviderRouterHistoryRoutes {
|
|
|
296
344
|
const cachedValue = cached ? normalizeRequestHistory(cached.value, request) : [];
|
|
297
345
|
const cachedHistoryStale = request.isCachedValueStale(cachedValue);
|
|
298
346
|
const forceRefresh = request.context?.cacheMode === "refresh";
|
|
299
|
-
|
|
300
|
-
|
|
347
|
+
const usableCached = cachedValue.length > 0 && cached && !cached.expired && !cachedHistoryStale;
|
|
348
|
+
if (usableCached && !forceRefresh) {
|
|
349
|
+
const exactHit = request.exactCacheVariantKeys.includes(cached.variantKey);
|
|
350
|
+
if (cached.stale && exactHit) {
|
|
351
|
+
scheduleRouterRevalidation(this.historyRefreshInFlight, request.identity.revalidationKey, () => this.refreshHistory(request));
|
|
352
|
+
}
|
|
353
|
+
return exactHit || !request.requestedRange
|
|
354
|
+
? cachedValue
|
|
355
|
+
: clipPriceHistoryToRange(cachedValue, request.requestedRange);
|
|
301
356
|
}
|
|
302
357
|
|
|
303
358
|
const brokerResult = await withBrokerTimeout(this.fetchBrokerHistory(request, brokerCandidates));
|
|
@@ -305,13 +360,28 @@ export class ProviderRouterHistoryRoutes {
|
|
|
305
360
|
|
|
306
361
|
const providerResult = await this.fetchProviderHistory(request);
|
|
307
362
|
if (providerResult && providerResult.value.length > 0) return providerResult.value;
|
|
308
|
-
if (cachedValue.length > 0 && !cachedHistoryStale)
|
|
363
|
+
if (cachedValue.length > 0 && !cachedHistoryStale) {
|
|
364
|
+
return request.requestedRange
|
|
365
|
+
? clipPriceHistoryToRange(cachedValue, request.requestedRange)
|
|
366
|
+
: cachedValue;
|
|
367
|
+
}
|
|
309
368
|
if (!providerResult && request.missingProviderError) {
|
|
310
369
|
throw new Error(request.missingProviderError);
|
|
311
370
|
}
|
|
312
371
|
return providerResult?.value ?? [];
|
|
313
372
|
}
|
|
314
373
|
|
|
374
|
+
private async refreshHistory(request: HistoryRequestDescriptor): Promise<void> {
|
|
375
|
+
const brokerCandidates = this.deps.getBrokerCandidatesForContext(request.context, false);
|
|
376
|
+
try {
|
|
377
|
+
const brokerResult = await withBrokerTimeout(this.fetchBrokerHistory(request, brokerCandidates));
|
|
378
|
+
if (brokerResult && brokerResult.value.length > 0) return;
|
|
379
|
+
await this.fetchProviderHistory(request);
|
|
380
|
+
} catch {
|
|
381
|
+
// Background refresh is best-effort; callers already have cached points.
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
|
|
315
385
|
private fetchBrokerHistory(
|
|
316
386
|
request: HistoryRequestDescriptor,
|
|
317
387
|
candidates: BrokerCandidate[],
|
|
@@ -371,20 +441,55 @@ export class ProviderRouterHistoryRoutes {
|
|
|
371
441
|
private async firstProviderArrayResult<T>(
|
|
372
442
|
fetch: (provider: DataProvider) => Promise<T[] | null>,
|
|
373
443
|
): Promise<SourceResult<T[]> | null> {
|
|
444
|
+
const providers = this.deps.providersInPriorityOrder();
|
|
374
445
|
let firstEmptyResult: SourceResult<T[]> | null = null;
|
|
375
|
-
|
|
446
|
+
const tryProvider = async (provider: DataProvider): Promise<SourceResult<T[]> | null> => {
|
|
376
447
|
try {
|
|
377
448
|
const value = await fetch(provider);
|
|
378
|
-
if (value === null)
|
|
449
|
+
if (value === null) return null;
|
|
379
450
|
const result = { sourceKey: this.deps.providerSourceKey(provider), value };
|
|
380
|
-
if (value.length
|
|
381
|
-
|
|
451
|
+
if (value.length === 0) firstEmptyResult ??= result;
|
|
452
|
+
return result;
|
|
382
453
|
} catch (error) {
|
|
383
454
|
if (shouldLogProviderError(error)) {
|
|
384
455
|
this.deps.logProviderError(`${provider.id} failed: ${error}`);
|
|
385
456
|
}
|
|
457
|
+
return null;
|
|
386
458
|
}
|
|
459
|
+
};
|
|
460
|
+
|
|
461
|
+
if (providers.length <= 1) {
|
|
462
|
+
for (const provider of providers) {
|
|
463
|
+
const result = await tryProvider(provider);
|
|
464
|
+
if (result && result.value.length > 0) return result;
|
|
465
|
+
}
|
|
466
|
+
return firstEmptyResult;
|
|
387
467
|
}
|
|
388
|
-
|
|
468
|
+
|
|
469
|
+
const preferred = tryProvider(providers[0]!);
|
|
470
|
+
const speculativeDelay = new Promise<"timeout">((resolve) => {
|
|
471
|
+
setTimeout(() => resolve("timeout"), 200);
|
|
472
|
+
});
|
|
473
|
+
const first = await Promise.race([preferred, speculativeDelay]);
|
|
474
|
+
if (first !== "timeout" && first && first.value.length > 0) return first;
|
|
475
|
+
|
|
476
|
+
const remaining = providers.slice(1).map((provider) => tryProvider(provider));
|
|
477
|
+
return await new Promise((resolve) => {
|
|
478
|
+
let settled = false;
|
|
479
|
+
const finish = (result: SourceResult<T[]> | null) => {
|
|
480
|
+
if (settled || !result || result.value.length === 0) return;
|
|
481
|
+
settled = true;
|
|
482
|
+
resolve(result);
|
|
483
|
+
};
|
|
484
|
+
void preferred.then((result) => {
|
|
485
|
+
if (result && result.value.length > 0) finish(result);
|
|
486
|
+
});
|
|
487
|
+
for (const pending of remaining) {
|
|
488
|
+
void pending.then(finish);
|
|
489
|
+
}
|
|
490
|
+
void Promise.all([preferred, ...remaining]).then(() => {
|
|
491
|
+
if (!settled) resolve(firstEmptyResult);
|
|
492
|
+
});
|
|
493
|
+
});
|
|
389
494
|
}
|
|
390
495
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ResourceStore } from "../../data/resource-store";
|
|
2
|
+
import type { ConnectionHealthRegistry } from "../../core/connection-health";
|
|
2
3
|
import type { PluginRegistry } from "../../plugins/registry";
|
|
3
4
|
import type { BrokerAdapter } from "../../types/broker";
|
|
4
5
|
import type { AppConfig } from "../../types/config";
|
|
@@ -39,6 +40,7 @@ import {
|
|
|
39
40
|
import { ProviderRouterSearchRoutes } from "./search";
|
|
40
41
|
import { collectCapabilityRouteSources, normalizeRouteSource } from "./sources";
|
|
41
42
|
import type { ProviderRouterCoreDeps } from "./route-types";
|
|
43
|
+
import { withProviderConnectionHealth } from "./connection-health";
|
|
42
44
|
import {
|
|
43
45
|
contextFromCachedTarget,
|
|
44
46
|
getBrokerCandidates,
|
|
@@ -69,11 +71,13 @@ export class AssetDataRouter implements DataProvider {
|
|
|
69
71
|
private readonly supplementalRoutes: ProviderRouterSupplementalRoutes;
|
|
70
72
|
private readonly financialRoutes: ProviderRouterFinancialRoutes;
|
|
71
73
|
private readonly documentRoutes: ProviderRouterDocumentRoutes;
|
|
74
|
+
private readonly healthyProviders = new WeakMap<DataProvider, DataProvider>();
|
|
72
75
|
|
|
73
76
|
constructor(
|
|
74
77
|
fallbackSource: CapabilityRouteSource | DataProvider | null = null,
|
|
75
78
|
extraSources: Array<CapabilityRouteSource | DataProvider> = [],
|
|
76
79
|
private readonly resources?: ResourceStore,
|
|
80
|
+
private readonly connectionHealth?: ConnectionHealthRegistry,
|
|
77
81
|
) {
|
|
78
82
|
this.fallbackSource = fallbackSource ? normalizeRouteSource(fallbackSource) : null;
|
|
79
83
|
this.extraSources = extraSources.map(normalizeRouteSource);
|
|
@@ -377,7 +381,14 @@ export class AssetDataRouter implements DataProvider {
|
|
|
377
381
|
if (fallbackProvider && !providers.some((provider) => provider.id === fallbackProvider.id)) {
|
|
378
382
|
providers.push(fallbackProvider);
|
|
379
383
|
}
|
|
380
|
-
return providers;
|
|
384
|
+
if (!this.connectionHealth) return providers;
|
|
385
|
+
return providers.map((provider) => {
|
|
386
|
+
const existing = this.healthyProviders.get(provider);
|
|
387
|
+
if (existing) return existing;
|
|
388
|
+
const wrapped = withProviderConnectionHealth(provider, this.connectionHealth!);
|
|
389
|
+
this.healthyProviders.set(provider, wrapped);
|
|
390
|
+
return wrapped;
|
|
391
|
+
});
|
|
381
392
|
}
|
|
382
393
|
|
|
383
394
|
private newsSourcesInPriorityOrder(): CapabilityRouteSource[] {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { TimeRange } from "../../time-series/range";
|
|
2
2
|
import {
|
|
3
|
+
DEFAULT_CHART_RESOLUTION_SUPPORT,
|
|
3
4
|
isIntradayResolution,
|
|
4
|
-
normalizeChartResolutionSupport,
|
|
5
5
|
type ChartResolutionSupport,
|
|
6
6
|
type ManualChartResolution,
|
|
7
7
|
} from "../../time-series/resolution";
|
|
@@ -22,14 +22,7 @@ const RANGE_PARAMS: Record<TimeRange, { range: string; interval: ManualChartReso
|
|
|
22
22
|
"ALL": { range: "max", interval: "1wk" },
|
|
23
23
|
};
|
|
24
24
|
|
|
25
|
-
const YAHOO_RESOLUTION_SUPPORT =
|
|
26
|
-
{ resolution: "5m", maxRange: "1W" },
|
|
27
|
-
{ resolution: "15m", maxRange: "1M" },
|
|
28
|
-
{ resolution: "1h", maxRange: "3M" },
|
|
29
|
-
{ resolution: "1d", maxRange: "5Y" },
|
|
30
|
-
{ resolution: "1wk", maxRange: "ALL" },
|
|
31
|
-
{ resolution: "1mo", maxRange: "ALL" },
|
|
32
|
-
]);
|
|
25
|
+
const YAHOO_RESOLUTION_SUPPORT = DEFAULT_CHART_RESOLUTION_SUPPORT;
|
|
33
26
|
|
|
34
27
|
type YahooChartFetcher = (
|
|
35
28
|
symbol: string,
|
|
@@ -3,7 +3,7 @@ import { httpFetch } from "../../utils/http-transport";
|
|
|
3
3
|
const MAX_RETRIES = 3;
|
|
4
4
|
const RETRY_BASE_MS = 1500;
|
|
5
5
|
const FETCH_TIMEOUT_MS = 20_000;
|
|
6
|
-
const RETRYABLE_ERROR = /
|
|
6
|
+
const RETRYABLE_ERROR = /403|401|Forbidden|Unauthorized|ECONNRESET|ETIMEDOUT|ENOTFOUND|fetch failed|Failed to get crumb|socket hang up|503|502|504/i;
|
|
7
7
|
|
|
8
8
|
const sleep = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
9
9
|
|
|
@@ -17,7 +17,7 @@ const EXCHANGE_SUFFIX_MAP: Record<string, string> = {
|
|
|
17
17
|
BVME: ".MI", BM: ".MC",
|
|
18
18
|
SIX: ".SW", EBS: ".SW", SWX: ".SW",
|
|
19
19
|
SFB: ".ST", Stockholm: ".ST", OMX: ".ST", CPH: ".CO", HEX: ".HE", OSE: ".OL", OMXNO: ".OL", ICEX: ".IC",
|
|
20
|
-
VSE: ".VI", WSE: ".WA", PRA: ".PR", BUX: ".BD", ATHEX: ".AT", BVB: ".RO", BIST: ".IS",
|
|
20
|
+
VSE: ".VI", WSE: ".WA", GPW: ".WA", PRA: ".PR", BUX: ".BD", ATHEX: ".AT", BVB: ".RO", BIST: ".IS",
|
|
21
21
|
TASE: ".TA",
|
|
22
22
|
JSE: ".JO",
|
|
23
23
|
BVMF: ".SA", MEXI: ".MX", BYMA: ".BA", BCS: ".SN",
|
|
@@ -49,6 +49,7 @@ export type QuoteSummaryResponse = {
|
|
|
49
49
|
targetMeanPrice?: { raw?: number } | number | null;
|
|
50
50
|
targetMedianPrice?: { raw?: number } | number | null;
|
|
51
51
|
recommendationMean?: { raw?: number } | number | null;
|
|
52
|
+
payoutRatio?: { raw?: number } | number | null;
|
|
52
53
|
};
|
|
53
54
|
recommendationTrend?: {
|
|
54
55
|
trend?: Array<{
|
|
@@ -141,6 +142,24 @@ export type QuoteSummaryResponse = {
|
|
|
141
142
|
open?: { raw?: number } | number | null;
|
|
142
143
|
dayHigh?: { raw?: number } | number | null;
|
|
143
144
|
dayLow?: { raw?: number } | number | null;
|
|
145
|
+
trailingAnnualDividendRate?: { raw?: number } | number | null;
|
|
146
|
+
trailingAnnualDividendYield?: { raw?: number } | number | null;
|
|
147
|
+
forwardAnnualDividendRate?: { raw?: number } | number | null;
|
|
148
|
+
dividendRate?: { raw?: number } | number | null;
|
|
149
|
+
payoutRatio?: { raw?: number } | number | null;
|
|
150
|
+
exDividendDate?: { raw?: number } | number | null;
|
|
151
|
+
dividendDate?: { raw?: number } | number | null;
|
|
152
|
+
currency?: string;
|
|
153
|
+
};
|
|
154
|
+
defaultKeyStatistics?: {
|
|
155
|
+
payoutRatio?: { raw?: number } | number | null;
|
|
156
|
+
sharesShort?: { raw?: number } | number | null;
|
|
157
|
+
sharesShortPriorMonth?: { raw?: number } | number | null;
|
|
158
|
+
sharesShortPreviousMonthDate?: { raw?: number; fmt?: string } | number | string | null;
|
|
159
|
+
dateShortInterest?: { raw?: number; fmt?: string } | number | string | null;
|
|
160
|
+
shortRatio?: { raw?: number } | number | null;
|
|
161
|
+
shortPercentOfFloat?: { raw?: number } | number | null;
|
|
162
|
+
floatShares?: { raw?: number } | number | null;
|
|
144
163
|
};
|
|
145
164
|
majorHoldersBreakdown?: {
|
|
146
165
|
insidersPercentHeld?: { raw?: number } | number | null;
|
|
@@ -94,6 +94,107 @@ describe("appReducer command bar state", () => {
|
|
|
94
94
|
expect(secondUndone.config.layout).toEqual(createBlankLayout());
|
|
95
95
|
});
|
|
96
96
|
|
|
97
|
+
test("reorders saved layouts without changing the active workspace", () => {
|
|
98
|
+
const config = createDefaultConfig("/tmp/gloomberb-layout-reorder-test");
|
|
99
|
+
const baseLayout = cloneLayout(config.layout);
|
|
100
|
+
config.layouts = [
|
|
101
|
+
{ name: "Home", layout: cloneLayout(baseLayout) },
|
|
102
|
+
{ name: "Research", layout: cloneLayout(baseLayout) },
|
|
103
|
+
{ name: "News", layout: cloneLayout(baseLayout) },
|
|
104
|
+
];
|
|
105
|
+
config.activeLayoutIndex = 1;
|
|
106
|
+
config.layout = cloneLayout(config.layouts[1]!.layout);
|
|
107
|
+
|
|
108
|
+
const historyLayout = (ratio: number) => {
|
|
109
|
+
const layout = cloneLayout(baseLayout);
|
|
110
|
+
if (!layout.dockRoot || layout.dockRoot.kind !== "split") {
|
|
111
|
+
throw new Error("expected split dock root");
|
|
112
|
+
}
|
|
113
|
+
layout.dockRoot.ratio = ratio;
|
|
114
|
+
return layout;
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
const state = {
|
|
118
|
+
...createInitialState(config),
|
|
119
|
+
paneState: {
|
|
120
|
+
"ticker-detail:main": { activeTabId: "financials" },
|
|
121
|
+
},
|
|
122
|
+
focusedPaneId: "ticker-detail:main",
|
|
123
|
+
layoutHistory: {
|
|
124
|
+
0: { past: [historyLayout(0.41)], future: [] },
|
|
125
|
+
1: { past: [historyLayout(0.52)], future: [] },
|
|
126
|
+
2: { past: [historyLayout(0.63)], future: [] },
|
|
127
|
+
},
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
const next = appReducer(state, { type: "REORDER_LAYOUT", fromIndex: 0, toIndex: 2 });
|
|
131
|
+
|
|
132
|
+
expect(next.config.layouts.map((layout) => layout.name)).toEqual(["Research", "News", "Home"]);
|
|
133
|
+
expect(next.config.activeLayoutIndex).toBe(0);
|
|
134
|
+
expect(next.config.layout).toEqual(state.config.layout);
|
|
135
|
+
expect(next.paneState).toEqual(state.paneState);
|
|
136
|
+
expect(next.config.layouts[0]?.paneState?.["ticker-detail:main"]?.activeTabId).toBe("financials");
|
|
137
|
+
expect(next.layoutHistory[0]?.past[0]?.dockRoot).toMatchObject({ kind: "split", ratio: 0.52 });
|
|
138
|
+
expect(next.layoutHistory[1]?.past[0]?.dockRoot).toMatchObject({ kind: "split", ratio: 0.63 });
|
|
139
|
+
expect(next.layoutHistory[2]?.past[0]?.dockRoot).toMatchObject({ kind: "split", ratio: 0.41 });
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
test("keeps saved layout operations coherent after a reorder", () => {
|
|
143
|
+
const config = createDefaultConfig("/tmp/gloomberb-layout-operations-test");
|
|
144
|
+
const baseLayout = cloneLayout(config.layout);
|
|
145
|
+
config.layouts = [
|
|
146
|
+
{ name: "Home", layout: cloneLayout(baseLayout) },
|
|
147
|
+
{ name: "Research", layout: cloneLayout(baseLayout) },
|
|
148
|
+
{ name: "News", layout: cloneLayout(baseLayout) },
|
|
149
|
+
];
|
|
150
|
+
config.activeLayoutIndex = 1;
|
|
151
|
+
config.layout = cloneLayout(config.layouts[1]!.layout);
|
|
152
|
+
|
|
153
|
+
let state = createInitialState(config);
|
|
154
|
+
state = appReducer(state, { type: "REORDER_LAYOUT", fromIndex: 0, toIndex: 2 });
|
|
155
|
+
expect(state.config.layouts.map((layout) => layout.name)).toEqual(["Research", "News", "Home"]);
|
|
156
|
+
expect(state.config.activeLayoutIndex).toBe(0);
|
|
157
|
+
|
|
158
|
+
state = appReducer(state, { type: "RENAME_LAYOUT", index: 0, name: "Overview" });
|
|
159
|
+
expect(state.config.layouts.map((layout) => layout.name)).toEqual(["Overview", "News", "Home"]);
|
|
160
|
+
|
|
161
|
+
state = appReducer(state, { type: "DUPLICATE_LAYOUT", index: 0 });
|
|
162
|
+
expect(state.config.layouts.map((layout) => layout.name)).toEqual([
|
|
163
|
+
"Overview",
|
|
164
|
+
"News",
|
|
165
|
+
"Home",
|
|
166
|
+
"Overview Copy",
|
|
167
|
+
]);
|
|
168
|
+
expect(state.config.activeLayoutIndex).toBe(3);
|
|
169
|
+
|
|
170
|
+
state = appReducer(state, { type: "SWITCH_LAYOUT", index: 1 });
|
|
171
|
+
expect(state.config.activeLayoutIndex).toBe(1);
|
|
172
|
+
expect(state.config.layouts[state.config.activeLayoutIndex]?.name).toBe("News");
|
|
173
|
+
|
|
174
|
+
state = appReducer(state, { type: "NEW_LAYOUT", name: "Scratch" });
|
|
175
|
+
expect(state.config.layouts.at(-1)?.name).toBe("Scratch");
|
|
176
|
+
expect(state.config.activeLayoutIndex).toBe(4);
|
|
177
|
+
expect(state.config.layout).toEqual(createBlankLayout());
|
|
178
|
+
|
|
179
|
+
state = appReducer(state, { type: "DELETE_LAYOUT", index: 4 });
|
|
180
|
+
expect(state.config.layouts.map((layout) => layout.name)).toEqual([
|
|
181
|
+
"Overview",
|
|
182
|
+
"News",
|
|
183
|
+
"Home",
|
|
184
|
+
"Overview Copy",
|
|
185
|
+
]);
|
|
186
|
+
expect(state.config.activeLayoutIndex).toBe(3);
|
|
187
|
+
|
|
188
|
+
state = appReducer(state, { type: "DELETE_LAYOUT", index: 1 });
|
|
189
|
+
expect(state.config.layouts.map((layout) => layout.name)).toEqual([
|
|
190
|
+
"Overview",
|
|
191
|
+
"Home",
|
|
192
|
+
"Overview Copy",
|
|
193
|
+
]);
|
|
194
|
+
expect(state.config.activeLayoutIndex).toBe(2);
|
|
195
|
+
expect(state.config.layouts[state.config.activeLayoutIndex]?.name).toBe("Overview Copy");
|
|
196
|
+
});
|
|
197
|
+
|
|
97
198
|
test("restores an explicit focus target after a layout removes the focused pane", () => {
|
|
98
199
|
const config = createDefaultConfig("/tmp/gloomberb-test-focus-restore");
|
|
99
200
|
const nextLayout = removePane(config.layout, "ticker-detail:main");
|
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
} from "react";
|
|
15
15
|
import type { AppSessionStorePort } from "../../../core/app-service-ports";
|
|
16
16
|
import { ThemeProvider } from "../../../theme/theme-context";
|
|
17
|
+
import { syncFontScale } from "../../../theme/font-scale";
|
|
17
18
|
import {
|
|
18
19
|
findPaneInstance,
|
|
19
20
|
materializeDetachedPanesAsFloating,
|
|
@@ -501,6 +502,15 @@ export function AppProvider({
|
|
|
501
502
|
void desktopBridge.replaceDetachedPaneState(desktopBridge.paneId, state.paneState[desktopBridge.paneId] ?? {});
|
|
502
503
|
}, [desktopBridge, serializePaneState, state.paneState]);
|
|
503
504
|
|
|
505
|
+
useLayoutEffect(() => {
|
|
506
|
+
// The DOM renderer measures everything in grid cells, so resizing the cell
|
|
507
|
+
// is what actually scales panes and windows. A resize notification makes
|
|
508
|
+
// viewport-derived measurements re-read the new grid immediately.
|
|
509
|
+
if (syncFontScale(state.config.fontSize) && typeof window !== "undefined" && typeof window.dispatchEvent === "function") {
|
|
510
|
+
window.dispatchEvent(new Event("resize"));
|
|
511
|
+
}
|
|
512
|
+
}, [state.config.fontSize]);
|
|
513
|
+
|
|
504
514
|
useLayoutEffect(() => {
|
|
505
515
|
stateRef.current = state;
|
|
506
516
|
for (const listener of listenersRef.current) {
|
|
@@ -21,11 +21,6 @@ export function scheduleConfigSave(config: AppConfig): void {
|
|
|
21
21
|
configSaveScheduler.schedule(config);
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
function cancelScheduledConfigSave(): void {
|
|
25
|
-
configSaveScheduler.cancel();
|
|
26
|
-
}
|
|
27
|
-
|
|
28
24
|
export async function saveConfigImmediately(config: AppConfig): Promise<void> {
|
|
29
|
-
|
|
30
|
-
await measurePerfAsync("persist.config.save", () => saveConfig(config));
|
|
25
|
+
await configSaveScheduler.saveImmediately(config);
|
|
31
26
|
}
|
|
@@ -48,6 +48,37 @@ describe("createPersistScheduler", () => {
|
|
|
48
48
|
expect(saved).toEqual([]);
|
|
49
49
|
});
|
|
50
50
|
|
|
51
|
+
test("serializes an immediate save after an in-flight scheduled save", async () => {
|
|
52
|
+
let persisted: string | undefined;
|
|
53
|
+
let releaseStaleSave: (() => void) | undefined;
|
|
54
|
+
let markStaleSaveStarted: (() => void) | undefined;
|
|
55
|
+
const staleSaveStarted = new Promise<void>((resolve) => {
|
|
56
|
+
markStaleSaveStarted = resolve;
|
|
57
|
+
});
|
|
58
|
+
const staleSaveReleased = new Promise<void>((resolve) => {
|
|
59
|
+
releaseStaleSave = resolve;
|
|
60
|
+
});
|
|
61
|
+
const scheduler = createPersistScheduler<string>({
|
|
62
|
+
delayMs: 1000,
|
|
63
|
+
save: async (value) => {
|
|
64
|
+
if (value === "stale") {
|
|
65
|
+
markStaleSaveStarted?.();
|
|
66
|
+
await staleSaveReleased;
|
|
67
|
+
}
|
|
68
|
+
persisted = value;
|
|
69
|
+
},
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
scheduler.schedule("stale");
|
|
73
|
+
const scheduledSave = scheduler.flush();
|
|
74
|
+
await staleSaveStarted;
|
|
75
|
+
const completionSave = scheduler.saveImmediately("complete");
|
|
76
|
+
releaseStaleSave?.();
|
|
77
|
+
await Promise.all([scheduledSave, completionSave]);
|
|
78
|
+
|
|
79
|
+
expect(persisted).toBe("complete");
|
|
80
|
+
});
|
|
81
|
+
|
|
51
82
|
test("save errors are reported without escaping timer", async () => {
|
|
52
83
|
const errors: unknown[] = [];
|
|
53
84
|
const scheduler = createPersistScheduler<string>({
|
|
@@ -12,6 +12,7 @@ export interface PersistScheduler<T> {
|
|
|
12
12
|
schedule(value: T): void;
|
|
13
13
|
flush(): Promise<void>;
|
|
14
14
|
cancel(): void;
|
|
15
|
+
saveImmediately(value: T): Promise<void>;
|
|
15
16
|
}
|
|
16
17
|
|
|
17
18
|
export function createPersistScheduler<T>({
|
|
@@ -30,12 +31,19 @@ export function createPersistScheduler<T>({
|
|
|
30
31
|
timer = null;
|
|
31
32
|
};
|
|
32
33
|
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
34
|
+
const enqueueSave = (value: T, reportError: boolean): Promise<void> => {
|
|
35
|
+
const saveTask = inFlight.then(async () => {
|
|
36
|
+
try {
|
|
37
|
+
await save(value);
|
|
38
|
+
} catch (error) {
|
|
39
|
+
if (reportError) onError?.(error);
|
|
40
|
+
throw error;
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
// Keep the serialization chain usable after a failed immediate save while
|
|
44
|
+
// still returning that failure to its caller.
|
|
45
|
+
inFlight = saveTask.catch(() => {});
|
|
46
|
+
return saveTask;
|
|
39
47
|
};
|
|
40
48
|
|
|
41
49
|
const drain = async () => {
|
|
@@ -44,8 +52,7 @@ export function createPersistScheduler<T>({
|
|
|
44
52
|
const value = pendingValue as T;
|
|
45
53
|
pendingValue = undefined;
|
|
46
54
|
hasPendingValue = false;
|
|
47
|
-
|
|
48
|
-
return inFlight;
|
|
55
|
+
return enqueueSave(value, true).catch(() => {});
|
|
49
56
|
};
|
|
50
57
|
|
|
51
58
|
return {
|
|
@@ -65,5 +72,11 @@ export function createPersistScheduler<T>({
|
|
|
65
72
|
pendingValue = undefined;
|
|
66
73
|
hasPendingValue = false;
|
|
67
74
|
},
|
|
75
|
+
saveImmediately(value: T): Promise<void> {
|
|
76
|
+
clearTimer();
|
|
77
|
+
pendingValue = undefined;
|
|
78
|
+
hasPendingValue = false;
|
|
79
|
+
return enqueueSave(value, false);
|
|
80
|
+
},
|
|
68
81
|
};
|
|
69
82
|
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { expect, test } from "bun:test";
|
|
2
|
+
import { subscribeToCloudVerification } from "./auth-transition";
|
|
3
|
+
|
|
4
|
+
test("starts sync only for an unverified session's verification transition", () => {
|
|
5
|
+
let verified = false;
|
|
6
|
+
const listeners = new Set<() => void>();
|
|
7
|
+
const syncReasons: string[] = [];
|
|
8
|
+
const stop = subscribeToCloudVerification({
|
|
9
|
+
isVerified: () => verified,
|
|
10
|
+
subscribeCurrentUser: (listener) => {
|
|
11
|
+
listeners.add(listener);
|
|
12
|
+
return () => listeners.delete(listener);
|
|
13
|
+
},
|
|
14
|
+
}, () => {
|
|
15
|
+
syncReasons.push("session-verified");
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
const publish = () => {
|
|
19
|
+
for (const listener of listeners) listener();
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
publish();
|
|
23
|
+
verified = true;
|
|
24
|
+
publish();
|
|
25
|
+
publish();
|
|
26
|
+
|
|
27
|
+
expect(syncReasons).toEqual(["session-verified"]);
|
|
28
|
+
|
|
29
|
+
stop();
|
|
30
|
+
verified = false;
|
|
31
|
+
publish();
|
|
32
|
+
verified = true;
|
|
33
|
+
publish();
|
|
34
|
+
|
|
35
|
+
expect(syncReasons).toEqual(["session-verified"]);
|
|
36
|
+
});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export interface CloudSessionLifecycle {
|
|
2
|
+
isVerified(): boolean;
|
|
3
|
+
subscribeCurrentUser(listener: () => void): () => void;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Runs exactly when a signed-in desktop session becomes verified. It deliberately
|
|
8
|
+
* ignores ordinary account and entitlement refreshes so they cannot re-run the
|
|
9
|
+
* initial sync pull and push.
|
|
10
|
+
*/
|
|
11
|
+
export function subscribeToCloudVerification(
|
|
12
|
+
session: CloudSessionLifecycle,
|
|
13
|
+
onVerified: () => void,
|
|
14
|
+
): () => void {
|
|
15
|
+
let wasVerified = session.isVerified();
|
|
16
|
+
return session.subscribeCurrentUser(() => {
|
|
17
|
+
const isVerified = session.isVerified();
|
|
18
|
+
const becameVerified = !wasVerified && isVerified;
|
|
19
|
+
wasVerified = isVerified;
|
|
20
|
+
if (becameVerified) onVerified();
|
|
21
|
+
});
|
|
22
|
+
}
|