@gloom-sh/terminal 0.20.17 → 0.20.19
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/package.json +3 -1
- package/src/account/auth-dialog.tsx +19 -1
- package/src/account/billing.ts +2 -1
- package/src/account/heard-from-question.tsx +235 -0
- package/src/account/heard-from.ts +97 -0
- package/src/api-client/cot.ts +5 -6
- package/src/api-client/data.ts +14 -3
- package/src/api-client/heard-from.ts +72 -0
- package/src/api-client/index.ts +64 -6
- package/src/api-client/mna.ts +18 -0
- package/src/api-client/request.ts +162 -40
- package/src/api-client/supply-chain.ts +9 -0
- package/src/api-client/types/billing.ts +35 -1
- package/src/api-client/types/news.ts +45 -0
- package/src/api-client/types/world-venues.ts +9 -0
- package/src/app/global-shortcuts.ts +5 -3
- package/src/app/pro-welcome/keys.ts +27 -0
- package/src/app/pro-welcome/model.ts +158 -0
- package/src/app/pro-welcome/row.tsx +176 -0
- package/src/app/pro-welcome/use-pro-welcome.ts +156 -0
- package/src/app/runtime/external-profile-changes.ts +135 -0
- package/src/app.tsx +37 -4
- package/src/architecture/core-builtin-allowlist.json +1 -1
- package/src/architecture/floating-promise-allowlist.json +1 -2
- package/src/architecture/shortcut-labels-allowlist.json +1 -0
- package/src/cli/alert-listing.ts +98 -0
- package/src/cli/commands/market.ts +191 -39
- package/src/cli/commands/overview.ts +7 -1
- package/src/cli/commands/plugins.ts +3 -2
- package/src/cli/commands/search.ts +30 -6
- package/src/cli/commands/ticker.ts +13 -6
- package/src/cli/context.ts +24 -5
- package/src/cli/csv-export.ts +2 -1
- package/src/cli/desktop-pane-shot-browser.ts +3 -1
- package/src/cli/desktop-pane-shot-view.ts +0 -1
- package/src/cli/desktop-pane-shot.ts +276 -52
- package/src/cli/errors.ts +3 -9
- package/src/cli/exit-codes.ts +1 -1
- package/src/cli/glossary.ts +65 -11
- package/src/cli/help.ts +1 -1
- package/src/cli/history-demergers.ts +117 -0
- package/src/cli/history-rows.ts +8 -4
- package/src/cli/index.ts +2 -1
- package/src/cli/known-gaps.ts +16 -0
- package/src/cli/known-us-stocks.ts +18 -0
- package/src/cli/listing-arg.ts +192 -38
- package/src/cli/pane-functions/catalog-snapshot-build.ts +83 -0
- package/src/cli/pane-functions/catalog-snapshot.json +877 -0
- package/src/cli/pane-functions/catalog-snapshot.ts +62 -0
- package/src/cli/pane-functions/catalog.ts +50 -16
- package/src/cli/pane-functions/data.ts +16 -4
- package/src/cli/pane-functions/dom.ts +54 -8
- package/src/cli/pane-functions/freshness.ts +39 -4
- package/src/cli/pane-functions/function-help.ts +3 -3
- package/src/cli/pane-functions/headless.ts +9 -1
- package/src/cli/pane-functions/index.ts +175 -50
- package/src/cli/pane-functions/report-notices.ts +10 -0
- package/src/cli/pane-functions/resolver.ts +11 -7
- package/src/cli/pane-functions/screenshot-assessment.ts +38 -10
- package/src/cli/pane-functions/screenshot-data-evidence.ts +7 -15
- package/src/cli/pane-functions/screenshot-payload.ts +36 -1
- package/src/cli/pane-functions/screenshot-render.ts +24 -9
- package/src/cli/pane-functions/screenshot-types.ts +9 -0
- package/src/cli/quote-answer.ts +33 -17
- package/src/cli/registry.ts +22 -2
- package/src/cli/result.ts +22 -4
- package/src/cli/scroll-truncation.ts +7 -2
- package/src/cli/series-search.ts +45 -6
- package/src/cli/shot-temp-dir.ts +4 -9
- package/src/cli/ticker-resolution.ts +1 -1
- package/src/cli/unreachable.ts +21 -0
- package/src/components/chart/composite/drawing-store.ts +11 -7
- package/src/components/chart/composite/format.ts +1 -0
- package/src/components/chart/composite/legend.tsx +48 -20
- package/src/components/chart/composite/panel-surface/panel-cursor.tsx +3 -3
- package/src/components/chart/composite/panel-surface/plot-gestures.ts +9 -2
- package/src/components/chart/composite/panel-surface.tsx +1 -1
- package/src/components/chart/composite/price-axis-labels.tsx +7 -5
- package/src/components/chart/composite/tools.ts +164 -39
- package/src/components/chart-table/header.tsx +11 -2
- package/src/components/chart-table/layout.ts +16 -17
- package/src/components/command-bar/pane-templates/items.ts +17 -1
- package/src/components/command-bar/routes/root/provider-search.ts +10 -1
- package/src/components/command-bar/routes/root/results.ts +34 -2
- package/src/components/command-bar/routes/root/runtime.ts +19 -4
- package/src/components/command-bar/routes/ticker-search/results.ts +5 -0
- package/src/components/command-bar/routes/ticker-search/route.ts +5 -0
- package/src/components/command-bar/selection-runtime.ts +29 -5
- package/src/components/command-bar/surface/index.tsx +4 -1
- package/src/components/command-bar/workflow/alert.ts +32 -13
- package/src/components/data-table/view.tsx +15 -2
- package/src/components/form-modal/content.tsx +9 -4
- package/src/components/index.ts +1 -1
- package/src/components/layout/header.tsx +9 -5
- package/src/components/layout/pane/capture-status.ts +6 -0
- package/src/components/layout/pane/footer/index.tsx +2 -0
- package/src/components/layout/pane/footer/model.ts +123 -17
- package/src/components/layout/pane/header.tsx +16 -2
- package/src/components/layout/pane/status-footer.ts +24 -0
- package/src/components/market-board/index.tsx +4 -2
- package/src/components/onboarding/onboarding-frame.tsx +6 -2
- package/src/components/onboarding/onboarding-keyboard.ts +7 -1
- package/src/components/onboarding/onboarding-wizard.tsx +3 -1
- package/src/components/onboarding/portfolio-step/positions-panel.tsx +24 -15
- package/src/components/onboarding/setup-cards.ts +36 -0
- package/src/components/onboarding/use-onboarding-progress.ts +22 -1
- package/src/components/onboarding/wizard-account.ts +6 -1
- package/src/components/onboarding/wizard-model.ts +32 -6
- package/src/components/onboarding/wizard-positions.ts +1 -1
- package/src/components/price-performance.tsx +26 -8
- package/src/components/reader/article-reader.tsx +12 -5
- package/src/components/sign-in-gate.tsx +3 -1
- package/src/components/toggle-list.tsx +6 -8
- package/src/components/ui/confirm-dialog.tsx +47 -7
- package/src/components/ui/data-table/opentui/index.tsx +7 -0
- package/src/components/ui/data-table/types.ts +8 -0
- package/src/components/ui/display.tsx +17 -2
- package/src/components/ui/index.ts +1 -1
- package/src/components/ui/stat-grid.tsx +4 -0
- package/src/components/ui/status.tsx +13 -1
- package/src/components/ui/table-layout.ts +34 -2
- package/src/components/use-pane-notice-footer.tsx +16 -3
- package/src/data/config/store/index.ts +31 -0
- package/src/data/config/store/node.ts +61 -11
- package/src/data/config/store/normalize.ts +4 -6
- package/src/data/config/store/shared-file.ts +309 -0
- package/src/data/profile-merge.ts +299 -0
- package/src/data/sqlite/checkpointer.ts +11 -1
- package/src/data/sqlite/database.ts +1 -1
- package/src/data/ticker-repository.ts +134 -10
- package/src/data/ticker-store.ts +67 -0
- package/src/data/ticker-writes.ts +5 -0
- package/src/i18n/es.ts +27 -0
- package/src/i18n/ja.ts +27 -0
- package/src/i18n/ko.ts +27 -0
- package/src/i18n/zh-cn.ts +27 -0
- package/src/i18n/zh-tw.ts +27 -0
- package/src/layout-marketplace/gallery-desktop.tsx +2 -2
- package/src/market-data/ah-pair.ts +122 -0
- package/src/market-data/coordinator/entries.ts +6 -4
- package/src/market-data/coordinator/index.ts +14 -3
- package/src/market-data/depositary-pair.ts +6 -2
- package/src/market-data/futures-board.ts +36 -29
- package/src/market-data/futures-contract.ts +37 -1
- package/src/market-data/hooks.tsx +33 -2
- package/src/market-data/market/change-basis.ts +11 -1
- package/src/market-data/market/header-market.ts +11 -0
- package/src/market-data/market/status.ts +40 -4
- package/src/market-data/performance.ts +127 -32
- package/src/market-data/quotes/time.ts +5 -2
- package/src/market-data/split-terms.ts +28 -0
- package/src/news/types.ts +28 -0
- package/src/notifications/app-badge.ts +2 -3
- package/src/notifications/app-notifier.ts +5 -0
- package/src/plugins/builtin/account-management/footer.ts +1 -1
- package/src/plugins/builtin/account-management/keyboard.ts +4 -0
- package/src/plugins/builtin/account-management/model.ts +1 -0
- package/src/plugins/builtin/account-management/pane.tsx +75 -7
- package/src/plugins/builtin/account-management/payment-recovery-row.tsx +12 -5
- package/src/plugins/builtin/account-management/pro-cancel.tsx +197 -0
- package/src/plugins/builtin/account-management/trial-cancel.ts +1 -1
- package/src/plugins/builtin/alerts/cli-move.ts +2 -2
- package/src/plugins/builtin/alerts/cli.ts +101 -48
- package/src/plugins/builtin/alerts/command.ts +39 -9
- package/src/plugins/builtin/alerts/constants.ts +10 -0
- package/src/plugins/builtin/alerts/earnings-listing.ts +20 -0
- package/src/plugins/builtin/alerts/event-rows.ts +9 -3
- package/src/plugins/builtin/alerts/events-pane.tsx +16 -10
- package/src/plugins/builtin/alerts/format.ts +24 -8
- package/src/plugins/builtin/alerts/headless.ts +12 -6
- package/src/plugins/builtin/alerts/index.tsx +97 -16
- package/src/plugins/builtin/alerts/move-checks.ts +7 -0
- package/src/plugins/builtin/alerts/option-contract.ts +197 -0
- package/src/plugins/builtin/alerts/pane.tsx +1 -1
- package/src/plugins/builtin/alerts/price.ts +30 -5
- package/src/plugins/builtin/alerts/pro-rules.ts +62 -0
- package/src/plugins/builtin/alerts/quotes.ts +26 -2
- package/src/plugins/builtin/alerts/research-builder.ts +5 -10
- package/src/plugins/builtin/alerts/scheduled.ts +6 -1
- package/src/plugins/builtin/alerts/types.ts +7 -0
- package/src/plugins/builtin/analytics/account-returns.ts +1 -1
- package/src/plugins/builtin/analytics/manual-value.ts +61 -0
- package/src/plugins/builtin/analytics/pane-model.ts +2 -2
- package/src/plugins/builtin/analytics/risk-book.ts +7 -7
- package/src/plugins/builtin/analytics/risk-client.ts +27 -14
- package/src/plugins/builtin/analytics/risk-headless.ts +13 -8
- package/src/plugins/builtin/analytics/risk-model.ts +92 -4
- package/src/plugins/builtin/analytics/risk-pane.tsx +85 -38
- package/src/plugins/builtin/awards/pane.tsx +1 -1
- package/src/plugins/builtin/broker-trading/orders.tsx +2 -2
- package/src/plugins/builtin/buildout/company/pane.tsx +4 -14
- package/src/plugins/builtin/catalysts/model.ts +2 -1
- package/src/plugins/builtin/central-bank-rates/model.ts +8 -2
- package/src/plugins/builtin/central-bank-rates/pane.tsx +5 -3
- package/src/plugins/builtin/chart-composer/chart-spec.ts +5 -0
- package/src/plugins/builtin/chart-composer/cli-options.ts +9 -5
- package/src/plugins/builtin/chart-composer/data-catalog-pane.tsx +2 -6
- package/src/plugins/builtin/chart-composer/headless-schema.ts +14 -10
- package/src/plugins/builtin/chart-composer/headless.ts +2 -0
- package/src/plugins/builtin/chart-composer/index.tsx +17 -5
- package/src/plugins/builtin/chart-composer/pane.tsx +19 -6
- package/src/plugins/builtin/chart-composer/viewport-labels.ts +2 -17
- package/src/plugins/builtin/chat/controller/notifications.ts +1 -0
- package/src/plugins/builtin/chat/index.tsx +0 -1
- package/src/plugins/builtin/cloud/auth-actions.tsx +11 -6
- package/src/plugins/builtin/cloud/company-picker.tsx +5 -3
- package/src/plugins/builtin/cloud/upgrade-command.ts +1 -1
- package/src/plugins/builtin/commodities-energy/index.tsx +1 -1
- package/src/plugins/builtin/company-kpis/headless.ts +10 -5
- package/src/plugins/builtin/company-kpis/latest.ts +45 -0
- package/src/plugins/builtin/company-kpis/model.ts +57 -15
- package/src/plugins/builtin/company-kpis/pane.tsx +22 -8
- package/src/plugins/builtin/composite/alt-data.ts +20 -0
- package/src/plugins/builtin/composite/application.ts +14 -0
- package/src/plugins/builtin/composite/broker.ts +12 -0
- package/src/plugins/builtin/composite/credit.ts +33 -0
- package/src/plugins/builtin/composite/crypto.ts +10 -0
- package/src/plugins/builtin/composite/earnings.ts +12 -0
- package/src/plugins/builtin/composite/filings.ts +13 -0
- package/src/plugins/builtin/composite/futures-commodities.ts +23 -0
- package/src/plugins/builtin/composite/global-markets.ts +12 -0
- package/src/plugins/builtin/composite/options-volatility.ts +23 -0
- package/src/plugins/builtin/composite/ownership.ts +23 -0
- package/src/plugins/builtin/composite/portfolio.ts +10 -0
- package/src/plugins/builtin/composite/quant.ts +15 -0
- package/src/plugins/builtin/composite/rates-macro.ts +30 -0
- package/src/plugins/builtin/composite/screeners.ts +11 -0
- package/src/plugins/builtin/composite/shared.ts +11 -0
- package/src/plugins/builtin/composite/ticker-core.ts +36 -0
- package/src/plugins/builtin/congress-trades/headless.ts +31 -3
- package/src/plugins/builtin/congress-trades/model.ts +9 -5
- package/src/plugins/builtin/correlation/index.tsx +13 -17
- package/src/plugins/builtin/correlation/matrix/model.ts +18 -0
- package/src/plugins/builtin/cot/client.ts +2 -3
- package/src/plugins/builtin/cot/headless.ts +16 -16
- package/src/plugins/builtin/cot/index.tsx +6 -6
- package/src/plugins/builtin/cot/model.ts +25 -5
- package/src/plugins/builtin/cot/pane.tsx +11 -6
- package/src/plugins/builtin/cot/series.ts +11 -8
- package/src/plugins/builtin/cpi/model.ts +15 -4
- package/src/plugins/builtin/cpi/pane.tsx +29 -7
- package/src/plugins/builtin/dividend-yield/client.ts +57 -16
- package/src/plugins/builtin/dividend-yield/headless.ts +17 -11
- package/src/plugins/builtin/dividend-yield/model.ts +4 -3
- package/src/plugins/builtin/dividend-yield/pane.tsx +22 -18
- package/src/plugins/builtin/dividend-yield/ranking.ts +1 -1
- package/src/plugins/builtin/dividend-yield/types.ts +4 -0
- package/src/plugins/builtin/dividend-yield/view.ts +23 -12
- package/src/plugins/builtin/doe/model.ts +30 -0
- package/src/plugins/builtin/doe/pane.tsx +8 -2
- package/src/plugins/builtin/earnings/board-table.ts +9 -4
- package/src/plugins/builtin/earnings/fiscal-quarter.ts +39 -0
- package/src/plugins/builtin/earnings/headless.ts +16 -6
- package/src/plugins/builtin/earnings/history-model.ts +6 -4
- package/src/plugins/builtin/earnings/history-table.ts +7 -4
- package/src/plugins/builtin/earnings-calls/calendar.tsx +4 -3
- package/src/plugins/builtin/earnings-calls/pane.tsx +8 -2
- package/src/plugins/builtin/earnings-ripple/pane.tsx +2 -2
- package/src/plugins/builtin/econ/calendar-model.ts +16 -0
- package/src/plugins/builtin/econ/index.tsx +7 -2
- package/src/plugins/builtin/equity-screener/headless.ts +4 -1
- package/src/plugins/builtin/equity-screener/model.ts +7 -6
- package/src/plugins/builtin/estimate-revisions/headless.ts +1 -1
- package/src/plugins/builtin/exposure/model.ts +10 -0
- package/src/plugins/builtin/exposure/pane.tsx +10 -3
- package/src/plugins/builtin/futures/model.ts +14 -1
- package/src/plugins/builtin/futures/series.ts +1 -8
- package/src/plugins/builtin/fx-matrix/amount.ts +15 -1
- package/src/plugins/builtin/fx-matrix/headless.ts +12 -6
- package/src/plugins/builtin/fx-matrix/index.tsx +25 -7
- package/src/plugins/builtin/fx-matrix/settings.ts +9 -4
- package/src/plugins/builtin/insider/detail.tsx +36 -7
- package/src/plugins/builtin/insider/filing-stories.ts +110 -0
- package/src/plugins/builtin/insider/headless.ts +37 -2
- package/src/plugins/builtin/insider/index.tsx +79 -10
- package/src/plugins/builtin/insider/model.ts +43 -5
- package/src/plugins/builtin/ipo-calendar/client.ts +11 -1
- package/src/plugins/builtin/ipo-calendar/model.ts +3 -7
- package/src/plugins/builtin/jobs/headless.ts +2 -1
- package/src/plugins/builtin/jobs/model.ts +6 -0
- package/src/plugins/builtin/jobs/pane.tsx +8 -3
- package/src/plugins/builtin/kelly-sizer/pane.tsx +9 -4
- package/src/plugins/builtin/market-valuation/pane.tsx +22 -10
- package/src/plugins/builtin/mna/detail.tsx +67 -6
- package/src/plugins/builtin/mna/headless.ts +128 -13
- package/src/plugins/builtin/mna/model.ts +219 -16
- package/src/plugins/builtin/mna/pane.tsx +34 -6
- package/src/plugins/builtin/money-markets/model.ts +14 -5
- package/src/plugins/builtin/money-markets/pane.tsx +4 -3
- package/src/plugins/builtin/news/wire/news/detail-view.tsx +118 -10
- package/src/plugins/builtin/news/wire/news/footer.ts +3 -8
- package/src/plugins/builtin/news/wire/news/story-evidence.ts +178 -0
- package/src/plugins/builtin/options/analytics.ts +1 -1
- package/src/plugins/builtin/options/view.tsx +18 -11
- package/src/plugins/builtin/options-positioning/model.ts +11 -0
- package/src/plugins/builtin/options-positioning/pane.tsx +22 -1
- package/src/plugins/builtin/options-scenario/client.ts +49 -8
- package/src/plugins/builtin/options-scenario/csp-screen-pane.tsx +22 -6
- package/src/plugins/builtin/options-scenario/csp-screen.ts +39 -12
- package/src/plugins/builtin/options-scenario/headless.ts +7 -3
- package/src/plugins/builtin/options-scenario/model.ts +33 -2
- package/src/plugins/builtin/options-scenario/pane.tsx +3 -4
- package/src/plugins/builtin/options-scenario/strategy-screen.ts +7 -5
- package/src/plugins/builtin/pe-band/client.ts +13 -1
- package/src/plugins/builtin/pe-band/headless.ts +2 -2
- package/src/plugins/builtin/pe-band/model.ts +63 -10
- package/src/plugins/builtin/pe-band/pane.tsx +5 -5
- package/src/plugins/builtin/perps/cascade.ts +4 -3
- package/src/plugins/builtin/perps/markets-section.tsx +5 -2
- package/src/plugins/builtin/perps/model.ts +4 -3
- package/src/plugins/builtin/portfolio-list/allocation-rows.ts +26 -7
- package/src/plugins/builtin/portfolio-list/cli/portfolio-command.ts +66 -13
- package/src/plugins/builtin/portfolio-list/cli/render.ts +76 -33
- package/src/plugins/builtin/portfolio-list/headless.ts +69 -22
- package/src/plugins/builtin/portfolio-list/pane/data.ts +3 -3
- package/src/plugins/builtin/portfolio-list/pane/index.tsx +29 -14
- package/src/plugins/builtin/portfolio-list/summary/index.tsx +2 -2
- package/src/plugins/builtin/portfolio-list/table.tsx +3 -2
- package/src/plugins/builtin/relative-rotation/pane.tsx +2 -3
- package/src/plugins/builtin/research/corporate-actions-pane.tsx +33 -14
- package/src/plugins/builtin/research/event-model.ts +43 -19
- package/src/plugins/builtin/research/headless.ts +8 -1
- package/src/plugins/builtin/research/relative-valuation-pane.tsx +19 -17
- package/src/plugins/builtin/research-search/index.tsx +3 -1
- package/src/plugins/builtin/scanner/denied.tsx +16 -4
- package/src/plugins/builtin/scanner/flow-pane.tsx +1 -1
- package/src/plugins/builtin/scanner/hilo-pane.tsx +1 -1
- package/src/plugins/builtin/sec/filing-display.tsx +14 -2
- package/src/plugins/builtin/sec/headless.ts +42 -4
- package/src/plugins/builtin/sec/index.tsx +21 -1
- package/src/plugins/builtin/sectors/index.tsx +6 -9
- package/src/plugins/builtin/sectors/sector-model.ts +1 -1
- package/src/plugins/builtin/shared/cloud-upgrade.ts +1 -1
- package/src/plugins/builtin/shared/earnings-report.ts +49 -5
- package/src/plugins/builtin/shared/options-pro-copy.ts +34 -0
- package/src/plugins/builtin/shared/report-freshness.ts +2 -3
- package/src/plugins/builtin/shared/statement-currency.ts +23 -0
- package/src/plugins/builtin/shared/ticker-surface.ts +1 -1
- package/src/plugins/builtin/supply-chain/client.ts +34 -9
- package/src/plugins/builtin/supply-chain/evidence.ts +3 -2
- package/src/plugins/builtin/supply-chain/flow.tsx +4 -3
- package/src/plugins/builtin/supply-chain/graph-model.ts +14 -7
- package/src/plugins/builtin/supply-chain/graph-pane.tsx +3 -1
- package/src/plugins/builtin/supply-chain/graph.tsx +6 -3
- package/src/plugins/builtin/supply-chain/headless.ts +19 -4
- package/src/plugins/builtin/supply-chain/model.ts +50 -6
- package/src/plugins/builtin/supply-chain/pane.tsx +79 -18
- package/src/plugins/builtin/themes/headless.ts +4 -4
- package/src/plugins/builtin/themes/model.ts +11 -8
- package/src/plugins/builtin/themes/pane.tsx +2 -2
- package/src/plugins/builtin/ticker-detail/adr-pair/ah.ts +62 -0
- package/src/plugins/builtin/ticker-detail/adr-pair/headless.ts +119 -20
- package/src/plugins/builtin/ticker-detail/adr-pair/model.ts +51 -1
- package/src/plugins/builtin/ticker-detail/adr-pair/tab.tsx +25 -14
- package/src/plugins/builtin/ticker-detail/financials/model.ts +22 -32
- package/src/plugins/builtin/ticker-detail/financials/tab.tsx +7 -9
- package/src/plugins/builtin/ticker-detail/headless-schema.ts +2 -0
- package/src/plugins/builtin/ticker-detail/headless.ts +28 -12
- package/src/plugins/builtin/ticker-detail/overview/board-lot.ts +21 -0
- package/src/plugins/builtin/ticker-detail/overview/model.ts +28 -2
- package/src/plugins/builtin/ticker-detail/overview/pane.tsx +8 -0
- package/src/plugins/builtin/ticker-detail/overview-tab.tsx +68 -13
- package/src/plugins/builtin/ticker-detail/quote-monitor/card.tsx +9 -2
- package/src/plugins/builtin/ticker-detail/quote-monitor/index.tsx +5 -2
- package/src/plugins/builtin/volatility/model.ts +17 -0
- package/src/plugins/builtin/volatility/pane.tsx +16 -7
- package/src/plugins/builtin/world-indices/index.tsx +2 -0
- package/src/plugins/builtin/world-indices/table.tsx +15 -0
- package/src/plugins/builtin/world-venue-map/evidence.ts +3 -2
- package/src/plugins/builtin/world-venue-map/headless.ts +32 -18
- package/src/plugins/builtin/world-venue-map/index.ts +19 -6
- package/src/plugins/builtin/world-venue-map/layered-pane.tsx +9 -5
- package/src/plugins/builtin/world-venue-map/layers.ts +33 -11
- package/src/plugins/builtin/world-venue-map/map.tsx +12 -0
- package/src/plugins/builtin/world-venue-map/model.ts +6 -1
- package/src/plugins/builtin/world-venue-map/pane.tsx +35 -6
- package/src/plugins/builtin/world-venue-map/place.ts +119 -0
- package/src/plugins/builtin/world-venue-map/venue-header.tsx +5 -3
- package/src/plugins/catalog-browser.ts +10 -1
- package/src/plugins/catalog-data.ts +20 -0
- package/src/plugins/catalog-lazy.ts +51 -0
- package/src/plugins/catalog-ui.ts +16 -18
- package/src/plugins/host-smoke.ts +5 -2
- package/src/portfolio/allocation.ts +79 -19
- package/src/portfolio/cash-balances.ts +76 -0
- package/src/portfolio/mutations.ts +43 -8
- package/src/public/__snapshots__/public-api.test.ts.snap +1 -0
- package/src/renderers/browser/activity.ts +16 -0
- package/src/renderers/browser/app-badge-host.ts +14 -0
- package/src/renderers/browser/main.tsx +5 -0
- package/src/renderers/browser/notifications.ts +103 -0
- package/src/renderers/browser/ui-host.tsx +4 -0
- package/src/renderers/desktop/window-layouts.ts +14 -0
- package/src/renderers/dom/data-table/index.tsx +27 -4
- package/src/renderers/dom/data-table/row.tsx +2 -0
- package/src/renderers/dom/host/tabs.tsx +57 -8
- package/src/renderers/dom/styles.css +13 -5
- package/src/renderers/electrobun/bun/desktop/backend-requests.ts +4 -0
- package/src/renderers/electrobun/bun/desktop/backend.ts +22 -1
- package/src/renderers/electrobun/bun/window/native-min-size.ts +6 -1
- package/src/renderers/electrobun/shared/protocol.ts +4 -0
- package/src/renderers/electrobun/view/cli-pane-shot-frame.tsx +50 -12
- package/src/renderers/electrobun/view/http-fetch.ts +3 -2
- package/src/renderers/electrobun/view/remote/ticker-repository.ts +10 -0
- package/src/series/standalone-catalog.ts +5 -4
- package/src/series/standalone.ts +13 -7
- package/src/sources/gloomberb-cloud/index.ts +22 -9
- package/src/sources/gloomberb-cloud/news.ts +35 -0
- package/src/sources/gloomberb-cloud/perpetuals.ts +60 -3
- package/src/sources/provider-errors.ts +34 -7
- package/src/sources/provider-router/financials.ts +20 -13
- package/src/sources/provider-router/history.ts +32 -6
- package/src/sources/provider-router/index.ts +4 -0
- package/src/sources/provider-router/search.ts +1 -0
- package/src/sync/collections-contributor.ts +3 -1
- package/src/sync/config-merge.ts +10 -1
- package/src/sync/sanitize.ts +26 -2
- package/src/tickers/company-name-listing.ts +16 -2
- package/src/tickers/listing-fate.ts +12 -8
- package/src/tickers/renamed-listings.ts +43 -10
- package/src/tickers/search/home-listing.ts +28 -0
- package/src/tickers/search/index.ts +19 -7
- package/src/tickers/terminal-codes.ts +11 -1
- package/src/time-series/base-series.ts +39 -6
- package/src/time-series/chart-seed.ts +2 -2
- package/src/time-series/history-quality.ts +4 -1
- package/src/time-series/hooks.ts +2 -0
- package/src/time-series/price-comparison.ts +17 -23
- package/src/time-series/reporting.ts +1 -1
- package/src/time-series/resolution.ts +13 -0
- package/src/time-series/resolve-context.ts +6 -0
- package/src/time-series/resolve.ts +42 -3
- package/src/time-series/spec.ts +2 -2
- package/src/time-series/types.ts +3 -2
- package/src/types/data-provider.ts +11 -0
- package/src/types/financials.ts +48 -4
- package/src/types/headless.ts +1 -0
- package/src/types/issuer-listings.ts +2 -0
- package/src/types/plugin-notifications.ts +3 -0
- package/src/types/price-history.ts +6 -4
- package/src/types/ticker.ts +10 -2
- package/src/ui/host.tsx +2 -0
- package/src/utils/cli-output.ts +1 -1
- package/src/utils/declared-dividends.ts +13 -1
- package/src/utils/dividend-cash.ts +5 -1
- package/src/utils/exchange-announcements.ts +7 -2
- package/src/utils/forward-dividend.ts +4 -3
- package/src/utils/fundamentals.ts +40 -0
- package/src/utils/network-failure.ts +2 -0
- package/src/utils/price-history-integrity.ts +9 -1
- package/src/utils/remove-folder.ts +37 -0
- package/src/utils/trailing-dividend.ts +1 -1
- package/src/plugins/builtin/composite-plugins.ts +0 -285
|
@@ -8,9 +8,10 @@ import { getGeoEntities, loadGeoCatalog, type GeoColumn, type GeoEntitiesPayload
|
|
|
8
8
|
import type { HeadlessPaneColumn, HeadlessPaneContext, HeadlessPaneDefinition, HeadlessPaneFreshness, HeadlessPaneRow, HeadlessRowsResult } from "../../../types/headless";
|
|
9
9
|
import { formatUtcDayTime } from "../../../utils/utc-time";
|
|
10
10
|
import { REFERENCE_DATA } from "../shared/report-freshness";
|
|
11
|
-
import { columnValue, formatGeoValue, isChangeColumn, layerCoverageNote, parseLayerTokens, plainGeoValue, resolveActiveLayers, tickerLinkKey } from "./layers";
|
|
12
|
-
import { filterWorldVenues, formatVenueLocalTime } from "./model";
|
|
11
|
+
import { columnValue, formatGeoValue, isChangeColumn, layerCoverageNote, parseLayerTokens, parseMapPreset, plainGeoValue, resolveActiveLayers, tickerLinkKey } from "./layers";
|
|
12
|
+
import { filterWorldVenues, formatVenueLocalTime, venueSession } from "./model";
|
|
13
13
|
import { REPORT_FILTER, REPORT_ROWS } from "../shared/headless-options";
|
|
14
|
+
import { mapHomeArea, mapPlaceBbox, nearestPlaces, resolveMapPlace, type MapStart } from "./place";
|
|
14
15
|
|
|
15
16
|
/**
|
|
16
17
|
* A layer's status from its own cadence, as the pane's footer shows it. The
|
|
@@ -32,12 +33,12 @@ export function contextGeoRequest(context: HeadlessPaneContext): GeoRequest {
|
|
|
32
33
|
return <T>(path: string, init?: RequestInit) => context.apiClient.geo<T>(path, { ...init, signal: init?.signal ?? context.signal });
|
|
33
34
|
}
|
|
34
35
|
|
|
35
|
-
function tokensFor(args: { argument: unknown; options: Record<string, unknown> }, settings: Record<string, unknown> | undefined): string[] {
|
|
36
|
+
function tokensFor(args: { argument: unknown; options: Record<string, unknown> }, settings: Record<string, unknown> | undefined, catalog: readonly GeoLayerInfo[]): string[] {
|
|
36
37
|
const fromOption = parseLayerTokens(args.options.layer);
|
|
37
38
|
if (fromOption.length) return fromOption;
|
|
38
39
|
const fromSettings = parseLayerTokens(settings?.layers);
|
|
39
40
|
if (fromSettings.length) return fromSettings;
|
|
40
|
-
return
|
|
41
|
+
return parseMapPreset(typeof args.argument === "string" ? args.argument : "", catalog)?.layers ?? [];
|
|
41
42
|
}
|
|
42
43
|
|
|
43
44
|
const VENUE_COLUMNS: HeadlessPaneColumn[] = [
|
|
@@ -45,28 +46,31 @@ const VENUE_COLUMNS: HeadlessPaneColumn[] = [
|
|
|
45
46
|
{ key: "name", header: "Venue" },
|
|
46
47
|
{ key: "city", header: "City" },
|
|
47
48
|
{ key: "country", header: "Country" },
|
|
48
|
-
|
|
49
|
+
// The state by the exchange's calendar: a holiday, or a US venue's pre-market and after-hours around its core session.
|
|
50
|
+
{ key: "session", header: "Session" },
|
|
49
51
|
{ key: "localTime", header: "Local" },
|
|
50
52
|
];
|
|
51
53
|
|
|
52
|
-
async function venueRows(context: HeadlessPaneContext, query: string): Promise<HeadlessRowsResult> {
|
|
54
|
+
async function venueRows(context: HeadlessPaneContext, query: string, start: MapStart): Promise<HeadlessRowsResult> {
|
|
53
55
|
const response = await context.apiClient.getCloudWorldVenues();
|
|
54
56
|
if (!response.data) throw new Error(response.reasonCode ?? "World venue data unavailable");
|
|
55
57
|
const now = Date.now();
|
|
56
58
|
return {
|
|
57
59
|
columns: VENUE_COLUMNS,
|
|
58
|
-
rows: filterWorldVenues(response.data.venues, query).map((venue) => ({
|
|
60
|
+
rows: nearestPlaces(filterWorldVenues(response.data.venues, query), start.place, (venue) => venue).map((venue) => ({
|
|
59
61
|
mic: venue.mic,
|
|
60
62
|
name: venue.title,
|
|
61
63
|
city: venue.city,
|
|
62
64
|
country: venue.country,
|
|
65
|
+
session: venueSession(venue),
|
|
63
66
|
open: venue.isOpen,
|
|
64
67
|
localTime: formatVenueLocalTime(venue.timezone, now),
|
|
65
68
|
lon: venue.longitude,
|
|
66
69
|
lat: venue.latitude,
|
|
67
70
|
})),
|
|
68
71
|
freshness: REFERENCE_DATA,
|
|
69
|
-
|
|
72
|
+
errors: start.note ? [start.note] : [],
|
|
73
|
+
metadata: { layer: "venues", stale: response.stale === true, ...(start.place ? { place: start.place } : {}) },
|
|
70
74
|
};
|
|
71
75
|
}
|
|
72
76
|
|
|
@@ -141,9 +145,9 @@ export const mapHeadless = {
|
|
|
141
145
|
description: "Trading venues with open status and local time, or one map layer's entities (ships, chokepoints, ports, airports, pipelines, fields, terminals) with their fields and linked tickers.",
|
|
142
146
|
argument: {
|
|
143
147
|
kind: "free-text",
|
|
144
|
-
placeholder: "layers",
|
|
148
|
+
placeholder: "layers [place or lat,lon]",
|
|
145
149
|
optional: true,
|
|
146
|
-
description: "
|
|
150
|
+
description: "Layers (ships, ports, energy, air), then an optional place or latitude,longitude; home area when no place is given.",
|
|
147
151
|
},
|
|
148
152
|
options: [
|
|
149
153
|
{ key: "layer", aliases: ["layers"], settingKey: "layers", description: "Layer id or group to list, such as vessels or energy.", type: "string" },
|
|
@@ -156,18 +160,27 @@ export const mapHeadless = {
|
|
|
156
160
|
screenshotReadiness: "ready",
|
|
157
161
|
},
|
|
158
162
|
describe: (args, result) => {
|
|
159
|
-
const tokens = parseLayerTokens(args.options.layer
|
|
160
|
-
|
|
163
|
+
const tokens = parseLayerTokens(args.options.layer).length ? parseLayerTokens(args.options.layer) : parseMapPreset(typeof args.argument === "string" ? args.argument : "")?.layers ?? [];
|
|
164
|
+
const place = result?.metadata?.place as { label?: string } | undefined;
|
|
165
|
+
const near = place?.label ? ` | near ${place.label}` : "";
|
|
166
|
+
if (!tokens.length) return `World Map | venues${near}`;
|
|
161
167
|
// A layer of 7-day sums names the week they end on, which its source line dates without saying so.
|
|
162
168
|
const weekEnding = typeof result?.metadata?.weekEnding === "string" ? ` | week ending ${formatUtcDayTime({ time: Date.parse(result.metadata.weekEnding), dateOnly: true })}` : "";
|
|
163
|
-
return `World Map | ${tokens.join(", ")}${weekEnding}`;
|
|
169
|
+
return `World Map | ${tokens.join(", ")}${near}${weekEnding}`;
|
|
164
170
|
},
|
|
165
171
|
async load(args, context) {
|
|
166
172
|
const query = typeof args.options.query === "string" ? args.options.query : "";
|
|
167
|
-
const tokens = tokensFor(args, context.settings);
|
|
168
|
-
if (!tokens.length) return venueRows(context, query);
|
|
169
173
|
const request = contextGeoRequest(context);
|
|
170
174
|
const catalog = await loadGeoCatalog(request, { signal: context.signal });
|
|
175
|
+
const tokens = tokensFor(args, context.settings, catalog?.layers ?? []);
|
|
176
|
+
const typedPlace = parseMapPreset(typeof args.argument === "string" ? args.argument : "", catalog?.layers)?.place
|
|
177
|
+
?? (typeof context.settings?.place === "string" ? context.settings.place : mapHomeArea(context.config));
|
|
178
|
+
const start = await resolveMapPlace(typedPlace, {
|
|
179
|
+
request,
|
|
180
|
+
signal: context.signal,
|
|
181
|
+
venues: async () => (await context.apiClient.getCloudWorldVenues()).data?.venues ?? [],
|
|
182
|
+
});
|
|
183
|
+
if (!tokens.length) return venueRows(context, query, start);
|
|
171
184
|
const layers = resolveActiveLayers(tokens, catalog?.layers);
|
|
172
185
|
const layer = layers[0];
|
|
173
186
|
if (!layer) {
|
|
@@ -177,9 +190,9 @@ export const mapHeadless = {
|
|
|
177
190
|
const limit = typeof args.options.limit === "number" ? args.options.limit : 100;
|
|
178
191
|
const page = layer.status === "unavailable"
|
|
179
192
|
? { rows: [], total: 0, asOf: null, columns: layer.columns }
|
|
180
|
-
: await getGeoEntities(request, layer.id, { q: query, limit }, context.signal);
|
|
193
|
+
: await getGeoEntities(request, layer.id, { q: query, limit, ...(start.place ? { bbox: mapPlaceBbox(start.place) } : {}) }, context.signal);
|
|
181
194
|
const columns = page.columns?.length ? page.columns : layer.columns;
|
|
182
|
-
const rows: HeadlessPaneRow[] = page.rows.map((row) => ({
|
|
195
|
+
const rows: HeadlessPaneRow[] = nearestPlaces(page.rows, start.place, (row) => ({ longitude: row.lon, latitude: row.lat })).map((row) => ({
|
|
183
196
|
id: row.id,
|
|
184
197
|
...Object.fromEntries(columns.map((column) => [column.key, plainGeoValue(columnValue(row, column))])),
|
|
185
198
|
ticker: row.tickers?.[0] ? tickerLinkKey(row.tickers[0]) : null,
|
|
@@ -198,7 +211,7 @@ export const mapHeadless = {
|
|
|
198
211
|
...(empty ? { empty } : {}),
|
|
199
212
|
freshness: layerFreshness(layer),
|
|
200
213
|
complete: layer.status === "ok",
|
|
201
|
-
errors: layer.status === "unavailable" ? [`${layer.name}: ${layer.statusNote ?? "unavailable"}`] : [],
|
|
214
|
+
errors: [...(start.note ? [start.note] : []), ...(layer.status === "unavailable" ? [`${layer.name}: ${layer.statusNote ?? "unavailable"}`] : [])],
|
|
202
215
|
metadata: {
|
|
203
216
|
layer: layer.id,
|
|
204
217
|
name: layer.name,
|
|
@@ -206,6 +219,7 @@ export const mapHeadless = {
|
|
|
206
219
|
status: layer.status,
|
|
207
220
|
asOf,
|
|
208
221
|
total: page.total ?? null,
|
|
222
|
+
...(start.place ? { place: start.place, bbox: mapPlaceBbox(start.place) } : {}),
|
|
209
223
|
...("totals" in page && page.totals ? { totals: page.totals } : {}),
|
|
210
224
|
...("matched" in page && page.matched ? { matched: page.matched } : {}),
|
|
211
225
|
...(weekEnding ? { weekEnding } : {}),
|
|
@@ -12,6 +12,7 @@ import { contextGeoRequest, mapHeadless } from "./headless";
|
|
|
12
12
|
import { buildMapSettingsDef, groupTitle, MAP_PRESET_OPTIONS, parseMapPreset } from "./layers";
|
|
13
13
|
import { WORLD_VENUE_MAP_PANE_ID, WorldVenueMapPane } from "./pane";
|
|
14
14
|
import { mapFollowsTicker } from "./scope";
|
|
15
|
+
import { mapHomeArea, paneWithoutHomeArea } from "./place";
|
|
15
16
|
|
|
16
17
|
const chartComposerHeadless = chartHeadless("chart-composer-pane");
|
|
17
18
|
|
|
@@ -41,7 +42,16 @@ const chokepointTemplate: PaneTemplateDef = {
|
|
|
41
42
|
createInstance: (_context, options) => createChokepointInstance(cloudGeoRequest, options?.arg),
|
|
42
43
|
};
|
|
43
44
|
|
|
45
|
+
/** The home area a share is checked against, read from the running app's config. */
|
|
46
|
+
let currentHomeArea = (): string => "";
|
|
47
|
+
|
|
44
48
|
export const worldVenueMapModule: PluginModule = {
|
|
49
|
+
setup: (ctx) => {
|
|
50
|
+
currentHomeArea = () => mapHomeArea(ctx.getConfig());
|
|
51
|
+
},
|
|
52
|
+
dispose: () => {
|
|
53
|
+
currentHomeArea = () => "";
|
|
54
|
+
},
|
|
45
55
|
panes: [
|
|
46
56
|
{
|
|
47
57
|
id: WORLD_VENUE_MAP_PANE_ID,
|
|
@@ -54,8 +64,9 @@ export const worldVenueMapModule: PluginModule = {
|
|
|
54
64
|
// Linked to a list, a map with the app's own layers (facilities) shows the selected company's.
|
|
55
65
|
shareItem: { ticker: true, argument: true },
|
|
56
66
|
tickerFollower: mapFollowsTicker,
|
|
57
|
-
//
|
|
58
|
-
|
|
67
|
+
// Maps made before the home area was read when a map opens stored it as their place.
|
|
68
|
+
portableShare: { prepare: (pane) => paneWithoutHomeArea(pane, currentHomeArea()) },
|
|
69
|
+
settings: (context) => buildMapSettingsDef(context.settings, peekGeoCatalog()?.layers),
|
|
59
70
|
},
|
|
60
71
|
],
|
|
61
72
|
paneTemplates: [
|
|
@@ -67,19 +78,21 @@ export const worldVenueMapModule: PluginModule = {
|
|
|
67
78
|
keywords: ["world", "map", "globe", "countries", "venue", "venues", "exchange", "mic", "market hours", "open markets", "ships", "ship", "vessels", "vessel", "shipping", "ais", "ports", "port", "chokepoints", "pipelines", "airports", "energy", "facilities", "data centers", "fabs", "layers"],
|
|
68
79
|
shortcut: {
|
|
69
80
|
prefix: "MAP",
|
|
70
|
-
argPlaceholder: "layers",
|
|
81
|
+
argPlaceholder: "layers [place or lat,lon]",
|
|
71
82
|
argKind: "text",
|
|
72
83
|
argOptional: true,
|
|
73
84
|
argOptions: () => MAP_PRESET_OPTIONS,
|
|
74
85
|
},
|
|
75
86
|
headless: mapHeadless,
|
|
76
87
|
createInstance: (_context, options) => {
|
|
77
|
-
const preset = parseMapPreset(options?.arg ?? options?.values?.layers);
|
|
88
|
+
const preset = parseMapPreset(options?.arg ?? options?.values?.layers, peekGeoCatalog()?.layers);
|
|
89
|
+
// Only a place that was typed is kept: the home area is read when the map opens, so a saved or shared map never carries it.
|
|
90
|
+
const place = preset?.place;
|
|
78
91
|
if (!preset) return { placement: "floating" };
|
|
79
92
|
return {
|
|
80
|
-
title: preset.layers.length ? `Map · ${preset.layers.map(groupTitle).join(", ")}` : "Map · Venues"
|
|
93
|
+
title: `${preset.layers.length ? `Map · ${preset.layers.map(groupTitle).join(", ")}` : "Map · Venues"}${place ? ` · ${place}` : ""}`,
|
|
81
94
|
placement: "floating",
|
|
82
|
-
settings: { layers: preset.layers, venues: preset.venues },
|
|
95
|
+
settings: { layers: preset.layers, venues: preset.venues, ...(place ? { place } : {}) },
|
|
83
96
|
};
|
|
84
97
|
},
|
|
85
98
|
},
|
|
@@ -79,6 +79,7 @@ import { usesClassTones } from "./map-symbols";
|
|
|
79
79
|
import { filterWorldVenues, WORLD_MAP_HEIGHT_RATIO } from "./model";
|
|
80
80
|
import { useGeoLayerFeed } from "./use-geo";
|
|
81
81
|
import { SelectedVenueHeader } from "./venue-header";
|
|
82
|
+
import { initialMapFocus, mapPlaceBbox, nearestPlaces, type MapStart } from "./place";
|
|
82
83
|
|
|
83
84
|
interface LayeredMapViewProps extends PaneProps {
|
|
84
85
|
/** The layers on, already capped. */
|
|
@@ -87,6 +88,7 @@ interface LayeredMapViewProps extends PaneProps {
|
|
|
87
88
|
tokens: readonly string[];
|
|
88
89
|
/** A plain MAP: venues show unless the pane turned them off. */
|
|
89
90
|
plain?: boolean;
|
|
91
|
+
start: MapStart;
|
|
90
92
|
}
|
|
91
93
|
|
|
92
94
|
interface OpenEntity {
|
|
@@ -179,7 +181,7 @@ const SelectedEntityHeader = memo(function SelectedEntityHeader({
|
|
|
179
181
|
);
|
|
180
182
|
});
|
|
181
183
|
|
|
182
|
-
export function LayeredMapView({ focused, width, height, layers, tokens, plain = false }: LayeredMapViewProps) {
|
|
184
|
+
export function LayeredMapView({ focused, width, height, layers, tokens, plain = false, start }: LayeredMapViewProps) {
|
|
183
185
|
const colors = useThemeColors();
|
|
184
186
|
const dark = relativeLuminance(colors.text) > relativeLuminance(colors.bg);
|
|
185
187
|
const { nativePaneChrome } = useUiCapabilities();
|
|
@@ -232,9 +234,9 @@ export function LayeredMapView({ focused, width, height, layers, tokens, plain =
|
|
|
232
234
|
const [open, setOpen] = usePluginPaneState<OpenEntity | null>("map:open", null);
|
|
233
235
|
const [selectedMic, setSelectedMic] = useState<string | null>(null);
|
|
234
236
|
const [headerSubject, setHeaderSubject] = useState<"entity" | "venue">("entity");
|
|
235
|
-
const [focus, setFocus] = useState<WorldMapFocus | null>(null);
|
|
236
237
|
// Kept per pane, so docking, undocking, popping out or reloading reopens the map where it was.
|
|
237
238
|
const [savedViewport, setSavedViewport] = usePluginPaneState<unknown>("map:viewport", null);
|
|
239
|
+
const [focus, setFocus] = useState<WorldMapFocus | null>(() => initialMapFocus(start.place, savedViewport, start.home));
|
|
238
240
|
const { active: searchFocused, focus: focusSearch, searchProps } = useQueryBarSearch();
|
|
239
241
|
const mapKeys = useMapKeyboard(searchFocused);
|
|
240
242
|
const scrollRef = useRef<ScrollBoxRenderable>(null);
|
|
@@ -249,7 +251,7 @@ export function LayeredMapView({ focused, width, height, layers, tokens, plain =
|
|
|
249
251
|
const timer = setTimeout(() => setTableView(view), TABLE_VIEW_SETTLE_MS);
|
|
250
252
|
return () => clearTimeout(timer);
|
|
251
253
|
}, [tableView, view]);
|
|
252
|
-
const tableBbox = entityTableBbox(tableLayer, tableView);
|
|
254
|
+
const tableBbox = !nativePaneChrome && start.place ? mapPlaceBbox(start.place) : entityTableBbox(tableLayer, tableView);
|
|
253
255
|
const tableBboxKey = tableBbox?.join(",") ?? "";
|
|
254
256
|
const loadPage = useCallback(async ({ offset, signal }: PageRequest) => {
|
|
255
257
|
const page = await loadEntityPage(tableLayer.id, {
|
|
@@ -269,7 +271,8 @@ export function LayeredMapView({ focused, width, height, layers, tokens, plain =
|
|
|
269
271
|
};
|
|
270
272
|
}, [query, request, scope?.key, sort.dir, sort.key, tableBboxKey, tableLayer.id]);
|
|
271
273
|
const pages = usePagedRows(tableReadable ? loadPage : null, { getId: (row) => row.id });
|
|
272
|
-
const rows = pages.rows
|
|
274
|
+
const rows = useMemo(() => !sort.key ? nearestPlaces(pages.rows, start.place, (row) => ({ longitude: row.lon, latitude: row.lat })) : pages.rows,
|
|
275
|
+
[pages.rows, sort.key, start.place]);
|
|
273
276
|
// A linked map frames the places of each company or theme it moves to, once.
|
|
274
277
|
const framedScopeRef = useRef<string | null>(null);
|
|
275
278
|
const firstPage = pages.pages[0];
|
|
@@ -385,9 +388,10 @@ export function LayeredMapView({ focused, width, height, layers, tokens, plain =
|
|
|
385
388
|
...(freshness ? [{ id: "fresh", parts: [{ text: freshness.text, tone: freshness.tone }] }] : []),
|
|
386
389
|
...(zoomLayers.length ? [{ id: "zoom", parts: [{ text: `zoom in for ${zoomLayers.map((state) => state.layer.name).join(", ")}`, tone: "muted" as const }] }] : []),
|
|
387
390
|
...(pages.error && rows.length ? [{ id: "error", parts: [{ text: pages.error.message, tone: "warning" as const }] }] : []),
|
|
391
|
+
...(start.note ? [{ id: "place", parts: [{ text: start.note, tone: "warning" as const }] }] : []),
|
|
388
392
|
],
|
|
389
393
|
hints,
|
|
390
|
-
}), [detail.data, detail.loading, detailOpen, freshness?.text, freshness?.tone, hints.map((hint) => hint.id).join(","), loadingLayers.length, pages.error, pages.loading, pages.loadingMore, rows.length, zoomLayers.map((state) => state.layer.id).join(",")]);
|
|
394
|
+
}), [detail.data, detail.loading, detailOpen, freshness?.text, freshness?.tone, hints.map((hint) => hint.id).join(","), loadingLayers.length, pages.error, pages.loading, pages.loadingMore, rows.length, start.note, zoomLayers.map((state) => state.layer.id).join(",")]);
|
|
391
395
|
// The table's own layer says it cannot serve in the body; the footer warns about the others.
|
|
392
396
|
const notices = layerNotices(states.filter((state) => state.layer.id !== tableLayer.id || (state.phase !== "unavailable" && state.phase !== "locked")));
|
|
393
397
|
usePaneNoticeFooter({ registrationId: `${WORLD_VENUE_MAP_PANE_ID}:notices`, focused, notices, enabled: !detailOpen });
|
|
@@ -20,6 +20,7 @@ import { unprojectWorldPoint, type WorldMapViewport } from "./model";
|
|
|
20
20
|
|
|
21
21
|
export const LAYERS_SETTING_KEY = "layers";
|
|
22
22
|
export const VENUES_SETTING_KEY = "venues";
|
|
23
|
+
export const HOME_AREA_SETTING_KEY = "mapHomeArea";
|
|
23
24
|
/** Layers that refresh on their own (ships, flights) are the expensive ones. */
|
|
24
25
|
const MAX_LIVE_LAYERS = GEO_MAX_LIVE_LAYERS;
|
|
25
26
|
const MAX_DATA_LAYERS = 4;
|
|
@@ -124,17 +125,31 @@ export function resolveActiveLayers(tokens: readonly string[], layers: readonly
|
|
|
124
125
|
export interface MapPreset {
|
|
125
126
|
layers: string[];
|
|
126
127
|
venues: boolean;
|
|
128
|
+
place?: string;
|
|
127
129
|
}
|
|
128
130
|
|
|
129
131
|
/**
|
|
130
|
-
*
|
|
131
|
-
* the catalog is known. `MAP venues` alone is the venue map without layers.
|
|
132
|
+
* Layers lead the argument; the remaining text names a place, keeping its commas.
|
|
132
133
|
*/
|
|
133
|
-
export function parseMapPreset(arg: string | null | undefined): MapPreset | null {
|
|
134
|
-
const
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
134
|
+
export function parseMapPreset(arg: string | null | undefined, catalog: readonly GeoLayerInfo[] = []): MapPreset | null {
|
|
135
|
+
const text = arg?.trim() ?? "";
|
|
136
|
+
if (!text) return null;
|
|
137
|
+
const known = new Set([
|
|
138
|
+
"venues", "ships", "ports", "energy", "air", "infrastructure", "facilities",
|
|
139
|
+
"vessels", "chokepoints", "airports", "flights", "pipelines", "oil-gas-fields", "terminals",
|
|
140
|
+
...catalog.flatMap((layer) => [layer.id.toLowerCase(), String(layer.group).toLowerCase()]),
|
|
141
|
+
]);
|
|
142
|
+
const layers: string[] = [];
|
|
143
|
+
let venues = false;
|
|
144
|
+
let rest = text;
|
|
145
|
+
while (rest) {
|
|
146
|
+
const token = /^[^\s,;+]+/.exec(rest)?.[0]?.toLowerCase();
|
|
147
|
+
if (!token || !known.has(token)) break;
|
|
148
|
+
if (token === "venues") venues = true;
|
|
149
|
+
else if (!layers.includes(token)) layers.push(token);
|
|
150
|
+
rest = rest.slice(token.length).replace(/^[\s,;+]+/, "");
|
|
151
|
+
}
|
|
152
|
+
return { layers, venues: venues || !layers.length, ...(rest ? { place: rest } : {}) };
|
|
138
153
|
}
|
|
139
154
|
|
|
140
155
|
export const MAP_PRESET_OPTIONS = [
|
|
@@ -221,17 +236,23 @@ export function readVenuesSetting(settings: Record<string, unknown> | undefined,
|
|
|
221
236
|
|
|
222
237
|
/**
|
|
223
238
|
* The layer picker in the pane settings: venues, then one list per group with
|
|
224
|
-
* each layer's cadence and status.
|
|
225
|
-
* so a server without geo layers shows the settings it always had.
|
|
239
|
+
* each layer's cadence and status. Home area also works without a catalog.
|
|
226
240
|
*/
|
|
227
241
|
export function buildMapSettingsDef(
|
|
228
242
|
settings: Record<string, unknown>,
|
|
229
243
|
layers: readonly GeoLayerInfo[] | null | undefined,
|
|
230
|
-
): PaneSettingsDef
|
|
231
|
-
|
|
244
|
+
): PaneSettingsDef {
|
|
245
|
+
layers ??= [];
|
|
232
246
|
const active = resolveActiveLayers(activeLayerTokens(settings, layers), layers);
|
|
233
247
|
const values: Record<string, unknown> = { [VENUES_SETTING_KEY]: readVenuesSetting(settings, active.length) };
|
|
234
248
|
const fields: PaneSettingField[] = [{
|
|
249
|
+
key: HOME_AREA_SETTING_KEY,
|
|
250
|
+
label: "Home area",
|
|
251
|
+
description: "New maps start here. Place name or latitude,longitude; blank for world.",
|
|
252
|
+
type: "text",
|
|
253
|
+
storage: "plugin",
|
|
254
|
+
placeholder: "Sydney or 51.5,-0.1",
|
|
255
|
+
}, {
|
|
235
256
|
key: VENUES_SETTING_KEY,
|
|
236
257
|
label: "Venues",
|
|
237
258
|
description: "Trading venues with open or closed status.",
|
|
@@ -262,6 +283,7 @@ export function applyMapSetting(
|
|
|
262
283
|
value: unknown,
|
|
263
284
|
layers: readonly GeoLayerInfo[],
|
|
264
285
|
): Record<string, unknown> {
|
|
286
|
+
if (key === HOME_AREA_SETTING_KEY) return { ...settings, [key]: value };
|
|
265
287
|
const before = resolveActiveLayers(activeLayerTokens(settings, layers), layers);
|
|
266
288
|
// The first edit of a plain map writes down what it showed, so only the edited part changes.
|
|
267
289
|
const chosen = isPlainMap(settings)
|
|
@@ -45,6 +45,8 @@ export interface WorldMapFocus {
|
|
|
45
45
|
zoom?: number;
|
|
46
46
|
/** Exactly at `zoom`, out as well as in: a frame around a set of places. */
|
|
47
47
|
exact?: boolean;
|
|
48
|
+
/** The pane starts here on its own, so the view is not kept in the pane until the map moves. */
|
|
49
|
+
transient?: boolean;
|
|
48
50
|
}
|
|
49
51
|
|
|
50
52
|
interface WorldVenueMapProps {
|
|
@@ -691,6 +693,12 @@ function DesktopWorldVenueMap(props: WorldVenueMapProps) {
|
|
|
691
693
|
const focus = props.focus;
|
|
692
694
|
if (!focus || !sized || appliedFocusRef.current === focus.key) return;
|
|
693
695
|
appliedFocusRef.current = focus.key;
|
|
696
|
+
if (focus.transient) {
|
|
697
|
+
const start = clampWorldMapViewport({ zoom: Math.max(1, focus.zoom ?? 1), centerLongitude: focus.longitude, centerLatitude: focus.latitude }, props.width, plotHeight, 1, maxZoom);
|
|
698
|
+
settledViewportRef.current = start;
|
|
699
|
+
setViewport(start);
|
|
700
|
+
return;
|
|
701
|
+
}
|
|
694
702
|
setViewport((current) => {
|
|
695
703
|
const zoom = focus.exact ? Math.max(1, focus.zoom ?? 1) : Math.max(current.zoom, focus.zoom ?? 1);
|
|
696
704
|
if (zoom <= 1 && !focus.exact) return current;
|
|
@@ -720,7 +728,11 @@ function DesktopWorldVenueMap(props: WorldVenueMapProps) {
|
|
|
720
728
|
|
|
721
729
|
// A venue picked in the table pans a zoomed map to it when it is out of view.
|
|
722
730
|
// Only a new selection moves the map, so a drag away from it stays put.
|
|
731
|
+
const previousSelectedMic = useRef(props.selectedMic);
|
|
723
732
|
useEffect(() => {
|
|
733
|
+
const previous = previousSelectedMic.current;
|
|
734
|
+
previousSelectedMic.current = props.selectedMic;
|
|
735
|
+
if (!previous || previous === props.selectedMic) return;
|
|
724
736
|
const venue = selectedVenueRef.current;
|
|
725
737
|
if (!venue) return;
|
|
726
738
|
setViewport((current) => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CloudWorldVenuePayload } from "../../../api-client";
|
|
1
|
+
import type { CloudWorldVenuePayload, WorldVenueSession } from "../../../api-client";
|
|
2
2
|
import { clamp } from "../../../utils/math";
|
|
3
3
|
|
|
4
4
|
export interface WorldMapPoint {
|
|
@@ -300,6 +300,11 @@ export function formatVenueLocalTime(timezone: string, now: number): string {
|
|
|
300
300
|
return formatter.format(now);
|
|
301
301
|
}
|
|
302
302
|
|
|
303
|
+
/** The venue's state as the service read it from the exchange's calendar, or from its core session where it says none. */
|
|
304
|
+
export function venueSession(venue: Pick<CloudWorldVenuePayload, "isOpen" | "session">): WorldVenueSession {
|
|
305
|
+
return venue.session ?? (venue.isOpen ? "open" : "closed");
|
|
306
|
+
}
|
|
307
|
+
|
|
303
308
|
export function venueRemainingSeconds(
|
|
304
309
|
venue: CloudWorldVenuePayload,
|
|
305
310
|
checkedAt: number,
|
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
} from "../../../components";
|
|
19
19
|
import { handleRefreshKey } from "../../../components/data-table/table-pane";
|
|
20
20
|
import { useShortcut } from "../../../react/input";
|
|
21
|
-
import { useAsyncResource, usePaneSettingValue, usePluginPaneState } from "../../../public/react";
|
|
21
|
+
import { useAppSelector, useAsyncResource, usePaneSettingValue, usePluginPaneState } from "../../../public/react";
|
|
22
22
|
import { colors } from "../../../theme/colors";
|
|
23
23
|
import type { PaneProps } from "../../../types/plugin";
|
|
24
24
|
import { Box, TextAttributes, useUiCapabilities } from "../../../ui";
|
|
@@ -31,6 +31,9 @@ import { useMapKeyboard, WorldVenueMap } from "./map";
|
|
|
31
31
|
import { filterWorldVenues, formatVenueLocalTime } from "./model";
|
|
32
32
|
import { useGeoCatalog } from "./use-geo";
|
|
33
33
|
import { SelectedVenueHeader } from "./venue-header";
|
|
34
|
+
import { cloudGeoRequest } from "./client";
|
|
35
|
+
import { initialMapFocus, mapHomeArea, nearestPlaces, resolveMapPlace, type MapStart } from "./place";
|
|
36
|
+
import { useWorldMapEvidence } from "./evidence";
|
|
34
37
|
|
|
35
38
|
export { WORLD_VENUE_MAP_PANE_ID } from "./ids";
|
|
36
39
|
|
|
@@ -54,6 +57,26 @@ function venueColumns(width: number): VenueColumn[] {
|
|
|
54
57
|
* server without them leaves the venue map exactly as it was.
|
|
55
58
|
*/
|
|
56
59
|
export function WorldVenueMapPane(props: PaneProps) {
|
|
60
|
+
const [placeSetting] = usePaneSettingValue<string | undefined>("place", undefined);
|
|
61
|
+
const homeArea = useAppSelector((state) => mapHomeArea(state.config));
|
|
62
|
+
// A map without a typed place starts at the home area; the pane never stores it.
|
|
63
|
+
const [initialPlace] = useState(placeSetting ?? homeArea);
|
|
64
|
+
const [startsAtHome] = useState(placeSetting === undefined);
|
|
65
|
+
const [mapStart, setMapStart] = useState<MapStart | null>(() => initialPlace ? null : { place: null, note: null });
|
|
66
|
+
useEffect(() => {
|
|
67
|
+
if (!initialPlace) return;
|
|
68
|
+
const controller = new AbortController();
|
|
69
|
+
resolveMapPlace(initialPlace, {
|
|
70
|
+
venues: async () => (await loadWorldVenues()).venues,
|
|
71
|
+
request: cloudGeoRequest,
|
|
72
|
+
signal: controller.signal,
|
|
73
|
+
}).then((start) => {
|
|
74
|
+
if (!controller.signal.aborted) setMapStart(startsAtHome ? { ...start, home: true } : start);
|
|
75
|
+
}, () => {
|
|
76
|
+
if (!controller.signal.aborted) setMapStart({ place: null, note: "Place unavailable; showing world." });
|
|
77
|
+
});
|
|
78
|
+
return () => controller.abort();
|
|
79
|
+
}, [initialPlace, startsAtHome]);
|
|
57
80
|
const [layerSetting] = usePaneSettingValue<unknown>(LAYERS_SETTING_KEY, null);
|
|
58
81
|
const [venuesSetting] = usePaneSettingValue<boolean | undefined>(VENUES_SETTING_KEY, undefined);
|
|
59
82
|
const { catalog, settled } = useGeoCatalog();
|
|
@@ -61,15 +84,16 @@ export function WorldVenueMapPane(props: PaneProps) {
|
|
|
61
84
|
const plain = isPlainMap(settings);
|
|
62
85
|
const tokens = useMemo(() => activeLayerTokens(settings, catalog?.layers), [catalog, settings]);
|
|
63
86
|
const layers = useMemo(() => resolveActiveLayers(tokens, catalog?.layers), [catalog, tokens]);
|
|
64
|
-
if (
|
|
87
|
+
if (!mapStart) return <PaneStatusBody loading align="center" width={props.width} height={props.height} loadingLabel="Finding place..." />;
|
|
88
|
+
if (layers.length) return <LayeredMapView {...props} layers={layers} tokens={tokens} plain={plain} start={mapStart} />;
|
|
65
89
|
// A preset or a plain map waits for the catalog rather than flashing the venue map first.
|
|
66
90
|
if ((plain || tokens.length) && !settled) {
|
|
67
91
|
return <PaneStatusBody loading align="center" width={props.width} height={props.height} loadingLabel="Loading map..." />;
|
|
68
92
|
}
|
|
69
|
-
return <VenueMapView {...props} />;
|
|
93
|
+
return <VenueMapView {...props} start={mapStart} />;
|
|
70
94
|
}
|
|
71
95
|
|
|
72
|
-
function VenueMapView({ focused, width, height }: PaneProps) {
|
|
96
|
+
function VenueMapView({ focused, width, height, start }: PaneProps & { start: MapStart }) {
|
|
73
97
|
// A background refresh keeps the venues on screen, so loading only shows before the first answer.
|
|
74
98
|
const { data, loading, error, load } = useAsyncResource(loadWorldVenues);
|
|
75
99
|
const [query, setQuery] = useState("");
|
|
@@ -90,7 +114,9 @@ function VenueMapView({ focused, width, height }: PaneProps) {
|
|
|
90
114
|
return () => clearInterval(timer);
|
|
91
115
|
}, []);
|
|
92
116
|
|
|
93
|
-
const venues = useMemo(() => filterWorldVenues(data?.venues ?? [], query),
|
|
117
|
+
const venues = useMemo(() => nearestPlaces(filterWorldVenues(data?.venues ?? [], query), start.place,
|
|
118
|
+
(venue) => venue), [data?.venues, query, start.place]);
|
|
119
|
+
useWorldMapEvidence([], [], venues.length, loading);
|
|
94
120
|
useEffect(() => {
|
|
95
121
|
if (selectedMic && venues.some((venue) => venue.mic === selectedMic)) return;
|
|
96
122
|
setSelectedMic(venues[0]?.mic ?? null);
|
|
@@ -117,15 +143,17 @@ function VenueMapView({ focused, width, height }: PaneProps) {
|
|
|
117
143
|
...(data && !data.stale ? [{ id: "live", parts: [{ text: "live", tone: "positive" as const }] }] : []),
|
|
118
144
|
...(data?.stale ? [{ id: "stale", parts: [{ text: "stale", tone: "warning" as const }] }] : []),
|
|
119
145
|
...(error ? [{ id: "error", parts: [{ text: error, tone: "warning" as const }] }] : []),
|
|
146
|
+
...(start.note ? [{ id: "place", parts: [{ text: start.note, tone: "warning" as const }] }] : []),
|
|
120
147
|
],
|
|
121
148
|
hints: [
|
|
122
149
|
...(searchable ? [{ id: "search", key: "/", label: "search", onPress: focusSearch }] : []),
|
|
123
150
|
],
|
|
124
|
-
}), [data, error, focusSearch, loading, searchable]);
|
|
151
|
+
}), [data, error, focusSearch, loading, searchable, start.note]);
|
|
125
152
|
|
|
126
153
|
const { nativePaneChrome } = useUiCapabilities();
|
|
127
154
|
const [storedSidebarWidth, setStoredSidebarWidth] = usePluginPaneState<number | null>("sidebarWidth", null);
|
|
128
155
|
const [savedViewport, setSavedViewport] = usePluginPaneState<unknown>("map:viewport", null);
|
|
156
|
+
const [initialFocus] = useState(() => initialMapFocus(start.place, savedViewport, start.home));
|
|
129
157
|
const [draggedSidebarWidth, setDraggedSidebarWidth] = useState<number | null>(null);
|
|
130
158
|
const horizontal = shouldShowPaneSidebar(data?.venues.length ?? 0, width, height);
|
|
131
159
|
// Venue names need more room than a conversation list, so the width the pane
|
|
@@ -227,6 +255,7 @@ function VenueMapView({ focused, width, height }: PaneProps) {
|
|
|
227
255
|
onSelect={(venue) => setSelectedMic(venue.mic)}
|
|
228
256
|
savedViewport={savedViewport}
|
|
229
257
|
onViewportSettled={setSavedViewport}
|
|
258
|
+
focus={initialFocus}
|
|
230
259
|
keyboard={mapKeys.keyboard}
|
|
231
260
|
/>
|
|
232
261
|
</Box>
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import type { CloudWorldVenuePayload } from "../../../api-client";
|
|
2
|
+
import { getGeoEntities, loadGeoCatalog, type GeoBbox, type GeoRequest } from "../../../api-client/geo";
|
|
3
|
+
import type { AppConfig, PaneInstanceConfig } from "../../../types/config";
|
|
4
|
+
import { HOME_AREA_SETTING_KEY } from "./layers";
|
|
5
|
+
import { savedWorldMapViewport } from "./model";
|
|
6
|
+
import { logFailure } from "../../../utils/log-failure";
|
|
7
|
+
|
|
8
|
+
export interface MapPlace {
|
|
9
|
+
label: string;
|
|
10
|
+
longitude: number;
|
|
11
|
+
latitude: number;
|
|
12
|
+
zoom: number;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface MapStart {
|
|
16
|
+
place: MapPlace | null;
|
|
17
|
+
note: string | null;
|
|
18
|
+
/** The place is the home area from the app's settings, not one the pane was made with. */
|
|
19
|
+
home?: true;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function mapHomeArea(config: AppConfig): string {
|
|
23
|
+
const value = config.pluginConfig?.["market-overview"]?.[HOME_AREA_SETTING_KEY];
|
|
24
|
+
return typeof value === "string" ? value.trim() : "";
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* The pane as a share carries it, without a starting place that is the home
|
|
29
|
+
* area: maps made before the home area was read at render time stored it in
|
|
30
|
+
* their settings and, with a layer preset, in their title.
|
|
31
|
+
*/
|
|
32
|
+
export function paneWithoutHomeArea(pane: PaneInstanceConfig, homeArea: string): PaneInstanceConfig {
|
|
33
|
+
const place = pane.settings?.place;
|
|
34
|
+
const same = (left: string, right: string) => left.trim().toLowerCase() === right.trim().toLowerCase();
|
|
35
|
+
if (!homeArea.trim() || typeof place !== "string" || !same(place, homeArea)) return pane;
|
|
36
|
+
const { place: _place, ...settings } = pane.settings!;
|
|
37
|
+
const suffix = ` · ${place.trim()}`;
|
|
38
|
+
const title = pane.title?.trim();
|
|
39
|
+
const shortened = title && title.length > suffix.length && same(title.slice(-suffix.length), suffix)
|
|
40
|
+
? title.slice(0, -suffix.length)
|
|
41
|
+
: pane.title;
|
|
42
|
+
return { ...pane, settings, ...(shortened === undefined ? {} : { title: shortened }) };
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function normalize(value: string): string {
|
|
46
|
+
return value.normalize("NFKD").replace(/\p{M}/gu, "").toLowerCase().replace(/[^\p{L}\p{N}]+/gu, " ").trim();
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export async function resolveMapPlace(
|
|
50
|
+
text: string,
|
|
51
|
+
sources: { venues: () => Promise<readonly CloudWorldVenuePayload[]>; request: GeoRequest; signal?: AbortSignal },
|
|
52
|
+
): Promise<MapStart> {
|
|
53
|
+
const typed = text.trim();
|
|
54
|
+
if (!typed) return { place: null, note: null };
|
|
55
|
+
const coordinates = /^([+-]?(?:\d+(?:\.\d*)?|\.\d+))\s*,\s*([+-]?(?:\d+(?:\.\d*)?|\.\d+))$/.exec(typed);
|
|
56
|
+
if (coordinates) {
|
|
57
|
+
const latitude = Number(coordinates[1]);
|
|
58
|
+
const longitude = Number(coordinates[2]);
|
|
59
|
+
if (Math.abs(latitude) <= 90 && Math.abs(longitude) <= 180) {
|
|
60
|
+
return { place: { label: typed, latitude, longitude, zoom: 32 }, note: null };
|
|
61
|
+
}
|
|
62
|
+
} else {
|
|
63
|
+
const name = normalize(typed);
|
|
64
|
+
const { COUNTRY_LABELS } = await import("./natural-earth/labels.chunk.js");
|
|
65
|
+
const country = COUNTRY_LABELS.find(([label]) => normalize(label) === name);
|
|
66
|
+
if (country) return { place: { label: country[0], longitude: country[1], latitude: country[2], zoom: 4 }, note: null };
|
|
67
|
+
const venues = await sources.venues().catch((error: unknown) => {
|
|
68
|
+
logFailure("world-venue-map.place", "Loading venue places failed")(error);
|
|
69
|
+
return [];
|
|
70
|
+
});
|
|
71
|
+
const venue = venues.find((entry) => [entry.city, entry.title, entry.mic, entry.country, entry.countryCode].some((label) => normalize(label) === name));
|
|
72
|
+
if (venue) return { place: { label: typed, longitude: venue.longitude, latitude: venue.latitude, zoom: 32 }, note: null };
|
|
73
|
+
const catalog = await loadGeoCatalog(sources.request, { signal: sources.signal });
|
|
74
|
+
const layers = [...(catalog?.layers ?? [])].sort((left, right) => {
|
|
75
|
+
const priority = (id: string) => ["chokepoints", "ports", "airports"].indexOf(id);
|
|
76
|
+
const rank = (id: string) => priority(id) < 0 ? 3 : priority(id);
|
|
77
|
+
return rank(left.id) - rank(right.id);
|
|
78
|
+
});
|
|
79
|
+
for (const layer of layers) {
|
|
80
|
+
if (layer.status === "unavailable" || sources.signal?.aborted) continue;
|
|
81
|
+
const page = await getGeoEntities(sources.request, layer.id, { q: typed, limit: 20 }, sources.signal).catch((error: unknown) => {
|
|
82
|
+
if (!sources.signal?.aborted) logFailure("world-venue-map.place", "Searching map places failed")(error);
|
|
83
|
+
return null;
|
|
84
|
+
});
|
|
85
|
+
const row = page?.rows.find((entry) => Number.isFinite(entry.lon) && Number.isFinite(entry.lat)
|
|
86
|
+
&& [entry.label, entry.id, ...Object.values(entry.props).filter((value): value is string => typeof value === "string")]
|
|
87
|
+
.some((value) => normalize(value) === name)) ?? (page?.rows.length === 1 ? page.rows[0] : null);
|
|
88
|
+
if (row && Number.isFinite(row.lon) && Number.isFinite(row.lat)) {
|
|
89
|
+
return { place: { label: row.label, longitude: row.lon, latitude: row.lat, zoom: 32 }, note: null };
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
return { place: null, note: `Unknown place "${typed}"; showing world.` };
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export function mapPlaceBbox(place: MapPlace): GeoBbox {
|
|
97
|
+
const span = 180 / place.zoom;
|
|
98
|
+
const west = place.longitude - span;
|
|
99
|
+
const east = place.longitude + span;
|
|
100
|
+
return [west < -180 ? west + 360 : west, Math.max(-90, place.latitude - span), east > 180 ? east - 360 : east, Math.min(90, place.latitude + span)];
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export function initialMapFocus(place: MapPlace | null, savedViewport: unknown, transient = false) {
|
|
104
|
+
return place && !savedWorldMapViewport(savedViewport)
|
|
105
|
+
? { key: "initial-place", ...place, exact: true, ...(transient ? { transient: true } : {}) }
|
|
106
|
+
: null;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export function nearestPlaces<Row>(rows: readonly Row[], place: MapPlace | null, point: (row: Row) => { longitude: number; latitude: number }): Row[] {
|
|
110
|
+
if (!place) return [...rows];
|
|
111
|
+
const distance = (row: Row) => {
|
|
112
|
+
const location = point(row);
|
|
113
|
+
const radians = Math.PI / 180;
|
|
114
|
+
return Math.sin((location.latitude - place.latitude) * radians / 2) ** 2
|
|
115
|
+
+ Math.cos(place.latitude * radians) * Math.cos(location.latitude * radians)
|
|
116
|
+
* Math.sin((location.longitude - place.longitude) * radians / 2) ** 2;
|
|
117
|
+
};
|
|
118
|
+
return [...rows].sort((left, right) => distance(left) - distance(right));
|
|
119
|
+
}
|