gloomberb 0.20.1 → 0.20.2
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/README.md +16 -26
- package/README.zh-CN.md +21 -65
- package/package.json +1 -1
- package/src/account/auth-model.ts +20 -1
- package/src/account/upgrade-dialog.tsx +8 -4
- package/src/api-client/askg.ts +7 -1
- package/src/api-client/auth.ts +27 -0
- package/src/api-client/catalysts.ts +2 -0
- package/src/api-client/company-kpis.ts +2 -1
- package/src/api-client/cot.ts +14 -2
- package/src/api-client/data.ts +3 -2
- package/src/api-client/earnings.ts +46 -3
- package/src/api-client/futures-curve.ts +17 -0
- package/src/api-client/index.ts +4 -1
- package/src/api-client/one-tap-reasons.ts +42 -0
- package/src/api-client/perps.ts +2 -1
- package/src/api-client/request.ts +3 -1
- package/src/api-client/research-activity.ts +16 -3
- package/src/api-client/types/filings-and-calls.ts +3 -0
- package/src/api-client/types/search.ts +3 -0
- package/src/app/keybindings/chord.ts +153 -9
- package/src/app/keybindings/index.ts +1 -1
- package/src/app/keybindings/labels.ts +49 -6
- package/src/app/runtime/desktop-deeplink.ts +73 -8
- package/src/app.tsx +7 -1
- package/src/architecture/core-builtin-allowlist.json +1 -2
- package/src/architecture/pane-tabs-allowlist.json +2 -1
- package/src/architecture/shortcut-labels-allowlist.json +11 -0
- package/src/architecture/ui-literals-allowlist.json +8 -8
- package/src/brokers/broker-portfolio-sync.ts +1 -1
- package/src/cli/bank-section.ts +26 -12
- package/src/cli/commands/market.ts +266 -75
- package/src/cli/commands/ticker.ts +12 -7
- package/src/cli/desktop-pane-shot-browser.ts +47 -31
- package/src/cli/desktop-pane-shot.ts +15 -0
- package/src/cli/entry.ts +5 -0
- package/src/cli/export-source.ts +7 -1
- package/src/cli/freshness.ts +0 -16
- package/src/cli/fx-pair.ts +64 -12
- package/src/cli/fx-quote-rate.ts +144 -0
- package/src/cli/glossary.ts +5 -0
- package/src/cli/history-back-adjust.ts +122 -0
- package/src/cli/history-rows.ts +114 -10
- package/src/cli/index.ts +4 -1
- package/src/cli/known-gaps.ts +45 -3
- package/src/cli/listing-arg.ts +48 -4
- package/src/cli/name-entries.ts +25 -5
- package/src/cli/pane-functions/catalog.ts +12 -2
- package/src/cli/pane-functions/dom.ts +4 -2
- package/src/cli/pane-functions/headless.ts +8 -5
- package/src/cli/pane-functions/index.ts +3 -0
- package/src/cli/pane-functions/resolver.ts +4 -1
- package/src/cli/pane-functions/screenshot-assessment.ts +15 -3
- package/src/cli/pane-functions/screenshot-payload.ts +130 -66
- package/src/cli/pane-functions/screenshot-render.ts +14 -2
- package/src/cli/pane-functions/screenshot-types.ts +4 -0
- package/src/cli/symbol-rows.ts +22 -2
- package/src/cli/ticker-resolution.ts +74 -17
- package/src/components/chart/composite/axis-overlays.tsx +13 -3
- package/src/components/chart/composite/composite-chart.tsx +8 -1
- package/src/components/chart/composite/format.ts +16 -1
- package/src/components/chart/composite/legend.tsx +4 -3
- package/src/components/chart/composite/panel-labels.ts +2 -1
- package/src/components/chart/composite/panel-surface.tsx +33 -4
- package/src/components/chart/composite/time-scale.ts +1 -1
- package/src/components/chart/composite/toolbar.tsx +8 -4
- package/src/components/chart/composite/types.ts +17 -1
- package/src/components/chart/composite/use-composite-chart-keyboard.ts +15 -5
- package/src/components/chart/composite/use-composite-viewport.ts +31 -8
- package/src/components/chart/static/scatter-chart-surface.tsx +25 -9
- package/src/components/chart-table/axis.ts +11 -0
- package/src/components/command-bar/assist/inventory.ts +3 -2
- package/src/components/command-bar/commands/collection-list.ts +3 -2
- package/src/components/command-bar/panel/layout.ts +8 -1
- package/src/components/command-bar/panel/prompt-width.ts +34 -0
- package/src/components/command-bar/panel/state.ts +4 -0
- package/src/components/command-bar/routes/root/search-providers.ts +3 -2
- package/src/components/command-bar/routes/root/search-report.ts +2 -2
- package/src/components/command-bar/workflow/ticker-listing-picker.ts +1 -0
- package/src/components/company-logo.tsx +2 -2
- package/src/components/data-table/view.tsx +11 -2
- package/src/components/feed-data-table/stack-view.tsx +20 -6
- package/src/components/feedback-dialog.tsx +3 -1
- package/src/components/form-modal/field-row.tsx +1 -1
- package/src/components/form-modal/routes.ts +1 -0
- package/src/components/index.ts +1 -1
- package/src/components/layout/header.tsx +12 -3
- package/src/components/layout/market-summary.ts +2 -1
- package/src/components/layout/pane/footer/index.tsx +9 -5
- package/src/components/layout/pane/footer/model.ts +26 -10
- package/src/components/layout/pane/footer/registration.tsx +60 -1
- package/src/components/layout/pane/header-tabs.tsx +17 -3
- package/src/components/layout/pane/header.tsx +5 -2
- package/src/components/layout/pane/pane-tabs.tsx +57 -3
- package/src/components/layout/shell/active-drag.ts +38 -30
- package/src/components/layout/shell/drag/index.ts +51 -21
- package/src/components/layout/shell/menu.ts +3 -5
- package/src/components/layout/shell/pane/actions.ts +4 -1
- package/src/components/layout/shell/pane/ask.ts +5 -2
- package/src/components/layout/status-bar.tsx +59 -54
- package/src/components/markdown-text.tsx +35 -10
- package/src/components/onboarding/first-run-workspace.ts +25 -23
- package/src/components/onboarding/onboarding-keyboard.ts +6 -1
- package/src/components/onboarding/onboarding-wizard.tsx +12 -2
- package/src/components/onboarding/portfolio-step/positions-panel.tsx +3 -3
- package/src/components/onboarding/use-onboarding-broker-form.ts +2 -1
- package/src/components/onboarding/use-onboarding-progress.ts +11 -4
- package/src/components/onboarding/use-onboarding-upgrade.ts +3 -2
- package/src/components/onboarding/wizard-positions.ts +8 -1
- package/src/components/pane-notice-seen.ts +125 -0
- package/src/components/pane-settings-dialog/field-dialogs.tsx +2 -1
- package/src/components/pane-settings-dialog.tsx +7 -6
- package/src/components/sign-in-code-panel.tsx +3 -2
- package/src/components/speedometer-gauge/terminal.tsx +30 -9
- package/src/components/ticker/list-table-view.tsx +39 -3
- package/src/components/ui/confirm-dialog.tsx +2 -1
- package/src/components/ui/data-table/index.tsx +4 -2
- package/src/components/ui/data-table/opentui/index.tsx +15 -5
- package/src/components/ui/data-table/types.ts +8 -0
- package/src/components/ui/external-link.tsx +4 -1
- package/src/components/ui/field-grid.tsx +1 -1
- package/src/components/ui/index.ts +2 -0
- package/src/components/ui/inline-quick-add.tsx +5 -0
- package/src/components/ui/multi-select/dialog.tsx +10 -9
- package/src/components/ui/pane-link-chip.tsx +354 -0
- package/src/components/ui/query-bar.tsx +22 -13
- package/src/components/ui/ratio-bar.tsx +24 -1
- package/src/components/ui/select-button.tsx +2 -1
- package/src/components/ui/shortcut-hint.tsx +6 -3
- package/src/components/ui/table-layout.ts +81 -0
- package/src/components/ui/tabs.tsx +45 -6
- package/src/components/use-pane-notice-footer.tsx +12 -4
- package/src/core/app-service-ports.ts +1 -1
- package/src/data/plugin-state-store.ts +44 -8
- package/src/docs/snapshot.json +53 -32
- package/src/i18n/es.ts +25 -6
- package/src/i18n/ja.ts +25 -5
- package/src/i18n/ko.ts +25 -5
- package/src/i18n/zh-cn.ts +25 -5
- package/src/i18n/zh-tw.ts +25 -5
- package/src/layout/pane-manager/gridlock-inference.ts +2 -1
- package/src/layout/pane-manager/gridlock.ts +47 -2
- package/src/layout-marketplace/api.ts +1 -0
- package/src/layout-marketplace/gallery.tsx +4 -3
- package/src/layout-marketplace/linked.ts +6 -4
- package/src/layout-marketplace/model.ts +3 -2
- package/src/market-data/futures-contract.ts +77 -31
- package/src/market-data/fx-closes.ts +5 -2
- package/src/market-data/hooks.tsx +23 -0
- package/src/market-data/market/change-basis.ts +72 -14
- package/src/market-data/market/format.ts +19 -11
- package/src/market-data/market/globex-day.ts +73 -0
- package/src/market-data/market/index-level.ts +10 -1
- package/src/market-data/quotes/intraday-bar.ts +1 -1
- package/src/market-data/quotes/session-split.ts +28 -0
- package/src/plugins/builtin/account-management/pane.tsx +1 -1
- package/src/plugins/builtin/analytics/account-returns.ts +1 -1
- package/src/plugins/builtin/analytics/index.tsx +10 -3
- package/src/plugins/builtin/analytics/pane-model.ts +1 -1
- package/src/plugins/builtin/analytics/risk-client.ts +4 -1
- package/src/plugins/builtin/analytics/risk-episodes.ts +422 -0
- package/src/plugins/builtin/analytics/risk-fx.ts +1 -1
- package/src/plugins/builtin/analytics/risk-headless.ts +28 -10
- package/src/plugins/builtin/analytics/risk-math.ts +1 -1
- package/src/plugins/builtin/analytics/risk-model.ts +115 -26
- package/src/plugins/builtin/analytics/risk-pane.tsx +201 -23
- package/src/plugins/builtin/analytics/sharpe-cadence.ts +1 -1
- package/src/plugins/builtin/backtest/format.ts +14 -0
- package/src/plugins/builtin/backtest/pane.tsx +3 -3
- package/src/plugins/builtin/backtest/report.ts +5 -3
- package/src/plugins/builtin/broker-manager/add-request.ts +10 -1
- package/src/plugins/builtin/broker-trading/pane.tsx +20 -2
- package/src/plugins/builtin/buildout/company/flow.tsx +5 -5
- package/src/plugins/builtin/buildout/company/model.ts +14 -2
- package/src/plugins/builtin/catalysts/detail.tsx +2 -2
- package/src/plugins/builtin/catalysts/model.ts +7 -2
- package/src/plugins/builtin/catalysts/pane.tsx +2 -2
- package/src/plugins/builtin/chat/message/pane-chip.tsx +36 -208
- package/src/plugins/builtin/cloud/askg/answer-follow-ups.tsx +61 -0
- package/src/plugins/builtin/cloud/askg/answer-sources.tsx +102 -0
- package/src/plugins/builtin/cloud/askg/controller.ts +7 -1
- package/src/plugins/builtin/cloud/askg/host.ts +57 -0
- package/src/plugins/builtin/cloud/askg/model.ts +45 -5
- package/src/plugins/builtin/cloud/askg/pane.tsx +304 -25
- package/src/plugins/builtin/cloud/askg/protocol.ts +26 -1
- package/src/plugins/builtin/cloud/askg/sources.ts +466 -0
- package/src/plugins/builtin/cloud/one-tap/controller.ts +309 -0
- package/src/plugins/builtin/cloud/one-tap/google-identity.ts +142 -0
- package/src/plugins/builtin/cloud/one-tap/one-tap-prompt.tsx +101 -0
- package/src/plugins/builtin/cloud/plugin.tsx +7 -1
- package/src/plugins/builtin/company-kpis/client.ts +4 -3
- package/src/plugins/builtin/company-kpis/model.ts +34 -3
- package/src/plugins/builtin/correlation/index.tsx +39 -167
- package/src/plugins/builtin/correlation/matrix/grid.tsx +285 -0
- package/src/plugins/builtin/correlation/relationship/pane.tsx +6 -7
- package/src/plugins/builtin/correlation/relationship/view-model.ts +14 -5
- package/src/plugins/builtin/cot/client.ts +8 -3
- package/src/plugins/builtin/cot/headless.ts +65 -12
- package/src/plugins/builtin/cot/pane.tsx +11 -5
- package/src/plugins/builtin/earnings/client.ts +40 -6
- package/src/plugins/builtin/earnings/fiscal-quarter.ts +54 -0
- package/src/plugins/builtin/earnings/headless.ts +47 -11
- package/src/plugins/builtin/earnings/history-model.ts +136 -24
- package/src/plugins/builtin/earnings/history-table.ts +42 -10
- package/src/plugins/builtin/earnings/history.tsx +23 -8
- package/src/plugins/builtin/earnings-ripple/client.ts +5 -2
- package/src/plugins/builtin/earnings-ripple/headless.ts +8 -3
- package/src/plugins/builtin/earnings-ripple/model.ts +21 -0
- package/src/plugins/builtin/earnings-ripple/pane.tsx +2 -3
- package/src/plugins/builtin/econ/index.tsx +5 -4
- package/src/plugins/builtin/econ-statistics/stats.ts +13 -5
- package/src/plugins/builtin/equity-screener/headless.ts +2 -1
- package/src/plugins/builtin/filing-events/feed.ts +56 -18
- package/src/plugins/builtin/filing-events/pane.tsx +8 -2
- package/src/plugins/builtin/futures/index.tsx +32 -10
- package/src/plugins/builtin/futures/model.ts +93 -6
- package/src/plugins/builtin/futures/returns.ts +29 -7
- package/src/plugins/builtin/futures/table.tsx +59 -17
- package/src/plugins/builtin/futures/use-front-returns.ts +32 -6
- package/src/plugins/builtin/futures-curve/client.ts +12 -2
- package/src/plugins/builtin/futures-curve/headless.ts +58 -17
- package/src/plugins/builtin/futures-curve/model.ts +111 -15
- package/src/plugins/builtin/futures-curve/pane.tsx +11 -6
- package/src/plugins/builtin/fx-matrix/amount.ts +132 -0
- package/src/plugins/builtin/fx-matrix/headless.ts +53 -13
- package/src/plugins/builtin/fx-matrix/index.tsx +205 -42
- package/src/plugins/builtin/fx-matrix/pairs.ts +10 -8
- package/src/plugins/builtin/fx-matrix/settings.ts +22 -1
- package/src/plugins/builtin/help/index.tsx +68 -61
- package/src/plugins/builtin/holders/format.ts +7 -2
- package/src/plugins/builtin/holders/pane.tsx +11 -3
- package/src/plugins/builtin/holders/report-header.ts +5 -4
- package/src/plugins/builtin/holders/report-rows.ts +4 -1
- package/src/plugins/builtin/holders/treemap.tsx +5 -3
- package/src/plugins/builtin/insider/signals-model.ts +4 -5
- package/src/plugins/builtin/ipo-calendar/headless.ts +18 -7
- package/src/plugins/builtin/ipo-calendar/listing-ipo.ts +3 -1
- package/src/plugins/builtin/ipo-calendar/model.ts +28 -8
- package/src/plugins/builtin/ipo-calendar/pane.tsx +2 -1
- package/src/plugins/builtin/kelly-sizer/headless.ts +4 -0
- package/src/plugins/builtin/perps/headless.ts +73 -17
- package/src/plugins/builtin/perps/index.tsx +3 -1
- package/src/plugins/builtin/perps/model.ts +1 -1
- package/src/plugins/builtin/perps/pane.tsx +2 -0
- package/src/plugins/builtin/portfolio-list/cell-version.ts +1 -0
- package/src/plugins/builtin/portfolio-list/cli/bulk-symbols.ts +20 -1
- package/src/plugins/builtin/portfolio-list/cli/import-positions.ts +260 -0
- package/src/plugins/builtin/portfolio-list/cli/period-report.ts +154 -0
- package/src/plugins/builtin/portfolio-list/cli/portfolio-command.ts +64 -22
- package/src/plugins/builtin/portfolio-list/cli/render.ts +18 -7
- package/src/plugins/builtin/portfolio-list/cli/watchlist-command.ts +5 -3
- package/src/plugins/builtin/portfolio-list/grid.tsx +56 -12
- package/src/plugins/builtin/portfolio-list/headless.ts +128 -0
- package/src/plugins/builtin/portfolio-list/pane/index.tsx +42 -4
- package/src/plugins/builtin/portfolio-list/pane/period-pnl.ts +124 -0
- package/src/plugins/builtin/portfolio-list/period-pnl.ts +179 -0
- package/src/plugins/builtin/portfolio-list/positions-import/dialog.tsx +445 -0
- package/src/plugins/builtin/portfolio-list/positions-import/index.tsx +255 -0
- package/src/plugins/builtin/portfolio-list/positions-import/lookup.ts +78 -0
- package/src/plugins/builtin/portfolio-list/positions-import/read-file.ts +32 -0
- package/src/plugins/builtin/portfolio-list/quick-add/index.tsx +186 -50
- package/src/plugins/builtin/portfolio-list/quick-add/resolution.ts +118 -4
- package/src/plugins/builtin/portfolio-list/settings.ts +25 -0
- package/src/plugins/builtin/portfolio-list/summary/index.tsx +16 -1
- package/src/plugins/builtin/portfolio-list/summary/totals.ts +7 -5
- package/src/plugins/builtin/portfolio-list/table.tsx +105 -6
- package/src/plugins/builtin/power/headless.ts +47 -9
- package/src/plugins/builtin/research/relative-valuation-model.ts +8 -3
- package/src/plugins/builtin/research-search/article.ts +12 -2
- package/src/plugins/builtin/research-search/data.ts +5 -2
- package/src/plugins/builtin/research-search/document-view.tsx +1 -1
- package/src/plugins/builtin/research-search/model.ts +47 -3
- package/src/plugins/builtin/research-search/pane.tsx +3 -2
- package/src/plugins/builtin/reverse-dcf/model.ts +7 -4
- package/src/plugins/builtin/risk-factors/headless.ts +3 -2
- package/src/plugins/builtin/risk-factors/pane.tsx +5 -3
- package/src/plugins/builtin/scanner/flow-model.ts +17 -13
- package/src/plugins/builtin/scanner/flow-pane.tsx +8 -9
- package/src/plugins/builtin/scanner/flow-session.ts +2 -9
- package/src/plugins/builtin/sec/filing-display.tsx +0 -5
- package/src/plugins/builtin/sec/forms.ts +19 -0
- package/src/plugins/builtin/sec/headless.ts +7 -11
- package/src/plugins/builtin/sec/index.tsx +11 -3
- package/src/plugins/builtin/shared/earnings-calendar.ts +6 -3
- package/src/plugins/builtin/shared/earnings-report.ts +1 -1
- package/src/plugins/builtin/shared/fx-rate-freshness.ts +0 -35
- package/src/plugins/builtin/shared/use-quote-board.ts +42 -27
- package/src/plugins/builtin/supply-chain/graph-model.ts +7 -1
- package/src/plugins/builtin/supply-chain/headless.ts +20 -10
- package/src/plugins/builtin/supply-chain/model.ts +117 -20
- package/src/plugins/builtin/supply-chain/pane.tsx +22 -15
- package/src/plugins/builtin/supply-chain/row-evidence.tsx +1 -1
- package/src/plugins/builtin/ticker-detail/data-panes/returns-chart-model.ts +69 -0
- package/src/plugins/builtin/ticker-detail/data-panes/returns-chart.tsx +118 -0
- package/src/plugins/builtin/ticker-detail/data-panes/returns-model.ts +1 -1
- package/src/plugins/builtin/ticker-detail/data-panes/returns-pane.tsx +103 -40
- package/src/plugins/builtin/ticker-detail/headless-schema.ts +10 -1
- package/src/plugins/builtin/ticker-detail/headless.ts +8 -1
- package/src/plugins/builtin/ticker-detail/overview/components.tsx +2 -1
- package/src/plugins/builtin/ticker-detail/overview/model.ts +4 -2
- package/src/plugins/builtin/ticker-detail/overview-tab.tsx +11 -8
- package/src/plugins/builtin/ticker-detail/pane.tsx +95 -20
- package/src/plugins/builtin/ticker-detail/research-groups.ts +89 -0
- package/src/plugins/builtin/ticker-detail/settings.ts +4 -3
- package/src/plugins/builtin/volatility/charts.tsx +2 -2
- package/src/plugins/host-resolver.ts +3 -2
- package/src/portfolio/column-values.ts +42 -8
- package/src/portfolio/futures-positions.ts +10 -2
- package/src/portfolio/mutations.ts +4 -3
- package/src/portfolio/period-pnl.ts +119 -0
- package/src/portfolio/positions-import/describe.ts +89 -0
- package/src/portfolio/positions-import/parse.ts +682 -0
- package/src/portfolio/positions-import/plan.ts +295 -0
- package/src/{plugins/builtin/analytics/metrics.ts → portfolio/return-metrics.ts} +24 -11
- package/src/public/__snapshots__/public-api.test.ts.snap +1 -0
- package/src/react/jsx-dev-fallback.ts +62 -0
- package/src/renderers/browser/cloud-transport.ts +1 -1
- package/src/renderers/browser/config-host.ts +3 -1
- package/src/renderers/browser/deeplink-bridge.ts +8 -1
- package/src/renderers/browser/http-proxy-transport.ts +9 -2
- package/src/renderers/browser/main.tsx +2 -1
- package/src/renderers/browser/research-entry.ts +12 -0
- package/src/renderers/cloudflare/http-proxy.ts +8 -2
- package/src/renderers/cloudflare/proxy-session.ts +1 -0
- package/src/renderers/cloudflare/worker.ts +12 -3
- package/src/renderers/dom/desktop/audio-player.tsx +2 -2
- package/src/renderers/dom/desktop/controls.tsx +1 -1
- package/src/renderers/dom/desktop/dialog-actions.tsx +10 -24
- package/src/renderers/dom/desktop/icons.tsx +4 -2
- package/src/renderers/dom/desktop/query-bar.tsx +23 -19
- package/src/renderers/dom/dom-host-providers.tsx +7 -2
- package/src/renderers/dom/host/box.tsx +2 -2
- package/src/renderers/dom/host/input.tsx +13 -0
- package/src/renderers/dom/key-event.ts +1 -0
- package/src/renderers/dom/styles.css +3 -0
- package/src/renderers/electrobun/bun/context-menu/click.ts +1 -0
- package/src/renderers/electrobun/bun/desktop/backend.ts +1 -0
- package/src/renderers/electrobun/bun/desktop/capability-bridge.ts +5 -4
- package/src/renderers/electrobun/bun/desktop/host-requests.ts +5 -4
- package/src/renderers/electrobun/bun/desktop/http-fetch.ts +1 -0
- package/src/renderers/electrobun/bun/desktop/http-stream.ts +1 -1
- package/src/renderers/electrobun/bun/desktop/initialization.ts +3 -1
- package/src/renderers/electrobun/bun/desktop/install-records.ts +4 -1
- package/src/renderers/electrobun/bun/desktop/installer-folder.ts +5 -2
- package/src/renderers/electrobun/bun/desktop/macos-objc.ts +3 -1
- package/src/renderers/electrobun/bun/desktop/screen-setup-file.ts +9 -4
- package/src/renderers/electrobun/bun/desktop/update.ts +27 -13
- package/src/renderers/electrobun/bun/desktop/windows-script.ts +6 -2
- package/src/renderers/electrobun/bun/window/attention.ts +1 -0
- package/src/renderers/electrobun/bun/window/boot-frame.ts +1 -0
- package/src/renderers/electrobun/bun/window/create.ts +1 -0
- package/src/renderers/electrobun/bun/window/electrobun-window-host.ts +13 -8
- package/src/renderers/electrobun/bun/window/native-min-size.ts +1 -1
- package/src/renderers/electrobun/bun/window/remembered-frame.ts +1 -0
- package/src/renderers/electrobun/bun/window/windows-native.ts +3 -1
- package/src/renderers/electrobun/bun/window/windows-quit.ts +3 -1
- package/src/renderers/electrobun/view/app-badge-host.ts +2 -1
- package/src/renderers/electrobun/view/capability-subscription.ts +2 -1
- package/src/renderers/electrobun/view/cli-pane-shot-entry.tsx +7 -10
- package/src/renderers/electrobun/view/cli-pane-shot-mutations.ts +36 -0
- package/src/renderers/electrobun/view/http-fetch.ts +2 -1
- package/src/renderers/electrobun/view/main.tsx +9 -4
- package/src/renderers/electrobun/view/remote/capability-invoker.ts +6 -3
- package/src/renderers/electrobun/view/remote/persistence.ts +63 -27
- package/src/renderers/electrobun/view/rpc-timeout.ts +1 -0
- package/src/renderers/electrobun/view/ui-host.tsx +3 -2
- package/src/renderers/electrobun/view/window-fullscreen.ts +3 -1
- package/src/renderers/opentui/browser-open.ts +2 -1
- package/src/renderers/opentui/dialog-host.tsx +1 -1
- package/src/renderers/opentui/interaction-performance.ts +3 -1
- package/src/renderers/opentui/start.tsx +2 -1
- package/src/renderers/opentui/terminal-media.ts +11 -6
- package/src/renderers/opentui/ui-host.tsx +5 -8
- package/src/shares/open.ts +22 -1
- package/src/shares/pane.ts +2 -1
- package/src/sources/gloomberb-cloud/normalizers.ts +3 -0
- package/src/sync/analytics-payload.ts +194 -0
- package/src/sync/baseline.ts +19 -9
- package/src/sync/broker-identity.ts +171 -0
- package/src/sync/broker-instances.ts +137 -0
- package/src/sync/collections-contributor.ts +173 -0
- package/src/sync/config-contributor.ts +100 -0
- package/src/sync/config-merge.ts +229 -0
- package/src/sync/controller.ts +139 -28
- package/src/sync/core-contributors.ts +8 -1583
- package/src/sync/history-memo.ts +32 -0
- package/src/sync/layout-merge.ts +259 -0
- package/src/sync/sanitize.ts +114 -0
- package/src/sync/ticker-merge.ts +208 -0
- package/src/sync/ticker-payload.ts +81 -0
- package/src/sync/types.ts +15 -1
- package/src/telemetry/attention-setting.ts +1 -1
- package/src/telemetry/usage-counts.ts +16 -0
- package/src/test-support/preload.ts +5 -0
- package/src/theme/color-utils.ts +10 -0
- package/src/theme/font-scale.ts +34 -3
- package/src/theme/series-colors.ts +44 -0
- package/src/theme/themes.ts +2 -1
- package/src/tickers/batched-lookups.ts +263 -6
- package/src/tickers/company-name-listing.ts +44 -2
- package/src/tickers/company-name.ts +7 -2
- package/src/tickers/search/upsert.ts +16 -1
- package/src/time-series/base-series.ts +18 -4
- package/src/time-series/studies/indicators.ts +3 -1
- package/src/time-series/studies/resolve.ts +1 -1
- package/src/time-series/types.ts +6 -0
- package/src/types/financials.ts +18 -0
- package/src/types/headless.ts +11 -0
- package/src/ui/host.tsx +26 -3
- package/src/ui/index.tsx +1 -0
- package/src/utils/concurrency.ts +6 -0
- package/src/utils/currency-pair.ts +56 -4
- package/src/utils/datetime-format.ts +11 -0
- package/src/utils/decimal-comma.ts +9 -6
- package/src/utils/exchanges.ts +32 -0
- package/src/utils/fundamentals.ts +41 -0
- package/src/utils/markdown.ts +4 -2
- package/src/utils/pasted-lines.ts +14 -0
- package/src/utils/price-window.ts +2 -1
- package/src/utils/sec-filings.ts +17 -0
- package/src/utils/sec.ts +4 -23
- package/src/utils/shortcut-labels.ts +6 -30
|
@@ -2,7 +2,7 @@ import { logFailure } from "../utils/log-failure";
|
|
|
2
2
|
import type { DataProvider } from "../types/data-provider";
|
|
3
3
|
import type { Quote } from "../types/financials";
|
|
4
4
|
import type { InstrumentSearchResult } from "../types/instrument";
|
|
5
|
-
import { canonicalExchange, isUsListingExchange, parsePublicTickerKey } from "../utils/exchanges";
|
|
5
|
+
import { canonicalExchange, isUsEquityExchange, isUsListingExchange, parsePublicTickerKey } from "../utils/exchanges";
|
|
6
6
|
import { companyLines, companyNameExtraWords, companyNameMatch, namedByService, runTogether, shortCompanyName } from "./company-name";
|
|
7
7
|
import { LISTING_SEARCH_LIMIT } from "./search";
|
|
8
8
|
import { lineDistance, primaryCompanyLine } from "./search/home-listing";
|
|
@@ -10,6 +10,7 @@ import { classifyInstrumentKind, isCryptoInstrumentType } from "./search/ranking
|
|
|
10
10
|
import { isProviderBusy, type ProviderBusyError } from "../sources/provider-errors";
|
|
11
11
|
import { readTerminalListingCode, type TerminalListing, type TerminalListingCode } from "./terminal-codes";
|
|
12
12
|
import { hasNonLatinLetters } from "../utils/typed-text";
|
|
13
|
+
import { formerIssuerLine } from "./ticker-changes";
|
|
13
14
|
|
|
14
15
|
export interface CompanyNameListing {
|
|
15
16
|
symbol: string;
|
|
@@ -47,6 +48,12 @@ export type MovedLineLookup = (
|
|
|
47
48
|
const NOT_COMMON = /preferred|warrant|right|unit|note|bond|debenture/i;
|
|
48
49
|
const RECEIPT = /depositary|^(?:ADR|ADS|GDR|CDR|BDR)$/i;
|
|
49
50
|
|
|
51
|
+
/** The searches `findListingOfCompanyName` asks for a name: as typed, and without its legal form. */
|
|
52
|
+
export function companyNameQueries(typed: string): string[] {
|
|
53
|
+
const name = typed.trim();
|
|
54
|
+
return [...new Set([name, shortCompanyName(name)])].filter(Boolean);
|
|
55
|
+
}
|
|
56
|
+
|
|
50
57
|
/** A list entry with a space inside is a company's name, never a symbol: "Whirlpool Corporation". */
|
|
51
58
|
export function isCompanyNameInput(input: string): boolean {
|
|
52
59
|
return /\S\s+\S/.test(input.trim());
|
|
@@ -96,7 +103,7 @@ export async function findListingOfCompanyName(
|
|
|
96
103
|
): Promise<CompanyNameListing | null> {
|
|
97
104
|
const name = typed.trim();
|
|
98
105
|
if (!name) return null;
|
|
99
|
-
const queries =
|
|
106
|
+
const queries = companyNameQueries(name);
|
|
100
107
|
const answers = await Promise.all(queries.map((query) => searchListings(dataProvider, query)));
|
|
101
108
|
const busy = answers.find(isProviderBusy);
|
|
102
109
|
const results = answers.flatMap((answer) => Array.isArray(answer) ? answer : []);
|
|
@@ -160,6 +167,31 @@ export async function findListingOfCompanyName(
|
|
|
160
167
|
return meant ? { ...found, meant } : found;
|
|
161
168
|
}
|
|
162
169
|
|
|
170
|
+
/**
|
|
171
|
+
* A company that merged away, found by its old name typed where a symbol goes
|
|
172
|
+
* ("Comerica"): search lists the company it merged into with the old one as
|
|
173
|
+
* its former issuer (FITB, formerly CMA, COMERICA INC). Its line, as `search`
|
|
174
|
+
* says it ("CMA was COMERICA until 2026, now Fifth Third Bancorp: FITB"), and
|
|
175
|
+
* the symbol it trades as now. Null when no row's former issuer is the name
|
|
176
|
+
* typed, and when search fails or is busy.
|
|
177
|
+
*/
|
|
178
|
+
export async function findFormerIssuerOfName(
|
|
179
|
+
dataProvider: Pick<DataProvider, "search">,
|
|
180
|
+
typed: string,
|
|
181
|
+
): Promise<{ note: string; successor: string } | null> {
|
|
182
|
+
const name = typed.trim();
|
|
183
|
+
if (!/\p{L}/u.test(name)) return null;
|
|
184
|
+
const answer = await searchListings(dataProvider, name);
|
|
185
|
+
if (!Array.isArray(answer)) return null;
|
|
186
|
+
for (const result of answer) {
|
|
187
|
+
const former = result.formerIssuer;
|
|
188
|
+
if (!former?.symbol || !former.name || !former.until || !companyNameMatch(name, former.name)) continue;
|
|
189
|
+
const successor = former.successor?.symbol?.trim() ? former.successor : { symbol: result.symbol, name: result.name };
|
|
190
|
+
return { note: formerIssuerLine(former.symbol, former, successor), successor: successor.symbol.toUpperCase() };
|
|
191
|
+
}
|
|
192
|
+
return null;
|
|
193
|
+
}
|
|
194
|
+
|
|
163
195
|
/** The ranks that say how near a listing's name is to the one typed, and whether it is a stock: one company's lines share them. */
|
|
164
196
|
const NAME_RANKS = 3;
|
|
165
197
|
|
|
@@ -206,6 +238,16 @@ async function firstQuoted<T extends RankedListing>(
|
|
|
206
238
|
if (moved && moved.symbol.toUpperCase() !== symbol) return { line: first, moved: { ...moved, symbol: moved.symbol.toUpperCase() } };
|
|
207
239
|
}
|
|
208
240
|
if (hasPrice(quote)) return only(first);
|
|
241
|
+
// A US line no source prices (ZION on IEX, as search lists it) is its symbol's: the US listing its own quote names
|
|
242
|
+
// and prices (ZION on NASDAQ), as `quote ZION` reads it. The US venues share one symbol, so it is the same company.
|
|
243
|
+
if (isUsEquityExchange(first.exchange)) {
|
|
244
|
+
const own = await dataProvider.getQuote(first.result.symbol.toUpperCase(), "").catch(() => {
|
|
245
|
+
// Intentional ignore: with no quote of its own, the symbol's other lines are asked below.
|
|
246
|
+
return null;
|
|
247
|
+
});
|
|
248
|
+
const venue = canonicalExchange(own?.listingExchangeName || own?.exchangeName);
|
|
249
|
+
if (hasPrice(own) && venue && venue !== first.exchange && isUsEquityExchange(venue)) return only({ ...first, exchange: venue });
|
|
250
|
+
}
|
|
209
251
|
const keys = new Set([listingKey(first)]);
|
|
210
252
|
const next: T[] = [];
|
|
211
253
|
for (const line of lines) {
|
|
@@ -223,7 +223,11 @@ export function cleanListingName(name: string): string {
|
|
|
223
223
|
return (cut || trimmed).replace(/\s+/g, " ");
|
|
224
224
|
}
|
|
225
225
|
|
|
226
|
-
/**
|
|
226
|
+
/**
|
|
227
|
+
* A company's name without its legal form, for sentences: "Avis Budget Group,
|
|
228
|
+
* Inc." is "Avis Budget Group", and "Wells Fargo & Company" is "Wells Fargo",
|
|
229
|
+
* never cut at its "&".
|
|
230
|
+
*/
|
|
227
231
|
export function shortCompanyName(name: string): string {
|
|
228
232
|
const words = name.trim().split(/\s+/).filter(Boolean);
|
|
229
233
|
const legal = (word: string) => {
|
|
@@ -231,7 +235,8 @@ export function shortCompanyName(name: string): string {
|
|
|
231
235
|
// "Public Limited Company" is a legal form too, though "Public" alone can be a name.
|
|
232
236
|
return NAME_NOISE.has(plain) || SHARE_NOISE.has(plain) || (plain === "public" && words.length > 2);
|
|
233
237
|
};
|
|
234
|
-
|
|
238
|
+
const joining = (word: string) => word === "&" || word.toLowerCase() === "and";
|
|
239
|
+
while (words.length > 1 && (legal(words[words.length - 1]!) || joining(words[words.length - 1]!))) words.pop();
|
|
235
240
|
if (words.length > 1 && words[0]!.toLowerCase() === "the") words.shift();
|
|
236
241
|
return words.join(" ").replace(/[,;]+$/, "");
|
|
237
242
|
}
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
getSearchResultSymbol,
|
|
9
9
|
shouldReplaceTickerName,
|
|
10
10
|
} from "./result";
|
|
11
|
-
import { canonicalExchange, parsePublicTickerKey, publicTickerKey } from "../../utils/exchanges";
|
|
11
|
+
import { canonicalExchange, parsePublicTickerKey, publicTickerKey, usShareClassSpellings } from "../../utils/exchanges";
|
|
12
12
|
import { scopedBrokerContractIdentityKey } from "../../utils/instrument-identity";
|
|
13
13
|
import { listingSuffixVenue } from "../../sources/listing-symbols";
|
|
14
14
|
import { coinPairQuoteCurrency, exchangeLineCoinListing, isCoinRowType } from "../../utils/crypto-pair";
|
|
@@ -59,6 +59,13 @@ export async function upsertTickerFromSearchResult(
|
|
|
59
59
|
const exchange = canonicalExchange(listingVenue(result)) === venue.exchange ? result.exchange : venue.exchange;
|
|
60
60
|
result = { ...result, symbol: venue.symbol, exchange };
|
|
61
61
|
}
|
|
62
|
+
// BRK.B and BRK-B are one US share class: the row saved under either spelling, else a new one under the dotted.
|
|
63
|
+
const spellings = options.tickerSymbol || result.brokerContract ? null : usShareClassSpellings(symbol, listingVenue(result));
|
|
64
|
+
if (spellings) {
|
|
65
|
+
const saved = await firstSavedSpelling(tickerRepository, spellings);
|
|
66
|
+
symbol = saved ?? spellings[0]!;
|
|
67
|
+
result = { ...result, symbol };
|
|
68
|
+
}
|
|
62
69
|
let ticker = await tickerRepository.loadTicker(symbol);
|
|
63
70
|
const otherListingKey = otherListingTickerKey(result, symbol, ticker);
|
|
64
71
|
if (otherListingKey) {
|
|
@@ -121,6 +128,14 @@ async function venueKeyedRow(tickerRepository: AppTickerRepositoryPort, result:
|
|
|
121
128
|
return row && canonicalExchange(row.metadata.exchange) === exchange ? row : null;
|
|
122
129
|
}
|
|
123
130
|
|
|
131
|
+
/** The first of a share class's spellings a row is saved under, or null. */
|
|
132
|
+
async function firstSavedSpelling(tickerRepository: AppTickerRepositoryPort, spellings: readonly string[]): Promise<string | null> {
|
|
133
|
+
for (const spelling of spellings) {
|
|
134
|
+
if (await tickerRepository.loadTicker(spelling)) return spelling;
|
|
135
|
+
}
|
|
136
|
+
return null;
|
|
137
|
+
}
|
|
138
|
+
|
|
124
139
|
function listingVenue(result: InstrumentSearchResult): string | undefined {
|
|
125
140
|
return result.exchange === "SMART" ? result.primaryExchange : result.exchange || result.primaryExchange;
|
|
126
141
|
}
|
|
@@ -22,7 +22,8 @@ import { marketSeriesFrequency } from "./market";
|
|
|
22
22
|
import { canonicalExchange, resolveExchangeTimeZone } from "../utils/exchanges";
|
|
23
23
|
import { futuresGenericCaption, futuresGenericListing, futuresListingPriceBasis } from "../utils/futures-generic";
|
|
24
24
|
import { contractPriceUnit, currencyPairPriceUnit } from "./price-units";
|
|
25
|
-
import { INDEX_POINTS_UNIT, isIndexLevel } from "../market-data/market/index-level";
|
|
25
|
+
import { INDEX_POINTS_UNIT, INDEX_MEMBERS_VOLUME_LABEL, isIndexLevel } from "../market-data/market/index-level";
|
|
26
|
+
import { classifyInstrumentType, kindFromListingSyntax } from "../tickers/instrument-kind";
|
|
26
27
|
import { isOhlcSeriesStyle } from "./spec";
|
|
27
28
|
import { SERIES_COLORS } from "../theme/series-colors";
|
|
28
29
|
import type {
|
|
@@ -129,7 +130,18 @@ export function baseSecuritySeries(
|
|
|
129
130
|
const assetKind = resolveAssetDisplayKind({ assetCategory: financials.quote?.instrumentType || quoteMetadata?.instrumentType });
|
|
130
131
|
const unknownBondBasis = hasUnknownBondHistoryBasis(financials.quote,
|
|
131
132
|
spec.source.instrument.instrument?.secType, quoteMetadata?.instrumentType);
|
|
132
|
-
|
|
133
|
+
// The table behind `assetKind` leaves out types a provider or broker also
|
|
134
|
+
// sends (a REIT, a closed-end fund, a continuous future), and a listing
|
|
135
|
+
// before its quote arrives has none: the instrument's own kind fills those.
|
|
136
|
+
const instrumentKind = [financials.quote?.instrumentType, quoteMetadata?.instrumentType, spec.source.instrument.instrument?.secType]
|
|
137
|
+
.map((type) => classifyInstrumentType(type)).find((kind) => kind !== null)
|
|
138
|
+
?? kindFromListingSyntax(spec.source.instrument.symbol, spec.source.instrument.exchange);
|
|
139
|
+
const volumeUnit = unknownBondBasis ? undefined
|
|
140
|
+
: assetKind === "equity" || instrumentKind === "equity" || instrumentKind === "fund" ? "shares" as const
|
|
141
|
+
: assetKind === "contract" || instrumentKind === "future" || instrumentKind === "option" ? "contracts" as const
|
|
142
|
+
: undefined;
|
|
143
|
+
// An index has no volume of its own: sources sum its members' volume.
|
|
144
|
+
const volumeBasis = !volumeUnit && !unknownBondBasis && instrumentKind === "index" ? "index-members" as const : undefined;
|
|
133
145
|
// A price quote establishes its currency, but only instrument metadata can
|
|
134
146
|
// establish a per-share or per-crypto-unit basis. This does not establish the
|
|
135
147
|
// provider's volume denomination or a derivative's contract multiplier.
|
|
@@ -196,7 +208,8 @@ export function baseSecuritySeries(
|
|
|
196
208
|
&& points.every((point) => [point.open, point.high, point.low].every((value) => value == null || value === point.close));
|
|
197
209
|
return {
|
|
198
210
|
id: spec.id,
|
|
199
|
-
label: spec.label?.trim() || (generic ? futuresGenericCaption(generic)
|
|
211
|
+
label: spec.label?.trim() || (generic ? futuresGenericCaption(generic)
|
|
212
|
+
: `${symbol} ${field.id === "market.volume" && volumeBasis ? INDEX_MEMBERS_VOLUME_LABEL : field.seriesLabel ?? field.shortLabel}`),
|
|
200
213
|
color: spec.color ?? SERIES_COLORS[index % SERIES_COLORS.length]!,
|
|
201
214
|
unit,
|
|
202
215
|
unitGroup: currencyUnitGroup,
|
|
@@ -204,9 +217,10 @@ export function baseSecuritySeries(
|
|
|
204
217
|
priceAssetCategory: marketField && field.unitGroup === "price" && !unknownBondBasis
|
|
205
218
|
? financials.quote?.instrumentType || quoteMetadata?.instrumentType : undefined,
|
|
206
219
|
volumeUnit,
|
|
220
|
+
...(volumeBasis ? { volumeBasis } : {}),
|
|
207
221
|
...(priceIssues.length ? { valuationPriceIssues: priceIssues } : {}),
|
|
208
222
|
warning: [valuationFallback ? "Release dates unavailable; showing reported periods." : undefined,
|
|
209
|
-
field.id === "market.volume" && !volumeUnit && points.
|
|
223
|
+
field.id === "market.volume" && !volumeUnit && !volumeBasis && points.some((point) => Number.isFinite(point.value) && point.value !== 0)
|
|
210
224
|
? "Volume unit unknown." : statementCurrency?.warning ?? valuationCurrencyWarning(financials, spec.source)].filter(Boolean).join(" ") || undefined,
|
|
211
225
|
nativeFrequency: marketField ? marketSeriesFrequency(spec.source, marketResolution)
|
|
212
226
|
: valuationFallback ?? (spec.source.period && spec.source.period !== "auto" ? spec.source.period : field.nativeFrequency),
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { mergePriceHistoryIntegrity } from "../../utils/price-history-integrity";
|
|
2
2
|
import { isRealizedVolatilityEstimator, rollingRealizedVolatility } from "../../market-data/realized-volatility";
|
|
3
|
+
import { INDEX_MEMBERS_VOLUME_LABEL } from "../../market-data/market/index-level";
|
|
3
4
|
import { averageTrueRange } from "../trader-studies";
|
|
4
5
|
import type { ChartStudySpec, ResolvedSeries, TimeSeriesPoint } from "../types";
|
|
5
6
|
import { isFiniteNumber } from "../../utils/guards";
|
|
@@ -273,8 +274,9 @@ export function resolveVolume(spec: ChartStudySpec, input: ResolvedSeries, color
|
|
|
273
274
|
...(directional && isFiniteNumber(point.open) && isFiniteNumber(point.close) && point.close < point.open ? { fell: true } : {}),
|
|
274
275
|
}]
|
|
275
276
|
: []);
|
|
277
|
+
const label = input.volumeBasis === "index-members" ? INDEX_MEMBERS_VOLUME_LABEL : "Volume";
|
|
276
278
|
return [outputSeries(spec, input, {
|
|
277
|
-
label: nameInput ?
|
|
279
|
+
label: nameInput ? `${label} ${input.label}` : label,
|
|
278
280
|
points,
|
|
279
281
|
color: directional ? input.color : color,
|
|
280
282
|
unit: input.volumeUnit ?? "",
|
|
@@ -298,7 +298,7 @@ function resolveStudySpecs(
|
|
|
298
298
|
else if (spec.kind === "formula" && formula) outputs = resolveFormula(spec, inputs as ResolvedSeries[], formula.terms, formula.unit, color);
|
|
299
299
|
else if (spec.kind === "volume") {
|
|
300
300
|
outputs = resolveVolume(spec, input, color, nameVolumeInput);
|
|
301
|
-
if (!input.volumeUnit && outputs.some((output) => output.points.length > 0)) {
|
|
301
|
+
if (!input.volumeUnit && !input.volumeBasis && outputs.some((output) => output.points.length > 0)) {
|
|
302
302
|
warnings.push(`Volume unit unknown: ${input.label}.`);
|
|
303
303
|
}
|
|
304
304
|
}
|
package/src/time-series/types.ts
CHANGED
|
@@ -218,6 +218,12 @@ export interface ResolvedSeries {
|
|
|
218
218
|
tickGrid?: number;
|
|
219
219
|
/** Volume basis established by the source instrument; omitted when unspecified. */
|
|
220
220
|
volumeUnit?: "shares" | "contracts";
|
|
221
|
+
/**
|
|
222
|
+
* Set where the volume is the combined volume of an index's members. It has
|
|
223
|
+
* no unit of its own to state and nothing unknown to warn about; the volume
|
|
224
|
+
* reads as "Members' volume".
|
|
225
|
+
*/
|
|
226
|
+
volumeBasis?: "index-members";
|
|
221
227
|
nativeFrequency: SeriesPeriod;
|
|
222
228
|
/**
|
|
223
229
|
* Set on a series with nothing to draw because its company reports no
|
package/src/types/financials.ts
CHANGED
|
@@ -120,6 +120,16 @@ interface DepositaryReceiptFacts {
|
|
|
120
120
|
cedearRatio?: CedearRatio;
|
|
121
121
|
}
|
|
122
122
|
|
|
123
|
+
/** A split in a quote's own session (Quote.sessionSplit). */
|
|
124
|
+
export interface QuoteSessionSplit {
|
|
125
|
+
/** The first session on the new basis, YYYY-MM-DD. */
|
|
126
|
+
exDate: string;
|
|
127
|
+
/** What a price from before the split is multiplied by. */
|
|
128
|
+
priceFactor: number;
|
|
129
|
+
/** The previous close the source stated, on the old basis. */
|
|
130
|
+
sourcePreviousClose: number;
|
|
131
|
+
}
|
|
132
|
+
|
|
123
133
|
export interface Quote extends DepositaryReceiptFacts {
|
|
124
134
|
/** Applies to this price observation; a stored position cannot supply it. */
|
|
125
135
|
priceBasis?: PriceBasis;
|
|
@@ -143,6 +153,14 @@ export interface Quote extends DepositaryReceiptFacts {
|
|
|
143
153
|
*/
|
|
144
154
|
changeBasis?: "24h" | "none";
|
|
145
155
|
previousClose?: number;
|
|
156
|
+
/**
|
|
157
|
+
* A split took effect in the quote's session, so the source's previous close
|
|
158
|
+
* was on the old share basis: previousClose is the close before it on the
|
|
159
|
+
* price's basis, the source's `sourcePreviousClose` times `priceFactor`
|
|
160
|
+
* (1/3 for a 3-for-1 split, 10 for a 1-for-10 reverse one), and change is
|
|
161
|
+
* measured from it. Gloom Cloud sets it; absent on any other quote.
|
|
162
|
+
*/
|
|
163
|
+
sessionSplit?: QuoteSessionSplit;
|
|
146
164
|
/**
|
|
147
165
|
* Exchange-local date of previousClose. The app's quote router reads it
|
|
148
166
|
* from the listing's own daily closes where the venue's calendar cannot
|
package/src/types/headless.ts
CHANGED
|
@@ -587,6 +587,15 @@ export type HeadlessBundleSection =
|
|
|
587
587
|
rowAsOfKey?: string;
|
|
588
588
|
/** The bar interval the rows are of (`1d`), which every exported row names in `interval`. */
|
|
589
589
|
interval?: string;
|
|
590
|
+
/** The row field naming each row's own interval (a contract's funding interval, `8h`), for rows that differ: each exported row names it in `interval`. */
|
|
591
|
+
rowIntervalKey?: string;
|
|
592
|
+
/**
|
|
593
|
+
* The row field naming who each row is cited to, for a table whose rows
|
|
594
|
+
* come from different publishers (each venue's contract): each exported
|
|
595
|
+
* row names it in `source`, in place of the closing lines' source that
|
|
596
|
+
* lists them all.
|
|
597
|
+
*/
|
|
598
|
+
rowSourceKey?: string;
|
|
590
599
|
/** The symbol every row is of, where the report's own is not (a section per name): each exported row names it in `symbol_or_series`. */
|
|
591
600
|
symbol?: string;
|
|
592
601
|
/** When every row was observed (an ISO date or instant), where it is not the report's newest: each exported row names it in `as_of`. */
|
|
@@ -630,6 +639,8 @@ export type HeadlessBundleSection =
|
|
|
630
639
|
unit?: never;
|
|
631
640
|
rowUnitKey?: never;
|
|
632
641
|
interval?: never;
|
|
642
|
+
rowIntervalKey?: never;
|
|
643
|
+
rowSourceKey?: never;
|
|
633
644
|
locked?: never;
|
|
634
645
|
};
|
|
635
646
|
|
package/src/ui/host.tsx
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { createContext, useContext, type ComponentType, type ReactNode, type Ref } from "react";
|
|
1
|
+
import { createContext, useCallback, useContext, type ComponentType, type ReactNode, type Ref } from "react";
|
|
2
2
|
import type { ContextMenuItem } from "../types/context-menu";
|
|
3
3
|
import type { AppNotificationRequest } from "../types/plugin";
|
|
4
4
|
import { getShortcutDisplayMode } from "../utils/shortcut-labels";
|
|
5
|
-
import { formatAdvertisedChord, useKeybindings } from "../app/keybindings";
|
|
5
|
+
import { formatAdvertisedChord, formatShortcutForHost, useKeybindings } from "../app/keybindings";
|
|
6
6
|
import type { AsciiFontName } from "./ascii-font";
|
|
7
7
|
|
|
8
8
|
export const TextAttributes = {
|
|
@@ -570,6 +570,8 @@ export interface HostQueryBarProps {
|
|
|
570
570
|
value: string;
|
|
571
571
|
options: { value: string; label: string; hint?: string; disabled?: boolean }[];
|
|
572
572
|
onChange(value: string): void;
|
|
573
|
+
/** Drawn first, where a tab row starts: a nested tab strip. */
|
|
574
|
+
start?: boolean;
|
|
573
575
|
};
|
|
574
576
|
onClearAll?: () => void;
|
|
575
577
|
/** Muted context at the right edge, e.g. the selected row's date. */
|
|
@@ -751,6 +753,7 @@ interface UiHostContextValue {
|
|
|
751
753
|
ui: UiHost;
|
|
752
754
|
renderer: RendererHost;
|
|
753
755
|
nativeRenderer: NativeRendererHost;
|
|
756
|
+
cellGrid: number;
|
|
754
757
|
}
|
|
755
758
|
|
|
756
759
|
const noopNativeRenderer: NativeRendererHost = {
|
|
@@ -770,15 +773,22 @@ export function UiHostProvider({
|
|
|
770
773
|
ui,
|
|
771
774
|
renderer,
|
|
772
775
|
nativeRenderer = noopNativeRenderer,
|
|
776
|
+
cellGrid = 0,
|
|
773
777
|
children,
|
|
774
778
|
}: {
|
|
775
779
|
ui: UiHost;
|
|
776
780
|
renderer: RendererHost;
|
|
777
781
|
nativeRenderer?: NativeRendererHost;
|
|
782
|
+
/**
|
|
783
|
+
* Changes with the host's cell size (the DOM's follows the font size). The
|
|
784
|
+
* context carries it so every kit element, memoized ones included, and every
|
|
785
|
+
* reader of `cellWidthPx` renders again on the new grid.
|
|
786
|
+
*/
|
|
787
|
+
cellGrid?: number;
|
|
778
788
|
children: ReactNode;
|
|
779
789
|
}) {
|
|
780
790
|
return (
|
|
781
|
-
<UiHostContext value={{ ui, renderer, nativeRenderer }}>
|
|
791
|
+
<UiHostContext value={{ ui, renderer, nativeRenderer, cellGrid }}>
|
|
782
792
|
{children}
|
|
783
793
|
</UiHostContext>
|
|
784
794
|
);
|
|
@@ -817,6 +827,19 @@ export function useActionShortcut(actionId: string): string {
|
|
|
817
827
|
return formatAdvertisedChord(keybindings, actionId, getShortcutDisplayMode(kind));
|
|
818
828
|
}
|
|
819
829
|
|
|
830
|
+
/**
|
|
831
|
+
* Writes a key named in text (`Ctrl+S`, `Shift+Enter`, `Shift+Left/Right`) the
|
|
832
|
+
* way this host shows keys: Apple's symbols on a Mac desktop or in a Mac
|
|
833
|
+
* browser (`⌃S`, `⇧↩`), as written in a terminal and on Windows and Linux.
|
|
834
|
+
* For any key a pane, hint, tooltip or sentence names that is not a
|
|
835
|
+
* keybinding action (those come from useActionShortcut).
|
|
836
|
+
*/
|
|
837
|
+
export function useShortcutLabel(): (text: string) => string {
|
|
838
|
+
const kind = useContext(UiHostContext)?.ui.kind;
|
|
839
|
+
const mode = getShortcutDisplayMode(kind);
|
|
840
|
+
return useCallback((text: string) => formatShortcutForHost(text, mode), [mode]);
|
|
841
|
+
}
|
|
842
|
+
|
|
820
843
|
export function useRendererHost(): RendererHost {
|
|
821
844
|
const context = useContext(UiHostContext);
|
|
822
845
|
if (!context) {
|
package/src/ui/index.tsx
CHANGED
package/src/utils/concurrency.ts
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A list's rows whose financials are read at once from a source without
|
|
3
|
+
* batches: `portfolio show` and a capture of the list (`shot PF`) alike.
|
|
4
|
+
*/
|
|
5
|
+
export const LIST_FINANCIALS_CONCURRENCY = 8;
|
|
6
|
+
|
|
1
7
|
/** Maps every item with at most `limit` calls in flight, keeping the input order in the result. */
|
|
2
8
|
export async function mapWithConcurrency<T, R>(
|
|
3
9
|
items: readonly T[],
|
|
@@ -86,11 +86,11 @@ export function looksLikeCurrencyPair(symbol: string): boolean {
|
|
|
86
86
|
}
|
|
87
87
|
|
|
88
88
|
/**
|
|
89
|
-
* Which currency of a pair markets quote it per:
|
|
90
|
-
* before the dollar, the dollar before CAD, CHF and the
|
|
91
|
-
* last (EUR/USD, USD/CAD, USD/JPY, EUR/CAD, CAD/JPY).
|
|
89
|
+
* Which currency of a pair markets quote it per: the metals first (XAU/USD),
|
|
90
|
+
* EUR, GBP, AUD and NZD before the dollar, the dollar before CAD, CHF and the
|
|
91
|
+
* rest, and the yen last (EUR/USD, USD/CAD, USD/JPY, EUR/CAD, CAD/JPY).
|
|
92
92
|
*/
|
|
93
|
-
const PAIR_BASE_ORDER = ["EUR", "GBP", "AUD", "NZD", "USD", "CAD", "CHF"];
|
|
93
|
+
const PAIR_BASE_ORDER = ["XAU", "XAG", "XPT", "XPD", "EUR", "GBP", "AUD", "NZD", "USD", "CAD", "CHF"];
|
|
94
94
|
|
|
95
95
|
function pairBaseRank(code: string): number {
|
|
96
96
|
const at = PAIR_BASE_ORDER.indexOf(code);
|
|
@@ -104,6 +104,58 @@ export function dollarPairListing(code: string): string {
|
|
|
104
104
|
return pairBaseRank(currency) < pairBaseRank("USD") ? `${currency}USD=X` : `USD${currency}=X`;
|
|
105
105
|
}
|
|
106
106
|
|
|
107
|
+
/**
|
|
108
|
+
* The decimals an FX rate is shown to, its pair's precision: a rate in yen
|
|
109
|
+
* from 1 up to three (EUR/JPY 177.861, TRY/JPY 3.712), any other rate from 50
|
|
110
|
+
* up to three as well (USD/INR 88.735), from 1000 up to two (USD/IDR
|
|
111
|
+
* 16250.50), from 1 up to five (EUR/USD 1.12625), and any rate below 1, yen
|
|
112
|
+
* too, to five significant digits with at least five decimals and at most
|
|
113
|
+
* eight (USD/EUR 0.88790, KRW/JPY 0.10712, IDR/JPY 0.0096120). `currency` is
|
|
114
|
+
* the currency the rate is in; `rate` is best a level that holds still (the
|
|
115
|
+
* previous close), so a rate ticking across 50 keeps its decimals. It is for
|
|
116
|
+
* showing a rate: a conversion uses the rate as it came.
|
|
117
|
+
*/
|
|
118
|
+
export function fxRateDigits(currency: string | undefined, rate: number | undefined): number {
|
|
119
|
+
const size = rate == null || !Number.isFinite(rate) ? 0 : Math.abs(rate);
|
|
120
|
+
if (currency?.trim().toUpperCase() === "JPY" && (size === 0 || size >= 1)) return 3;
|
|
121
|
+
if (size === 0) return 5;
|
|
122
|
+
if (size >= 1000) return 2;
|
|
123
|
+
if (size >= 50) return 3;
|
|
124
|
+
if (size >= 1) return 5;
|
|
125
|
+
return Math.min(8, Math.max(5, 4 - Math.floor(Math.log10(size))));
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* A figure as its source sent it, without the tail a single-precision float
|
|
130
|
+
* picks up on the way: 1.1265100240707397 is 1.12651, 153.5540008544922 is
|
|
131
|
+
* 153.554. A figure that is no single-precision float stays as it came, so
|
|
132
|
+
* nothing it carries is rounded off.
|
|
133
|
+
*/
|
|
134
|
+
export function fxFigureAsSent(value: number): number {
|
|
135
|
+
if (!Number.isFinite(value) || value === 0 || Math.fround(value) !== value) return value;
|
|
136
|
+
for (let digits = 1; digits <= 9; digits += 1) {
|
|
137
|
+
const short = Number(value.toPrecision(digits));
|
|
138
|
+
if (Math.fround(short) === value) return short;
|
|
139
|
+
}
|
|
140
|
+
return value;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/** The decimals a figure carries: 1.12651 has five, 157.8 one, 6.5e-7 seven. */
|
|
144
|
+
function decimalsCarried(value: number): number {
|
|
145
|
+
const [mantissa, exponent] = String(Math.abs(value)).split("e");
|
|
146
|
+
return Math.max(0, (mantissa!.split(".")[1] ?? "").length - Number(exponent ?? 0));
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* A rate as the figure it is: at least its pair's decimals (`fxRateDigits`),
|
|
151
|
+
* and every decimal it carries, so the rate printed is the rate used
|
|
152
|
+
* (EUR/USD 1.12650, 1.126507; IDR/JPY 0.0096120).
|
|
153
|
+
*/
|
|
154
|
+
export function fxFigureText(value: number, currency: string | undefined): string {
|
|
155
|
+
if (!Number.isFinite(value)) return String(value);
|
|
156
|
+
return value.toFixed(Math.min(15, Math.max(fxRateDigits(currency, value), decimalsCarried(value))));
|
|
157
|
+
}
|
|
158
|
+
|
|
107
159
|
/**
|
|
108
160
|
* A rate of `quote` per unit of `currency`, written the way markets quote
|
|
109
161
|
* the pair, as `fx` reads a pair: 0.0067 USD per JPY is USD/JPY 149.25, and
|
|
@@ -103,6 +103,17 @@ export function formatShortDate(value: DisplayDateValue, options: ShortDateOptio
|
|
|
103
103
|
return formatter.format(date);
|
|
104
104
|
}
|
|
105
105
|
|
|
106
|
+
/**
|
|
107
|
+
* The day a filing is dated, as the agency and the filer write it: "Nov 04,
|
|
108
|
+
* 2026", the day padded so a column of them lines up. A calendar day, read in
|
|
109
|
+
* UTC, so it never moves with the viewer's zone: give it the filing date
|
|
110
|
+
* (`2026-11-04`, or that day at midnight UTC), not an acceptance instant,
|
|
111
|
+
* which can fall on the evening before or on a weekend.
|
|
112
|
+
*/
|
|
113
|
+
export function formatFilingDate(value: DisplayDateValue, fallback = "\u2014"): string {
|
|
114
|
+
return formatShortDate(value, { day: "2-digit", utc: true, fallback });
|
|
115
|
+
}
|
|
116
|
+
|
|
106
117
|
const clockFormatter = new Intl.DateTimeFormat("en-US", {
|
|
107
118
|
hour: "2-digit",
|
|
108
119
|
minute: "2-digit",
|
|
@@ -194,15 +194,18 @@ export function readCurrencyAmount(value: unknown, label: string, currency: stri
|
|
|
194
194
|
}
|
|
195
195
|
|
|
196
196
|
/**
|
|
197
|
-
* A labelled amount to convert (`fx 81,000 EUR/USD`)
|
|
198
|
-
*
|
|
199
|
-
*
|
|
200
|
-
* readings,
|
|
201
|
-
*
|
|
197
|
+
* A labelled amount to convert (`fx 81,000 EUR/USD`): a single comma or dot
|
|
198
|
+
* and exactly three digits (`1,234`, `1.234`) could be thousands or a decimal
|
|
199
|
+
* mark whatever the currency's minor units, so it throws naming both
|
|
200
|
+
* readings, as `alerts add` refuses `1,234` for a price. A dot-decimal reader
|
|
201
|
+
* typing `1.234` is never handed 1234. Anything else reads as
|
|
202
|
+
* `readCurrencyAmount` reads it.
|
|
202
203
|
*/
|
|
203
204
|
export function readConvertedAmount(value: unknown, label: string, currency: string): number {
|
|
204
205
|
const read = parseTypedNumber(value);
|
|
205
|
-
|
|
206
|
+
const dotted = read.kind === "number" ? thousandsDotReadings(withoutUnderscores(value)) : null;
|
|
207
|
+
const reading = read.kind === "ambiguous" ? read : dotted;
|
|
208
|
+
if (reading) throw ambiguousAmountError(value, reading, label, currency.trim().toUpperCase());
|
|
206
209
|
return readCurrencyAmount(value, label, currency);
|
|
207
210
|
}
|
|
208
211
|
|
package/src/utils/exchanges.ts
CHANGED
|
@@ -164,6 +164,38 @@ export function isUsListingExchange(value?: string): boolean {
|
|
|
164
164
|
return US_LISTING_EXCHANGES.has(canonicalExchange(value));
|
|
165
165
|
}
|
|
166
166
|
|
|
167
|
+
/**
|
|
168
|
+
* A US share class's spellings, the dotted one first: BRK.B, BRK-B and BRK/B
|
|
169
|
+
* are one listing, and so one row. Null for any other symbol, and for one on
|
|
170
|
+
* a venue abroad (RCI-B on TSX is that venue's own code).
|
|
171
|
+
*/
|
|
172
|
+
export function usShareClassSpellings(symbol: string, exchange?: string | null): string[] | null {
|
|
173
|
+
const match = /^([A-Z]{1,5})[.\-/]([A-Z])$/.exec(symbol.trim().toUpperCase());
|
|
174
|
+
const venue = canonicalExchange(exchange ?? "");
|
|
175
|
+
if (!match || (venue && !isUsEquityExchange(venue))) return null;
|
|
176
|
+
return [`${match[1]}.${match[2]}`, `${match[1]}-${match[2]}`, `${match[1]}/${match[2]}`];
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/** Canonical US equity venues: the listing exchanges plus other lit and OTC venues. */
|
|
180
|
+
const US_EQUITY_EXCHANGES: ReadonlySet<string> = new Set([
|
|
181
|
+
...US_LISTING_EXCHANGES,
|
|
182
|
+
"BYX",
|
|
183
|
+
"IEX",
|
|
184
|
+
"OTC",
|
|
185
|
+
"PINK",
|
|
186
|
+
// Listing codes for the OTC Markets tiers.
|
|
187
|
+
"PNK",
|
|
188
|
+
"OQB",
|
|
189
|
+
"OQX",
|
|
190
|
+
"OEM",
|
|
191
|
+
"OBB",
|
|
192
|
+
]);
|
|
193
|
+
|
|
194
|
+
/** A US venue a stock or fund trades on, listed or over the counter. */
|
|
195
|
+
export function isUsEquityExchange(value?: string): boolean {
|
|
196
|
+
return US_EQUITY_EXCHANGES.has(canonicalExchange(value));
|
|
197
|
+
}
|
|
198
|
+
|
|
167
199
|
export function resolveExchangeTimeZone(value?: string): string | null {
|
|
168
200
|
const canonical = canonicalExchange(value);
|
|
169
201
|
return canonical ? EXCHANGE_TIME_ZONES[canonical] ?? null : null;
|
|
@@ -23,6 +23,45 @@ export function redactUnavailableFundamentals(value: Fundamentals | undefined):
|
|
|
23
23
|
return result;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
+
/**
|
|
27
|
+
* What a bank's enterprise value reads wherever one is shown: its deposits are
|
|
28
|
+
* its funding, not debt, so market cap + debt - cash measures nothing of it.
|
|
29
|
+
* Its reported cash flow stays as reported.
|
|
30
|
+
*/
|
|
31
|
+
export const BANK_ENTERPRISE_VALUE = "n/m for banks";
|
|
32
|
+
|
|
33
|
+
/** A bank by its industry ("Banks - Diversified", "Banks - Regional"), as the Bank section and its EV read one. */
|
|
34
|
+
function isBankIndustry(industry: string | null | undefined): boolean {
|
|
35
|
+
return /\bbanks?\b/i.test(industry ?? "");
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* A bank's fundamentals with its EV and EV/revenue not meaningful
|
|
40
|
+
* (`BANK_ENTERPRISE_VALUE`), the source's figure kept on the check: every view
|
|
41
|
+
* that reads an EV then reads N/M. Any other company's as they are.
|
|
42
|
+
*/
|
|
43
|
+
export function withBankEnterpriseValue<F extends Fundamentals | undefined>(
|
|
44
|
+
fundamentals: F,
|
|
45
|
+
profile: { industry?: string | null } | null | undefined,
|
|
46
|
+
): F {
|
|
47
|
+
if (!fundamentals || !isBankIndustry(profile?.industry)) return fundamentals;
|
|
48
|
+
const { enterpriseValue: _value, enterpriseToRevenue: _ratio, ...rest } = fundamentals;
|
|
49
|
+
const source = reportedEnterpriseValue(fundamentals) ?? fundamentals.enterpriseValueCheck?.source;
|
|
50
|
+
// Only where an EV would be shown: a bank the source gave none for shows no line, as before.
|
|
51
|
+
if (!finiteNumber(source)) return fundamentals;
|
|
52
|
+
const withdrawn = new Set([...fundamentals.unavailableFields ?? [], "enterpriseValue" as const, "enterpriseToRevenue" as const]);
|
|
53
|
+
return {
|
|
54
|
+
...rest,
|
|
55
|
+
unavailableFields: [...withdrawn],
|
|
56
|
+
enterpriseValueCheck: { status: "not-meaningful", ...finiteNumber(source) ? { source } : {}, reason: BANK_ENTERPRISE_VALUE },
|
|
57
|
+
} as F;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** Whether a not meaningful EV is so because the company is a bank (`withBankEnterpriseValue`). */
|
|
61
|
+
export function isBankEnterpriseValue(fundamentals: Parameters<typeof enterpriseValueCheck>[0]): boolean {
|
|
62
|
+
return enterpriseValueNotMeaningful(fundamentals) === BANK_ENTERPRISE_VALUE;
|
|
63
|
+
}
|
|
64
|
+
|
|
26
65
|
/** A source's enterprise value, or undefined when it has none: banks and insurers come back as 0, which is a gap, not a value. */
|
|
27
66
|
export function reportedEnterpriseValue(fundamentals: Pick<Fundamentals, "enterpriseValue"> | undefined): number | undefined {
|
|
28
67
|
const value = fundamentals?.enterpriseValue;
|
|
@@ -98,6 +137,8 @@ export function enterpriseValueLabel(fundamentals: Parameters<typeof enterpriseV
|
|
|
98
137
|
*/
|
|
99
138
|
export function enterpriseValueReconciliationNote(fundamentals: Parameters<typeof enterpriseValueCheck>[0]): string | undefined {
|
|
100
139
|
const notMeaningful = enterpriseValueNotMeaningful(fundamentals);
|
|
140
|
+
// A bank's EV line says it all: "n/m for banks".
|
|
141
|
+
if (notMeaningful === BANK_ENTERPRISE_VALUE) return undefined;
|
|
101
142
|
if (notMeaningful) return `EV N/M: ${notMeaningful.charAt(0).toLowerCase()}${notMeaningful.slice(1)}.`;
|
|
102
143
|
const check = enterpriseValueCheck(fundamentals);
|
|
103
144
|
if (!check && enterpriseValueWithdrawn(fundamentals)) return "EV unavailable: the provider's figure failed validation.";
|
package/src/utils/markdown.ts
CHANGED
|
@@ -22,7 +22,9 @@ export interface InlineMarkdownOptions {
|
|
|
22
22
|
links?: boolean | ((href: string) => boolean);
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
// A backslash escapes the punctuation markdown would read ("\\*" is a star)
|
|
25
|
+
// A backslash escapes the punctuation markdown would read ("\\*" is a star),
|
|
26
|
+
// a link's label included. A bracket inside a label is escaped: "[a [b](href)"
|
|
27
|
+
// links "b" only.
|
|
26
28
|
// A bracket after a bang is a picture, which stays as written. A bare address
|
|
27
29
|
// is read whole, so the underscores and stars in it are not marks. A mark
|
|
28
30
|
// opens before a character and closes after one, so "2 * 3 * 4" is
|
|
@@ -30,7 +32,7 @@ export interface InlineMarkdownOptions {
|
|
|
30
32
|
// An italic span may hold a bold one ("*covers **96%** of value*").
|
|
31
33
|
const INLINE_RE = new RegExp([
|
|
32
34
|
String.raw`\\(?<escaped>[\\` + "`" + String.raw`*_~#>[\]()-])`,
|
|
33
|
-
String.raw`(?<!!)\[(?<linkLabel>[
|
|
35
|
+
String.raw`(?<!!)\[(?<linkLabel>(?:\\.|[^[\]\\])+)\]\((?<linkHref>(?:[^()\s]|\([^()\s]*\))+)\)`,
|
|
34
36
|
String.raw`(?<url>\b(?:https?:\/\/|www\.)[^\s<>"']+)`,
|
|
35
37
|
"(?<!`)(?<ticks>`{1,3})(?!`)(?<code>[^`]|[^`].*?[^`])\\k<ticks>(?!`)",
|
|
36
38
|
String.raw`\*\*(?![\s*])(?<bold>[^*]+?)(?<!\s)\*\*`,
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How a one-line field takes a paste of several lines: `true` joins them as
|
|
3
|
+
* words, each line break or tab a space (`AAPL MSFT`); `"list"` keeps each
|
|
4
|
+
* line and each tab-separated cell an entry, joined with ", " (`Apple Inc,
|
|
5
|
+
* Meta Platforms`), so a pasted column or sheet row of names or terminal codes
|
|
6
|
+
* (`VOD LN`, `BARC LN`) stays one entry a line.
|
|
7
|
+
*/
|
|
8
|
+
export type PastedLines = boolean | "list";
|
|
9
|
+
|
|
10
|
+
/** A paste as the one line a field that reads a list takes (`PastedLines`). */
|
|
11
|
+
export function joinPastedLines(text: string, mode: Exclude<PastedLines, false>): string {
|
|
12
|
+
if (mode === "list") return text.replace(/^[\s,]+|[\s,]+$/g, "").replace(/[ \t]*[\t\r\n][\s]*/g, ", ");
|
|
13
|
+
return text.replace(/^[\r\n]+|[\r\n]+$/g, "").replace(/[ \t]*[\r\n]+[ \t]*/g, " ").replace(/\t+/g, " ");
|
|
14
|
+
}
|