@gloom-sh/terminal 0.20.16 → 0.20.18
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/data.ts +16 -5
- package/src/api-client/heard-from.ts +72 -0
- package/src/api-client/index.ts +63 -6
- package/src/api-client/mna.ts +18 -0
- package/src/api-client/supply-chain.ts +9 -0
- package/src/api-client/types/billing.ts +35 -1
- package/src/api-client/types/econ.ts +3 -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 +33 -2
- package/src/architecture/core-builtin-allowlist.json +1 -1
- package/src/architecture/floating-promise-allowlist.json +0 -1
- package/src/architecture/shortcut-labels-allowlist.json +1 -0
- package/src/cli/alert-listing.ts +98 -0
- package/src/cli/commands/fred-series.ts +3 -1
- package/src/cli/commands/market.ts +138 -22
- package/src/cli/commands/overview.ts +72 -14
- package/src/cli/commands/plugins.ts +3 -2
- package/src/cli/commands/search.ts +30 -6
- package/src/cli/context.ts +16 -5
- package/src/cli/csv-export.ts +74 -0
- package/src/cli/desktop-pane-shot.ts +75 -11
- package/src/cli/glossary.ts +64 -10
- package/src/cli/help.ts +4 -2
- package/src/cli/history-demergers.ts +117 -0
- package/src/cli/history-rows.ts +6 -2
- package/src/cli/index.ts +1 -0
- package/src/cli/known-gaps.ts +16 -0
- package/src/cli/known-us-stocks.ts +18 -0
- package/src/cli/listing-arg.ts +105 -15
- package/src/cli/pane-functions/catalog-snapshot-build.ts +83 -0
- package/src/cli/pane-functions/catalog-snapshot.json +866 -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 +24 -6
- package/src/cli/pane-functions/freshness.ts +17 -1
- package/src/cli/pane-functions/headless.ts +7 -2
- package/src/cli/pane-functions/index.ts +102 -44
- package/src/cli/pane-functions/resolver.ts +8 -5
- package/src/cli/pane-functions/screenshot-assessment.ts +30 -7
- package/src/cli/pane-functions/screenshot-bridge.ts +4 -2
- package/src/cli/pane-functions/screenshot-payload.ts +21 -0
- package/src/cli/pane-functions/screenshot-render.ts +3 -1
- package/src/cli/quote-answer.ts +32 -16
- package/src/cli/registry.ts +22 -2
- package/src/cli/report-tables.ts +17 -3
- package/src/cli/result.ts +8 -10
- package/src/cli/series-search.ts +45 -6
- package/src/cli/shot-temp-dir.ts +4 -9
- package/src/components/chart/composite/legend.tsx +80 -25
- package/src/components/chart/composite/panel-surface/panel-cursor.tsx +3 -3
- package/src/components/chart/composite/price-axis-labels.tsx +7 -5
- package/src/components/chart-table/header.tsx +9 -0
- package/src/components/chart-table/layout.ts +11 -11
- 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 +8 -1
- package/src/components/command-bar/routes/ticker-search/route.ts +5 -0
- package/src/components/command-bar/workflow/alert.ts +19 -8
- 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 +113 -15
- package/src/components/layout/pane/header.tsx +16 -2
- 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/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/display-columns.ts +4 -1
- package/src/components/ui/data-table/hooks.ts +2 -3
- package/src/components/ui/data-table/index.tsx +4 -1
- package/src/components/ui/data-table/types.ts +19 -4
- package/src/components/ui/data-table/visible-range.ts +11 -1
- 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 +2 -1
- 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 +103 -0
- package/src/market-data/depositary-pair.ts +6 -2
- package/src/market-data/hooks.tsx +33 -2
- package/src/market-data/market/change-basis.ts +2 -1
- package/src/market-data/market/header-market.ts +11 -0
- package/src/market-data/split-terms.ts +28 -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 +36 -30
- package/src/plugins/builtin/alerts/constants.ts +10 -0
- package/src/plugins/builtin/alerts/earnings-listing.ts +20 -0
- package/src/plugins/builtin/alerts/format.ts +24 -8
- package/src/plugins/builtin/alerts/index.tsx +38 -9
- package/src/plugins/builtin/alerts/move-checks.ts +7 -0
- package/src/plugins/builtin/alerts/pane.tsx +1 -1
- package/src/plugins/builtin/alerts/quotes.ts +26 -2
- package/src/plugins/builtin/alerts/scheduled.ts +6 -1
- package/src/plugins/builtin/alerts/types.ts +7 -0
- package/src/plugins/builtin/analytics/manual-value.ts +61 -0
- package/src/plugins/builtin/analytics/risk-book.ts +7 -7
- package/src/plugins/builtin/analytics/risk-client.ts +26 -13
- 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 +7 -3
- package/src/plugins/builtin/broker-trading/orders.tsx +2 -2
- 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/cli-options.ts +4 -2
- package/src/plugins/builtin/chart-composer/data-catalog-pane.tsx +2 -6
- package/src/plugins/builtin/chart-composer/pane.tsx +9 -3
- 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/company-kpis/headless.ts +9 -4
- package/src/plugins/builtin/company-kpis/latest.ts +45 -0
- package/src/plugins/builtin/company-kpis/model.ts +38 -8
- 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/correlation/index.tsx +13 -17
- package/src/plugins/builtin/correlation/matrix/model.ts +18 -0
- package/src/plugins/builtin/credit-conditions/series.ts +2 -2
- 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/earnings/board-model.ts +12 -0
- package/src/plugins/builtin/earnings/board-table.ts +7 -4
- package/src/plugins/builtin/earnings/board.tsx +2 -2
- package/src/plugins/builtin/earnings/fiscal-quarter.ts +39 -0
- package/src/plugins/builtin/earnings/headless.ts +7 -4
- package/src/plugins/builtin/earnings/highlight.ts +1 -1
- package/src/plugins/builtin/earnings/history-model.ts +6 -4
- package/src/plugins/builtin/earnings/history-table.ts +4 -3
- package/src/plugins/builtin/earnings-calls/pane.tsx +8 -2
- package/src/plugins/builtin/econ/calendar-model.ts +18 -0
- package/src/plugins/builtin/econ/fred-catalog.ts +1 -256
- package/src/plugins/builtin/econ/index.tsx +3 -0
- package/src/plugins/builtin/econ-statistics/cache.ts +1 -1
- package/src/plugins/builtin/econ-statistics/client.ts +11 -10
- package/src/plugins/builtin/econ-statistics/detail.tsx +1 -0
- package/src/plugins/builtin/econ-statistics/headless.ts +42 -6
- package/src/plugins/builtin/econ-statistics/index.tsx +1 -0
- package/src/plugins/builtin/econ-statistics/pane.tsx +7 -2
- package/src/plugins/builtin/econ-statistics/stats.ts +2 -1
- package/src/plugins/builtin/econ-statistics/view.ts +9 -3
- 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/fx-matrix/amount.ts +15 -1
- package/src/plugins/builtin/fx-matrix/headless.ts +12 -6
- package/src/plugins/builtin/fx-matrix/index.tsx +23 -5
- package/src/plugins/builtin/fx-matrix/settings.ts +9 -4
- 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/footer.ts +3 -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/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/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/relative-rotation/pane.tsx +2 -3
- package/src/plugins/builtin/research/corporate-actions-pane.tsx +5 -1
- package/src/plugins/builtin/research/event-model.ts +31 -13
- package/src/plugins/builtin/research/headless.ts +8 -1
- package/src/plugins/builtin/research/relative-valuation-pane.tsx +19 -17
- package/src/plugins/builtin/sectors/index.tsx +6 -9
- package/src/plugins/builtin/shared/cloud-upgrade.ts +1 -1
- package/src/plugins/builtin/shared/earnings-report.ts +19 -4
- package/src/plugins/builtin/shared/fred-catalog.ts +256 -0
- package/src/plugins/builtin/shared/report-freshness.ts +2 -3
- package/src/plugins/builtin/shared/series-cache.ts +3 -0
- package/src/plugins/builtin/shared/series-detail-chart.tsx +3 -0
- package/src/plugins/builtin/short-interest/watch-pane.tsx +7 -7
- 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 +76 -16
- 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 +67 -1
- package/src/plugins/builtin/ticker-detail/adr-pair/tab.tsx +31 -16
- package/src/plugins/builtin/ticker-detail/overview/model.ts +17 -1
- package/src/plugins/builtin/ticker-detail/overview/pane.tsx +4 -0
- package/src/plugins/builtin/ticker-detail/overview-tab.tsx +9 -2
- 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/time-sales/headless.ts +4 -1
- package/src/plugins/builtin/time-sales/pane.tsx +2 -0
- package/src/plugins/builtin/time-sales/window.ts +12 -0
- package/src/plugins/builtin/treasury-auctions/client.ts +4 -0
- package/src/plugins/builtin/treasury-auctions/treasury-direct.ts +2 -0
- package/src/plugins/builtin/treasury-daily/client.ts +23 -11
- package/src/plugins/builtin/volatility/model.ts +17 -0
- package/src/plugins/builtin/volatility/pane.tsx +13 -4
- 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 +28 -16
- 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/pane.tsx +35 -6
- package/src/plugins/builtin/world-venue-map/place.ts +119 -0
- 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/desktop/window-layouts.ts +14 -0
- 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-entry.tsx +2 -0
- package/src/renderers/electrobun/view/cli-pane-shot-frame.tsx +50 -12
- 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/fred-publisher.ts +25 -0
- package/src/sources/gloomberb-cloud/fred-series.ts +1 -1
- package/src/sources/gloomberb-cloud/index.ts +14 -3
- package/src/sources/gloomberb-cloud/perpetuals.ts +60 -3
- package/src/sources/provider-router/financials.ts +20 -13
- 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 +3 -0
- package/src/time-series/ice-credit.ts +1 -0
- package/src/time-series/resolve.ts +3 -1
- package/src/time-series/spec.ts +2 -2
- package/src/time-series/types.ts +2 -1
- package/src/types/data-provider.ts +11 -0
- package/src/types/financials.ts +39 -3
- package/src/types/headless.ts +4 -2
- package/src/types/ticker.ts +10 -2
- 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/forward-dividend.ts +4 -3
- package/src/utils/remove-folder.ts +37 -0
- package/src/utils/throttled-fetch.ts +15 -1
- 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";
|
|
11
|
+
import { columnValue, formatGeoValue, isChangeColumn, layerCoverageNote, parseLayerTokens, parseMapPreset, plainGeoValue, resolveActiveLayers, tickerLinkKey } from "./layers";
|
|
12
12
|
import { filterWorldVenues, formatVenueLocalTime } 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[] = [
|
|
@@ -49,13 +50,13 @@ const VENUE_COLUMNS: HeadlessPaneColumn[] = [
|
|
|
49
50
|
{ key: "localTime", header: "Local" },
|
|
50
51
|
];
|
|
51
52
|
|
|
52
|
-
async function venueRows(context: HeadlessPaneContext, query: string): Promise<HeadlessRowsResult> {
|
|
53
|
+
async function venueRows(context: HeadlessPaneContext, query: string, start: MapStart): Promise<HeadlessRowsResult> {
|
|
53
54
|
const response = await context.apiClient.getCloudWorldVenues();
|
|
54
55
|
if (!response.data) throw new Error(response.reasonCode ?? "World venue data unavailable");
|
|
55
56
|
const now = Date.now();
|
|
56
57
|
return {
|
|
57
58
|
columns: VENUE_COLUMNS,
|
|
58
|
-
rows: filterWorldVenues(response.data.venues, query).map((venue) => ({
|
|
59
|
+
rows: nearestPlaces(filterWorldVenues(response.data.venues, query), start.place, (venue) => venue).map((venue) => ({
|
|
59
60
|
mic: venue.mic,
|
|
60
61
|
name: venue.title,
|
|
61
62
|
city: venue.city,
|
|
@@ -66,7 +67,8 @@ async function venueRows(context: HeadlessPaneContext, query: string): Promise<H
|
|
|
66
67
|
lat: venue.latitude,
|
|
67
68
|
})),
|
|
68
69
|
freshness: REFERENCE_DATA,
|
|
69
|
-
|
|
70
|
+
errors: start.note ? [start.note] : [],
|
|
71
|
+
metadata: { layer: "venues", stale: response.stale === true, ...(start.place ? { place: start.place } : {}) },
|
|
70
72
|
};
|
|
71
73
|
}
|
|
72
74
|
|
|
@@ -141,9 +143,9 @@ export const mapHeadless = {
|
|
|
141
143
|
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
144
|
argument: {
|
|
143
145
|
kind: "free-text",
|
|
144
|
-
placeholder: "layers",
|
|
146
|
+
placeholder: "layers [place or lat,lon]",
|
|
145
147
|
optional: true,
|
|
146
|
-
description: "
|
|
148
|
+
description: "Layers (ships, ports, energy, air), then an optional place or latitude,longitude; home area when no place is given.",
|
|
147
149
|
},
|
|
148
150
|
options: [
|
|
149
151
|
{ key: "layer", aliases: ["layers"], settingKey: "layers", description: "Layer id or group to list, such as vessels or energy.", type: "string" },
|
|
@@ -156,18 +158,27 @@ export const mapHeadless = {
|
|
|
156
158
|
screenshotReadiness: "ready",
|
|
157
159
|
},
|
|
158
160
|
describe: (args, result) => {
|
|
159
|
-
const tokens = parseLayerTokens(args.options.layer
|
|
160
|
-
|
|
161
|
+
const tokens = parseLayerTokens(args.options.layer).length ? parseLayerTokens(args.options.layer) : parseMapPreset(typeof args.argument === "string" ? args.argument : "")?.layers ?? [];
|
|
162
|
+
const place = result?.metadata?.place as { label?: string } | undefined;
|
|
163
|
+
const near = place?.label ? ` | near ${place.label}` : "";
|
|
164
|
+
if (!tokens.length) return `World Map | venues${near}`;
|
|
161
165
|
// A layer of 7-day sums names the week they end on, which its source line dates without saying so.
|
|
162
166
|
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}`;
|
|
167
|
+
return `World Map | ${tokens.join(", ")}${near}${weekEnding}`;
|
|
164
168
|
},
|
|
165
169
|
async load(args, context) {
|
|
166
170
|
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
171
|
const request = contextGeoRequest(context);
|
|
170
172
|
const catalog = await loadGeoCatalog(request, { signal: context.signal });
|
|
173
|
+
const tokens = tokensFor(args, context.settings, catalog?.layers ?? []);
|
|
174
|
+
const typedPlace = parseMapPreset(typeof args.argument === "string" ? args.argument : "", catalog?.layers)?.place
|
|
175
|
+
?? (typeof context.settings?.place === "string" ? context.settings.place : mapHomeArea(context.config));
|
|
176
|
+
const start = await resolveMapPlace(typedPlace, {
|
|
177
|
+
request,
|
|
178
|
+
signal: context.signal,
|
|
179
|
+
venues: async () => (await context.apiClient.getCloudWorldVenues()).data?.venues ?? [],
|
|
180
|
+
});
|
|
181
|
+
if (!tokens.length) return venueRows(context, query, start);
|
|
171
182
|
const layers = resolveActiveLayers(tokens, catalog?.layers);
|
|
172
183
|
const layer = layers[0];
|
|
173
184
|
if (!layer) {
|
|
@@ -177,9 +188,9 @@ export const mapHeadless = {
|
|
|
177
188
|
const limit = typeof args.options.limit === "number" ? args.options.limit : 100;
|
|
178
189
|
const page = layer.status === "unavailable"
|
|
179
190
|
? { rows: [], total: 0, asOf: null, columns: layer.columns }
|
|
180
|
-
: await getGeoEntities(request, layer.id, { q: query, limit }, context.signal);
|
|
191
|
+
: await getGeoEntities(request, layer.id, { q: query, limit, ...(start.place ? { bbox: mapPlaceBbox(start.place) } : {}) }, context.signal);
|
|
181
192
|
const columns = page.columns?.length ? page.columns : layer.columns;
|
|
182
|
-
const rows: HeadlessPaneRow[] = page.rows.map((row) => ({
|
|
193
|
+
const rows: HeadlessPaneRow[] = nearestPlaces(page.rows, start.place, (row) => ({ longitude: row.lon, latitude: row.lat })).map((row) => ({
|
|
183
194
|
id: row.id,
|
|
184
195
|
...Object.fromEntries(columns.map((column) => [column.key, plainGeoValue(columnValue(row, column))])),
|
|
185
196
|
ticker: row.tickers?.[0] ? tickerLinkKey(row.tickers[0]) : null,
|
|
@@ -198,7 +209,7 @@ export const mapHeadless = {
|
|
|
198
209
|
...(empty ? { empty } : {}),
|
|
199
210
|
freshness: layerFreshness(layer),
|
|
200
211
|
complete: layer.status === "ok",
|
|
201
|
-
errors: layer.status === "unavailable" ? [`${layer.name}: ${layer.statusNote ?? "unavailable"}`] : [],
|
|
212
|
+
errors: [...(start.note ? [start.note] : []), ...(layer.status === "unavailable" ? [`${layer.name}: ${layer.statusNote ?? "unavailable"}`] : [])],
|
|
202
213
|
metadata: {
|
|
203
214
|
layer: layer.id,
|
|
204
215
|
name: layer.name,
|
|
@@ -206,6 +217,7 @@ export const mapHeadless = {
|
|
|
206
217
|
status: layer.status,
|
|
207
218
|
asOf,
|
|
208
219
|
total: page.total ?? null,
|
|
220
|
+
...(start.place ? { place: start.place, bbox: mapPlaceBbox(start.place) } : {}),
|
|
209
221
|
...("totals" in page && page.totals ? { totals: page.totals } : {}),
|
|
210
222
|
...("matched" in page && page.matched ? { matched: page.matched } : {}),
|
|
211
223
|
...(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) => {
|
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { GloomPlugin } from "../types/plugin";
|
|
2
|
+
import type { LoadedExternalPlugin } from "./loader";
|
|
3
|
+
import { loadBuiltinPlugin } from "./catalog-lazy";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* The built-in plugins that contribute an `asset-data` or `news` capability, which is all a command that reads
|
|
7
|
+
* market data needs from the plugins it runs with. Naming them here keeps such a command from loading every
|
|
8
|
+
* other plugin's panes; `catalog-data.test.ts` fails when a plugin outside this list declares one.
|
|
9
|
+
*/
|
|
10
|
+
export const BUILTIN_DATA_PLUGIN_IDS: readonly string[] = ["gloomberb-cloud"];
|
|
11
|
+
|
|
12
|
+
/** The built-in data plugins and the installed plugins that loaded, which may carry data capabilities of their own. */
|
|
13
|
+
export function getLoadableDataPlugins(externalPlugins: LoadedExternalPlugin[] = []): GloomPlugin[] {
|
|
14
|
+
return [
|
|
15
|
+
...BUILTIN_DATA_PLUGIN_IDS.flatMap((id) => loadBuiltinPlugin(id) ?? []),
|
|
16
|
+
...externalPlugins
|
|
17
|
+
.filter((entry) => !entry.needsRestart && !entry.error && !entry.unsupportedTarget)
|
|
18
|
+
.map((entry) => entry.plugin),
|
|
19
|
+
];
|
|
20
|
+
}
|