gloomberb 0.19.5 → 0.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +0 -4
- package/package.json +6 -5
- package/patches/@opentui%2Fcore@0.3.2.patch +86 -25
- package/patches/electrobun-devkit@2.0.5.patch +148 -0
- package/src/api-client/bond-trades.ts +59 -0
- package/src/api-client/data.ts +21 -0
- package/src/api-client/equity-screener.ts +23 -0
- package/src/api-client/index.ts +2 -0
- package/src/api-client/types/account.ts +86 -0
- package/src/api-client/types/assist.ts +32 -0
- package/src/api-client/types/auth.ts +63 -0
- package/src/api-client/types/billing.ts +54 -0
- package/src/api-client/types/chat.ts +180 -0
- package/src/api-client/types/congress.ts +107 -0
- package/src/api-client/types/credit.ts +110 -0
- package/src/api-client/types/econ.ts +158 -0
- package/src/api-client/types/equity-diagnostic.ts +73 -0
- package/src/api-client/types/filings-and-calls.ts +350 -0
- package/src/api-client/types/index.ts +25 -0
- package/src/api-client/types/jobs.ts +147 -0
- package/src/api-client/types/market.ts +122 -0
- package/src/api-client/types/news.ts +91 -0
- package/src/api-client/types/notes-and-theses.ts +172 -0
- package/src/api-client/types/quotes.ts +28 -0
- package/src/api-client/types/scanners.ts +125 -0
- package/src/api-client/types/screener.ts +65 -0
- package/src/api-client/types/search.ts +107 -0
- package/src/api-client/types/sync.ts +14 -0
- package/src/api-client/types/team-collections.ts +43 -0
- package/src/api-client/types/team-views.ts +32 -0
- package/src/api-client/types/teams.ts +135 -0
- package/src/api-client/types/ticker-data.ts +57 -0
- package/src/api-client/types/tweets.ts +59 -0
- package/src/api-client/types/world-venues.ts +23 -0
- package/src/app/pane-runtime/index.tsx +2 -0
- package/src/app/pane-runtime/plugin-bindings.ts +10 -1
- package/src/app/runtime/desktop-deeplink.ts +41 -6
- package/src/app/star-prompt/status-line.tsx +1 -1
- package/src/app.tsx +64 -23
- package/src/architecture/ui-tokens-allowlist.json +0 -8
- package/src/cli/commands/market.ts +149 -10
- package/src/cli/commands/search.ts +21 -3
- package/src/cli/commands/ticker.ts +90 -36
- package/src/cli/desktop-pane-shot-browser.ts +69 -3
- package/src/cli/glossary.ts +3 -3
- package/src/cli/known-gaps.ts +8 -0
- package/src/cli/listing-arg.ts +12 -0
- package/src/cli/pane-functions/capabilities.ts +2 -0
- package/src/cli/pane-functions/catalog.ts +25 -5
- package/src/cli/pane-functions/function-help.ts +8 -5
- package/src/cli/pane-functions/headless.ts +4 -3
- package/src/cli/pane-functions/resolver.ts +75 -2
- package/src/cli/quote-answer.ts +9 -0
- package/src/cli/symbol-list.ts +54 -2
- package/src/cli/symbol-rows.ts +14 -2
- package/src/cli/ticker-resolution.ts +89 -20
- package/src/components/chart/composite/axis-overlays.tsx +60 -27
- package/src/components/chart/composite/composite-chart.tsx +118 -63
- package/src/components/chart/composite/cursor-source.ts +111 -0
- package/src/components/chart/composite/format.ts +168 -6
- package/src/components/chart/composite/legend.tsx +8 -4
- package/src/components/chart/composite/panel-labels.ts +20 -1
- package/src/components/chart/composite/panel-surface.tsx +201 -92
- package/src/components/chart/composite/price-axis-labels.tsx +92 -46
- package/src/components/chart/composite/price-series.ts +31 -8
- package/src/components/chart/composite/scene.ts +154 -59
- package/src/components/chart/composite/series-axis-tags.tsx +4 -2
- package/src/components/chart/composite/time-axis.ts +13 -5
- package/src/components/chart/composite/time-scale.ts +211 -56
- package/src/components/chart/composite/types.ts +11 -1
- package/src/components/chart/composite/use-composite-chart-keyboard.ts +43 -14
- package/src/components/chart/curve/curve-surface.tsx +5 -2
- package/src/components/chart/curve/model.ts +4 -1
- package/src/components/chart/native/use-bitmap-metrics.ts +81 -0
- package/src/components/chart/static/series.ts +3 -0
- package/src/components/command-bar/commands/collection-list.ts +81 -0
- package/src/components/command-bar/commands/direct/index.ts +6 -0
- package/src/components/command-bar/commands/registry.ts +8 -0
- package/src/components/command-bar/layout-items/current-layout.ts +22 -1
- package/src/components/command-bar/layout-items/focused-pane.ts +22 -1
- package/src/components/command-bar/pane-templates/items.ts +19 -3
- package/src/components/command-bar/pane-templates/workflow.ts +5 -0
- package/src/components/command-bar/routes/root/results.ts +23 -3
- package/src/components/command-bar/routes/root/selection.ts +4 -2
- package/src/components/command-bar/routes/root/shortcut-feedback.ts +1 -1
- package/src/components/command-bar/routes/root/shortcut-items.ts +3 -4
- package/src/components/command-bar/routes/root/shortcuts.ts +58 -14
- package/src/components/command-bar/routes/root/ticker-first.ts +32 -0
- package/src/components/command-bar/surface/environment.ts +2 -0
- package/src/components/command-bar/view-model.ts +7 -0
- package/src/components/command-bar/workflow/ops.ts +2 -1
- package/src/components/command-bar/workflow/tickers.ts +20 -0
- package/src/components/data-table/export.ts +4 -1
- package/src/components/layout/detached-pane-shell.tsx +10 -37
- package/src/components/layout/double-escape-close.ts +90 -0
- package/src/components/layout/header.tsx +3 -2
- package/src/components/layout/market-summary.ts +6 -3
- package/src/components/layout/pane/footer/index.tsx +2 -6
- package/src/components/layout/pane/footer/model.ts +6 -12
- package/src/components/layout/shell/active-drag.ts +53 -11
- package/src/components/layout/shell/drag/magnets.ts +128 -19
- package/src/components/layout/shell/menu.ts +15 -1
- package/src/components/layout/shell/pane/actions.ts +10 -2
- package/src/components/layout/shell/pane/management-shortcuts.ts +13 -51
- package/src/components/layout/shell/ticker-link-menu.ts +12 -3
- package/src/components/layout/status-bar.tsx +24 -78
- package/src/components/layout/status-widget-space.ts +5 -5
- package/src/components/onboarding/onboarding-keyboard.ts +5 -1
- package/src/components/onboarding/onboarding-wizard.tsx +15 -4
- package/src/components/onboarding/portfolio-step/positions-panel.tsx +9 -6
- package/src/components/onboarding/use-onboarding-progress.ts +20 -1
- package/src/components/price-sparkline/view.tsx +14 -6
- package/src/components/ticker/badge/index.tsx +8 -4
- package/src/components/ticker/badge/list.tsx +23 -7
- package/src/components/ui/column-grid.tsx +8 -2
- package/src/components/ui/data-table/index.tsx +5 -1
- package/src/components/ui/data-table/opentui/model.ts +4 -1
- package/src/components/ui/data-table/render-cell.ts +19 -0
- package/src/components/ui/delayed-mark.tsx +59 -7
- package/src/components/ui/icon.tsx +1 -8
- package/src/components/ui/menu.tsx +6 -1
- package/src/components/ui/tabs.tsx +5 -2
- package/src/core/state/app/layout.ts +18 -3
- package/src/core/state/app/state.ts +2 -0
- package/src/core/state/app/types.ts +5 -0
- package/src/data/config/layout.ts +3 -0
- package/src/data/config/store/normalize.ts +39 -4
- package/src/i18n/es.ts +13 -3
- package/src/i18n/ja.ts +13 -3
- package/src/i18n/ko.ts +13 -3
- package/src/i18n/zh-cn.ts +13 -3
- package/src/i18n/zh-tw.ts +13 -3
- package/src/layout/pane-manager/floating-placement.ts +7 -4
- package/src/layout/pane-manager/floating.ts +5 -2
- package/src/market-data/bond-funds.ts +19 -0
- package/src/market-data/futures-contract.ts +14 -3
- package/src/market-data/market/freshness.ts +18 -0
- package/src/market-data/market/status.ts +15 -2
- package/src/plugins/builtin/bond-calculator/headless.ts +2 -1
- package/src/plugins/builtin/bond-calculator/index.tsx +1 -1
- package/src/plugins/builtin/bond-calculator/model.ts +14 -5
- package/src/plugins/builtin/bond-calculator/pane.tsx +1 -1
- package/src/plugins/builtin/buildout/cells.tsx +25 -45
- package/src/plugins/builtin/buildout/detail/company.tsx +3 -3
- package/src/plugins/builtin/buildout/detail/index.tsx +1 -1
- package/src/plugins/builtin/buildout/detail/intel.tsx +4 -7
- package/src/plugins/builtin/buildout/detail/site.tsx +4 -4
- package/src/plugins/builtin/buildout/detail/ui.tsx +39 -38
- package/src/plugins/builtin/buildout/format.ts +23 -1
- package/src/plugins/builtin/buildout/model/types.ts +1 -0
- package/src/plugins/builtin/buildout/pane/index.tsx +2 -8
- package/src/plugins/builtin/buildout/table-model.ts +12 -4
- package/src/plugins/builtin/cds/headless.ts +1 -0
- package/src/plugins/builtin/cds/index.tsx +1 -1
- package/src/plugins/builtin/chat/content/composer.tsx +21 -27
- package/src/plugins/builtin/chat/content/index.tsx +31 -3
- package/src/plugins/builtin/chat/content/shortcuts.ts +4 -2
- package/src/plugins/builtin/chat/content/snapshot.ts +0 -3
- package/src/plugins/builtin/cloud/auth-actions.tsx +51 -23
- package/src/plugins/builtin/cloud/plugin.tsx +2 -0
- package/src/plugins/builtin/cloud/trial-offer-status-widget.tsx +3 -3
- package/src/plugins/builtin/cloud/upgrade-status-widget.tsx +44 -12
- package/src/plugins/builtin/congress-trades/model.ts +2 -1
- package/src/plugins/builtin/congress-trades/pane.tsx +3 -0
- package/src/plugins/builtin/correlation/headless.ts +3 -2
- package/src/plugins/builtin/crypto-board/pane.tsx +5 -4
- package/src/plugins/builtin/custom-view/index.tsx +1 -1
- package/src/plugins/builtin/custom-view/loader.ts +85 -8
- package/src/plugins/builtin/custom-view/view-spec.ts +28 -0
- package/src/plugins/builtin/debt-maturities/headless.ts +11 -2
- package/src/plugins/builtin/debt-maturities/model.ts +66 -0
- package/src/plugins/builtin/debt-maturities/pane.tsx +23 -4
- package/src/plugins/builtin/earnings-ripple/pane.tsx +1 -1
- package/src/plugins/builtin/econ/calendar-model.ts +28 -6
- package/src/plugins/builtin/equity-screener/client.ts +1 -1
- package/src/plugins/builtin/equity-screener/criterion-editor.tsx +16 -19
- package/src/plugins/builtin/equity-screener/headless.ts +37 -3
- package/src/plugins/builtin/equity-screener/ideas.ts +67 -3
- package/src/plugins/builtin/equity-screener/model.ts +238 -27
- package/src/plugins/builtin/equity-screener/pane.tsx +88 -18
- package/src/plugins/builtin/equity-screener/screen-check.ts +7 -4
- package/src/plugins/builtin/equity-screener/watchlist.ts +33 -0
- package/src/plugins/builtin/executives/format.ts +5 -4
- package/src/plugins/builtin/executives/pane.tsx +1 -1
- package/src/plugins/builtin/futures-curve/client.ts +19 -0
- package/src/plugins/builtin/futures-curve/headless.ts +52 -13
- package/src/plugins/builtin/futures-curve/index.tsx +1 -1
- package/src/plugins/builtin/futures-curve/model.ts +77 -6
- package/src/plugins/builtin/futures-curve/pane.tsx +19 -3
- package/src/plugins/builtin/help/index.tsx +55 -1
- package/src/plugins/builtin/insider/model.ts +30 -2
- package/src/plugins/builtin/jobs/model.ts +2 -2
- package/src/plugins/builtin/macro-day/client.ts +41 -0
- package/src/plugins/builtin/macro-day/headless.ts +19 -9
- package/src/plugins/builtin/macro-day/model.ts +3 -1
- package/src/plugins/builtin/market-movers/index.tsx +4 -3
- package/src/plugins/builtin/mna/distress/headless.ts +1 -0
- package/src/plugins/builtin/mna/model.ts +2 -2
- package/src/plugins/builtin/notes/files.ts +2 -0
- package/src/plugins/builtin/notes/owner.tsx +20 -1
- package/src/plugins/builtin/notes/quick-notes-pane.tsx +22 -4
- package/src/plugins/builtin/notes/store.ts +6 -1
- package/src/plugins/builtin/perps/pane.tsx +3 -1
- package/src/plugins/builtin/portfolio-list/cli/bulk-symbols.ts +17 -0
- package/src/plugins/builtin/portfolio-list/cli/portfolio-command.ts +2 -1
- package/src/plugins/builtin/portfolio-list/cli/watchlist-command.ts +2 -1
- package/src/plugins/builtin/portfolio-list/header.tsx +1 -1
- package/src/plugins/builtin/rate-path/headless.ts +24 -10
- package/src/plugins/builtin/research/corporate-actions-pane.tsx +29 -25
- package/src/plugins/builtin/research/event-model.ts +10 -3
- package/src/plugins/builtin/research/events-headless.ts +20 -2
- package/src/plugins/builtin/sec/fund-facts.ts +17 -1
- package/src/plugins/builtin/sec/index.tsx +1 -1
- package/src/plugins/builtin/series-inventory.ts +1 -0
- package/src/plugins/builtin/shared/earnings-report.ts +7 -2
- package/src/plugins/builtin/shared/members-menu.tsx +103 -38
- package/src/plugins/builtin/shared/use-quote-board.ts +85 -46
- package/src/plugins/builtin/short-interest/headless.ts +1 -1
- package/src/plugins/builtin/short-interest/model.ts +15 -6
- package/src/plugins/builtin/short-interest/publications-model.ts +22 -1
- package/src/plugins/builtin/short-interest/publications-pane.tsx +13 -4
- package/src/plugins/builtin/short-interest/types.ts +2 -0
- package/src/plugins/builtin/short-interest/watch-model.ts +1 -1
- package/src/plugins/builtin/thirteenf/overlap-pane.tsx +3 -0
- package/src/plugins/builtin/thirteenf/pane.tsx +3 -0
- package/src/plugins/builtin/ticker-detail/overview/model.ts +5 -3
- package/src/plugins/builtin/ticker-detail/overview-tab.tsx +4 -4
- package/src/plugins/builtin/time-sales/pane.tsx +3 -2
- package/src/plugins/builtin/trace-bonds/client.ts +7 -4
- package/src/plugins/builtin/trace-bonds/detail.tsx +198 -0
- package/src/plugins/builtin/trace-bonds/headless.ts +62 -4
- package/src/plugins/builtin/trace-bonds/history.ts +155 -0
- package/src/plugins/builtin/trace-bonds/index.tsx +1 -1
- package/src/plugins/builtin/trace-bonds/pane.tsx +64 -5
- package/src/plugins/builtin/volatility/client.ts +6 -1
- package/src/plugins/builtin/volatility/headless.ts +0 -1
- package/src/plugins/builtin/yield-curve/curves.ts +15 -0
- package/src/plugins/builtin/yield-curve/headless.ts +6 -1
- package/src/plugins/builtin/yield-curve/index.tsx +5 -8
- package/src/plugins/host-modules.ts +22 -3
- package/src/plugins/host-smoke.ts +6 -3
- package/src/plugins/installer.ts +16 -3
- package/src/plugins/plugin-names.ts +11 -2
- package/src/portfolio/collection-name.ts +19 -0
- package/src/remote/controller.ts +9 -2
- package/src/remote/schema.ts +2 -1
- package/src/renderers/browser/http-proxy-transport.ts +78 -8
- package/src/renderers/cloudflare/http-proxy.ts +73 -3
- package/src/renderers/cloudflare/proxy-session.ts +47 -24
- package/src/renderers/cloudflare/worker.ts +44 -4
- package/src/renderers/desktop/geometry.ts +279 -0
- package/src/renderers/desktop/screen-setup.ts +246 -0
- package/src/renderers/desktop/sequential-window-host.ts +179 -0
- package/src/renderers/desktop/test-utils.ts +71 -0
- package/src/renderers/desktop/window-controller.ts +433 -0
- package/src/renderers/desktop/window-host.ts +70 -0
- package/src/renderers/desktop/window-layouts.ts +630 -0
- package/src/renderers/dom/data-frames.ts +15 -4
- package/src/renderers/dom/desktop/icons.tsx +0 -2
- package/src/renderers/dom/styles.css +0 -3
- package/src/renderers/electrobun/bun/application-menu/click.ts +1 -0
- package/src/renderers/electrobun/bun/application-menu/index.ts +4 -1
- package/src/renderers/electrobun/bun/desktop/backend-requests.ts +19 -8
- package/src/renderers/electrobun/bun/desktop/backend.ts +320 -19
- package/src/renderers/electrobun/bun/desktop/detached-windows.ts +83 -61
- package/src/renderers/electrobun/bun/desktop/host-requests.ts +4 -14
- package/src/renderers/electrobun/bun/desktop/initialization.ts +30 -11
- package/src/renderers/electrobun/bun/desktop/install-records.ts +59 -0
- package/src/renderers/electrobun/bun/desktop/installer-folder.ts +208 -592
- package/src/renderers/electrobun/bun/desktop/macos-objc.ts +14 -0
- package/src/renderers/electrobun/bun/desktop/screen-setup-file.ts +55 -0
- package/src/renderers/electrobun/bun/desktop/state-broadcaster.ts +44 -8
- package/src/renderers/electrobun/bun/desktop/update.ts +1 -1
- package/src/renderers/electrobun/bun/desktop/workspace/index.ts +298 -97
- package/src/renderers/electrobun/bun/desktop/workspace/requests.ts +44 -6
- package/src/renderers/electrobun/bun/index.ts +22 -109
- package/src/renderers/electrobun/bun/window/create.ts +23 -3
- package/src/renderers/electrobun/bun/window/electrobun-window-host.ts +306 -0
- package/src/renderers/electrobun/bun/window/events.ts +4 -4
- package/src/renderers/electrobun/bun/window/focus.ts +0 -25
- package/src/renderers/electrobun/bun/window/frame.ts +2 -1
- package/src/renderers/electrobun/bun/window/native-min-size.ts +322 -0
- package/src/renderers/electrobun/bun/window/remembered-frame.ts +4 -82
- package/src/renderers/electrobun/shared/protocol.ts +44 -2
- package/src/renderers/electrobun/view/backend-rpc.ts +16 -1
- package/src/renderers/electrobun/view/desktop/window/bridge.ts +63 -3
- package/src/renderers/electrobun/view/main.tsx +13 -7
- package/src/series/fred-argument.ts +17 -0
- package/src/sources/gloomberb-cloud/index.ts +5 -7
- package/src/sources/provider-router/batches.ts +18 -3
- package/src/sources/provider-router/financial-routes.ts +7 -1
- package/src/sources/provider-router/financials.ts +18 -4
- package/src/state/app/context/index.tsx +16 -2
- package/src/state/desktop-windows.ts +63 -0
- package/src/sync/other-window-tabs.ts +62 -0
- package/src/tickers/company-name-listing.ts +23 -3
- package/src/tickers/listing-fate.ts +147 -1
- package/src/tickers/terminal-codes.ts +5 -0
- package/src/time-series/types.ts +6 -0
- package/src/types/config.ts +10 -1
- package/src/types/data-provider.ts +14 -0
- package/src/types/desktop-window.ts +71 -2
- package/src/types/financials.ts +19 -3
- package/src/types/headless.ts +21 -0
- package/src/types/plugin.ts +6 -0
- package/src/ui/index.tsx +14 -13
- package/src/ui/same-props.ts +58 -0
- package/src/utils/cli-output.ts +33 -4
- package/src/utils/double-escape-close.ts +38 -16
- package/src/utils/format.ts +30 -5
- package/src/utils/futures-generic.ts +12 -0
- package/src/utils/http-proxy-upstream.ts +6 -2
- package/src/utils/plugin-proxy-hosts.json +0 -4
- package/src/utils/plugin-proxy-hosts.ts +22 -0
- package/src/utils/price-earnings.ts +18 -0
- package/src/utils/sec-filings.ts +7 -1
- package/patches/electrobun@1.18.1.patch +0 -633
- package/src/api-client/types.ts +0 -2441
|
@@ -383,6 +383,11 @@ const LEGAL_FORMS: ReadonlySet<string> = new Set([
|
|
|
383
383
|
"GMBH", "KGAA", "BHD", "TBK", "PCL",
|
|
384
384
|
]);
|
|
385
385
|
|
|
386
|
+
/** Whether a word is a company's legal form (`INC`, `AG`, `PLC`), the last word of a name. */
|
|
387
|
+
export function isLegalForm(word: string): boolean {
|
|
388
|
+
return LEGAL_FORMS.has(word.toUpperCase());
|
|
389
|
+
}
|
|
390
|
+
|
|
386
391
|
/** Two words, the second a company's legal form (`SAP SE`, `VOLVO AB`): a name to look up before reading it as a code. */
|
|
387
392
|
export function endsInLegalForm(raw: string): boolean {
|
|
388
393
|
const words = normalizeTyped(raw).split(" ");
|
package/src/time-series/types.ts
CHANGED
|
@@ -210,6 +210,12 @@ export interface ResolvedSeries {
|
|
|
210
210
|
* over an FX rate) prints at: the most its legs print, from two to four.
|
|
211
211
|
*/
|
|
212
212
|
valueDecimals?: number;
|
|
213
|
+
/**
|
|
214
|
+
* The grid a price quoted in fractions of a point moves on (a Treasury
|
|
215
|
+
* future's half or quarter 32nd): its axis ticks fall on multiples of it,
|
|
216
|
+
* never on decimal steps that read 104-25.60. Unset for decimal prices.
|
|
217
|
+
*/
|
|
218
|
+
tickGrid?: number;
|
|
213
219
|
/** Volume basis established by the source instrument; omitted when unspecified. */
|
|
214
220
|
volumeUnit?: "shares" | "contracts";
|
|
215
221
|
nativeFrequency: SeriesPeriod;
|
package/src/types/config.ts
CHANGED
|
@@ -869,6 +869,11 @@ export function normalizePaneLayout(
|
|
|
869
869
|
resolveOrphanSymbol?: (instanceId: string) => string | null;
|
|
870
870
|
/** Pins an orphaned follower on its last symbol; by default only its binding changes. */
|
|
871
871
|
pinOrphan?: (instance: PaneInstanceConfig, symbol: string | null) => PaneInstanceConfig;
|
|
872
|
+
/**
|
|
873
|
+
* Panes outside this layout that a pane here may follow: on another
|
|
874
|
+
* desktop window's tab. A link to one is not orphaned.
|
|
875
|
+
*/
|
|
876
|
+
externalSourceIds?: ReadonlySet<string>;
|
|
872
877
|
},
|
|
873
878
|
): LayoutConfig {
|
|
874
879
|
const fallbackSourceId = options?.defaultFollowSourceInstanceId ?? null;
|
|
@@ -898,7 +903,11 @@ export function normalizePaneLayout(
|
|
|
898
903
|
const orphanPins = new Map<string, PaneInstanceConfig>();
|
|
899
904
|
|
|
900
905
|
for (const instance of nextLayout.instances) {
|
|
901
|
-
if (
|
|
906
|
+
if (
|
|
907
|
+
instance.binding?.kind === "follow"
|
|
908
|
+
&& !validInstanceIds.has(instance.binding.sourceInstanceId)
|
|
909
|
+
&& !options?.externalSourceIds?.has(instance.binding.sourceInstanceId)
|
|
910
|
+
) {
|
|
902
911
|
// Structural helpers remove the source before the app can resolve its last ticker. Preserve
|
|
903
912
|
// the dangling binding until the runtime normalizes again with a resolver.
|
|
904
913
|
if (!options?.resolveOrphanSymbol) continue;
|
|
@@ -223,6 +223,13 @@ export interface QuoteBatchResult {
|
|
|
223
223
|
target: QuoteSubscriptionTarget;
|
|
224
224
|
quote: Quote | null;
|
|
225
225
|
error?: unknown;
|
|
226
|
+
/**
|
|
227
|
+
* Set only with `deferFollowUps`: the batch left this target without a
|
|
228
|
+
* current quote, and `getQuote` with this cache mode is the read that
|
|
229
|
+
* settles it. `quote` meanwhile is the dated price the batch had, flagged
|
|
230
|
+
* stale, or none.
|
|
231
|
+
*/
|
|
232
|
+
followUp?: "default" | "refresh";
|
|
226
233
|
}
|
|
227
234
|
|
|
228
235
|
export interface QuoteBatchOptions {
|
|
@@ -241,6 +248,13 @@ export interface QuoteBatchOptions {
|
|
|
241
248
|
* each form's own copy from whenever it was last asked for.
|
|
242
249
|
*/
|
|
243
250
|
revalidate?: boolean;
|
|
251
|
+
/**
|
|
252
|
+
* Answer from the cache and the batch read alone: a target they leave
|
|
253
|
+
* without a current quote comes back with `followUp` instead of being
|
|
254
|
+
* asked for on its own. A board paints the batch as soon as it answers and
|
|
255
|
+
* asks for those itself, so a slow one holds only its own row.
|
|
256
|
+
*/
|
|
257
|
+
deferFollowUps?: boolean;
|
|
244
258
|
/** The caller stopped waiting; a transport that can abandon the request does. */
|
|
245
259
|
signal?: AbortSignal;
|
|
246
260
|
/** The caller prints what each move is from (MarketDataRequestContext.datesChangeBasis). */
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { PaneRuntimeState } from "../core/state/app/state";
|
|
2
|
-
import type { AppConfig } from "./config";
|
|
2
|
+
import type { AppConfig, SavedLayout } from "./config";
|
|
3
3
|
|
|
4
4
|
export interface DesktopSharedStateSnapshot {
|
|
5
5
|
config: AppConfig;
|
|
@@ -12,6 +12,66 @@ export interface DesktopSharedStateSnapshot {
|
|
|
12
12
|
brokerSyncErrors?: Record<string, string>;
|
|
13
13
|
mainStateRevision?: number;
|
|
14
14
|
layoutChanged?: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* The tickers of panes in other windows that panes in this one follow, by
|
|
17
|
+
* pane id: a link keeps working when the pane it follows moved away.
|
|
18
|
+
*/
|
|
19
|
+
linkedTickers?: Record<string, string>;
|
|
20
|
+
/**
|
|
21
|
+
* The number of a state the desktop process sent. A window's next sync
|
|
22
|
+
* names the one it last took, so only what it changed since counts.
|
|
23
|
+
*/
|
|
24
|
+
stateSeq?: number;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** A full desktop window, as the others list it to move a tab or a pane there. */
|
|
28
|
+
export interface DesktopWindowInfo {
|
|
29
|
+
id: string;
|
|
30
|
+
/** Its place in the order windows opened in: 1 for the main window. */
|
|
31
|
+
number: number;
|
|
32
|
+
/** The tab it shows. */
|
|
33
|
+
activeLayoutName: string;
|
|
34
|
+
tabCount: number;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* A tab another full window holds, at its place among all the tabs. The main
|
|
39
|
+
* window's cloud sync pushes and pulls every window's tabs, not only its own.
|
|
40
|
+
*/
|
|
41
|
+
export interface OtherWindowTab {
|
|
42
|
+
at: number;
|
|
43
|
+
tab: SavedLayout;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** Where a tab or pane goes: one of the open windows, or a new one. */
|
|
47
|
+
export type DesktopWindowTarget = { windowId: string } | { newWindow: true };
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* The desktop app's full windows, for the window that holds this. Each has
|
|
51
|
+
* its own tabs; a tab or a pane can move to another, and focus can follow.
|
|
52
|
+
*/
|
|
53
|
+
export interface DesktopWindowsBridge {
|
|
54
|
+
/** This window's id. */
|
|
55
|
+
readonly windowId: string;
|
|
56
|
+
/** Every full window, this one included, in the order they opened. */
|
|
57
|
+
list(): DesktopWindowInfo[];
|
|
58
|
+
subscribe(listener: () => void): () => void;
|
|
59
|
+
/** A new window on an empty tab of its own. */
|
|
60
|
+
openWindow(): Promise<void>;
|
|
61
|
+
/** Moves a tab of this window. Resolves false when it cannot go (this window's last tab, for the main window). */
|
|
62
|
+
moveLayout(layoutId: string, target: DesktopWindowTarget): Promise<boolean>;
|
|
63
|
+
movePane(paneId: string, target: DesktopWindowTarget): Promise<boolean>;
|
|
64
|
+
focusWindow(windowId: string): Promise<void>;
|
|
65
|
+
/** Brings forward the window showing a pane in another window, on the pane's tab, with the pane focused. */
|
|
66
|
+
focusPane(paneId: string): Promise<boolean>;
|
|
67
|
+
/** Asked by another window to focus one of this window's panes. */
|
|
68
|
+
subscribeFocusRequests(listener: (paneId: string) => void): () => void;
|
|
69
|
+
/**
|
|
70
|
+
* The tabs the other windows hold, for cloud sync; the same array until
|
|
71
|
+
* they change, which `subscribe` reports. Only the main window is sent
|
|
72
|
+
* them, and only while there is more than one window.
|
|
73
|
+
*/
|
|
74
|
+
otherWindowTabs(): readonly OtherWindowTab[];
|
|
15
75
|
}
|
|
16
76
|
|
|
17
77
|
export interface DesktopDockPreviewState {
|
|
@@ -26,7 +86,16 @@ export interface DesktopThemePreviewState {
|
|
|
26
86
|
export interface DesktopWindowBridge {
|
|
27
87
|
kind: "main" | "detached";
|
|
28
88
|
paneId?: string;
|
|
29
|
-
|
|
89
|
+
/**
|
|
90
|
+
* False in a full window other than the main one: it has its own tabs, but
|
|
91
|
+
* the app-wide work (cloud sync, the session, the Dock badge, deep links,
|
|
92
|
+
* remote control) stays with the main window.
|
|
93
|
+
*/
|
|
94
|
+
primary?: boolean;
|
|
95
|
+
/** The full windows, where the shell has more than one. */
|
|
96
|
+
windows?: DesktopWindowsBridge;
|
|
97
|
+
/** `baseSeq` is the `stateSeq` of the last state this window took, or null when it built on its own last sync. */
|
|
98
|
+
syncMainState?(snapshot: DesktopSharedStateSnapshot, baseSeq?: number | null): Promise<void>;
|
|
30
99
|
syncThemePreview?(preview: DesktopThemePreviewState): Promise<void>;
|
|
31
100
|
replaceDetachedPaneState?(paneId: string, paneState: PaneRuntimeState): Promise<void>;
|
|
32
101
|
popOutPane?(paneId: string): Promise<void>;
|
package/src/types/financials.ts
CHANGED
|
@@ -350,13 +350,25 @@ export interface Fundamentals extends DepositaryReceiptFacts {
|
|
|
350
350
|
marketCap?: number;
|
|
351
351
|
marketCapCurrency?: string;
|
|
352
352
|
trailingPE?: number;
|
|
353
|
+
/** The price over next fiscal year's consensus EPS; absent when that EPS is not positive or there is none. */
|
|
353
354
|
forwardPE?: number;
|
|
354
355
|
/**
|
|
355
|
-
*
|
|
356
|
-
* unit
|
|
357
|
-
*
|
|
356
|
+
* Next fiscal year's consensus EPS behind `forwardPE`, per share in the
|
|
357
|
+
* unit of the multiple's price, so the multiple can be repriced from a live
|
|
358
|
+
* quote. Served negative without a multiple (N/M); absent otherwise.
|
|
358
359
|
*/
|
|
359
360
|
forwardEps?: number;
|
|
361
|
+
/** The currency `forwardEps` is in. */
|
|
362
|
+
forwardEpsCurrency?: string;
|
|
363
|
+
/**
|
|
364
|
+
* The end of the fiscal year the consensus is for (`2027-12-31` is FY27).
|
|
365
|
+
* Null when the source was asked and had no consensus for next year, or
|
|
366
|
+
* only one from before the listing's last split; absent from a block
|
|
367
|
+
* served before Gloom Cloud read consensus.
|
|
368
|
+
*/
|
|
369
|
+
forwardEpsPeriodEnd?: string | null;
|
|
370
|
+
/** When the consensus was read. */
|
|
371
|
+
forwardEpsObservedAt?: string;
|
|
360
372
|
pegRatio?: number;
|
|
361
373
|
enterpriseValue?: number;
|
|
362
374
|
enterpriseToRevenue?: number;
|
|
@@ -643,6 +655,10 @@ export interface DeclaredCash {
|
|
|
643
655
|
}
|
|
644
656
|
|
|
645
657
|
export interface CompanyProfile {
|
|
658
|
+
/** Who the profile is of, as the source names it beside its facts: another listing's name where one took the symbol. */
|
|
659
|
+
name?: string;
|
|
660
|
+
/** Where its issuer is domiciled, as the source gives it (NL, US). */
|
|
661
|
+
country?: string;
|
|
646
662
|
description?: string;
|
|
647
663
|
/**
|
|
648
664
|
* Who published the description and where, when it is quoted from a
|
package/src/types/headless.ts
CHANGED
|
@@ -93,6 +93,8 @@ export interface HeadlessPaneOptionDef {
|
|
|
93
93
|
list?: boolean;
|
|
94
94
|
/** The option in use as typed after the function, such as `--expiration 2028-01-21`; the catalog shows it as an example. */
|
|
95
95
|
example?: string;
|
|
96
|
+
/** Other uses the catalog shows after `example`: a form of the value the first does not show. */
|
|
97
|
+
examples?: readonly string[];
|
|
96
98
|
/** The example runs without the function's optional argument, as an option that works only then does (`fn INS --side sell`). */
|
|
97
99
|
exampleWithoutArgument?: boolean;
|
|
98
100
|
/**
|
|
@@ -511,6 +513,12 @@ export interface HeadlessRowsResult extends HeadlessPaneResultBase {
|
|
|
511
513
|
textRows?: HeadlessPaneRow[];
|
|
512
514
|
/** What the report says when `rows` is empty, in place of "No data.": why there are none. */
|
|
513
515
|
empty?: string;
|
|
516
|
+
/**
|
|
517
|
+
* Sections the text report prints under the rows, drawn as a bundle's are:
|
|
518
|
+
* the figures a pane shows beside its table (a curve's spreads). JSON keeps
|
|
519
|
+
* them in `metadata`, and the exports leave them out.
|
|
520
|
+
*/
|
|
521
|
+
textSections?: HeadlessBundleSection[];
|
|
514
522
|
/**
|
|
515
523
|
* The row fields naming each row's own unit, symbol and observation date
|
|
516
524
|
* (an ISO date or instant), for rows of several series dated apart: each
|
|
@@ -696,6 +704,13 @@ export interface HeadlessPaneDefinition<Shape extends HeadlessPaneShape = Headle
|
|
|
696
704
|
* means and the commands that run them, and `catalog ivol` lists them first.
|
|
697
705
|
*/
|
|
698
706
|
suggestFor?: string[];
|
|
707
|
+
/**
|
|
708
|
+
* Words that name one case of the function, each with the argument it
|
|
709
|
+
* takes for it: CTM opens the VIX futures curve for `VX` and `vix
|
|
710
|
+
* futures`. `fn VX` runs `CTM VIX` and says so, and `catalog vx` lists
|
|
711
|
+
* the function first.
|
|
712
|
+
*/
|
|
713
|
+
opens?: ReadonlyArray<{ words: readonly string[]; argument: string }>;
|
|
699
714
|
intents?: string[];
|
|
700
715
|
dataRequirements?: string[];
|
|
701
716
|
limitations?: string[];
|
|
@@ -723,6 +738,12 @@ export interface HeadlessPaneDefinition<Shape extends HeadlessPaneShape = Headle
|
|
|
723
738
|
* points at GIP's 1-minute bars). `key` is the listing as read, RMS:ASX.
|
|
724
739
|
*/
|
|
725
740
|
usListingsOnlyHint?(key: string): string;
|
|
741
|
+
/**
|
|
742
|
+
* The ticker argument also takes a FRED series as the catalog writes it
|
|
743
|
+
* (`FRED:T10Y2Y`), which reaches `load` as typed instead of being read as a
|
|
744
|
+
* listing: MDAY reads a spread's moves on release days.
|
|
745
|
+
*/
|
|
746
|
+
fredSeriesArgument?: boolean;
|
|
726
747
|
/**
|
|
727
748
|
* A typed symbol the function reads as another before it is resolved, with
|
|
728
749
|
* the note that says so: OPX and OVDV read a bare BTC or ETH as the coin
|
package/src/types/plugin.ts
CHANGED
|
@@ -482,6 +482,12 @@ interface PaneTemplateShortcut {
|
|
|
482
482
|
*/
|
|
483
483
|
keepArgToken?: (token: string) => boolean;
|
|
484
484
|
argOptional?: boolean;
|
|
485
|
+
/**
|
|
486
|
+
* The argument is a company the function reports on (CDS, TRACE): with
|
|
487
|
+
* none typed, the command bar opens it on the ticker in focus, and with no
|
|
488
|
+
* ticker in focus market-wide. `<ticker> <code>` opens it too.
|
|
489
|
+
*/
|
|
490
|
+
focusedIssuer?: boolean;
|
|
485
491
|
/**
|
|
486
492
|
* With no argument typed and none to infer from the active ticker, open
|
|
487
493
|
* the pane without one instead of asking for it (ERN alone is the market
|
package/src/ui/index.tsx
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { createElement, forwardRef, useCallback, useRef, type ComponentProps } from "react";
|
|
1
|
+
import { createElement, forwardRef, memo, useCallback, useRef, type ComponentProps } from "react";
|
|
2
2
|
import { useForwardedScrollBoxRef, useRegisterPaneScrollBox } from "../state/pane-scroll-registry";
|
|
3
3
|
import { useUiHost, type UiHost } from "./host";
|
|
4
4
|
import { scrollBoxScrollsVertically } from "./scroll-box-axis";
|
|
5
5
|
import { useRemoteUiNode } from "../remote/semantic-tree";
|
|
6
|
+
import { markPure, samePureProps } from "./same-props";
|
|
6
7
|
import { assignRef } from "../react/assign-ref";
|
|
7
8
|
import {
|
|
8
9
|
remoteChartEvent,
|
|
@@ -60,7 +61,7 @@ export type {
|
|
|
60
61
|
TextareaRenderable,
|
|
61
62
|
} from "./host";
|
|
62
63
|
|
|
63
|
-
export const Box = forwardRef<any, ComponentProps<UiHost["Box"]>>((props, ref) => {
|
|
64
|
+
export const Box = markPure(memo(forwardRef<any, ComponentProps<UiHost["Box"]>>((props, ref) => {
|
|
64
65
|
const { Box: HostBox } = useUiHost();
|
|
65
66
|
const rawProps = props as Record<string, unknown>;
|
|
66
67
|
const onMouseDown = rawProps.onMouseDown as ((event?: unknown) => unknown) | undefined;
|
|
@@ -84,10 +85,10 @@ export const Box = forwardRef<any, ComponentProps<UiHost["Box"]>>((props, ref) =
|
|
|
84
85
|
: null,
|
|
85
86
|
);
|
|
86
87
|
return createElement(HostBox as any, { ...props, ref, "data-gloom-remote-node-id": remoteNodeId ?? undefined });
|
|
87
|
-
});
|
|
88
|
+
}), samePureProps));
|
|
88
89
|
Box.displayName = "Box";
|
|
89
90
|
|
|
90
|
-
export const Text = forwardRef<any, ComponentProps<UiHost["Text"]>>((props, ref) => {
|
|
91
|
+
export const Text = markPure(memo(forwardRef<any, ComponentProps<UiHost["Text"]>>((props, ref) => {
|
|
91
92
|
const { Text: HostText } = useUiHost();
|
|
92
93
|
const rawProps = props as Record<string, unknown>;
|
|
93
94
|
const onMouseDown = rawProps.onMouseDown as ((event?: unknown) => unknown) | undefined;
|
|
@@ -105,25 +106,25 @@ export const Text = forwardRef<any, ComponentProps<UiHost["Text"]>>((props, ref)
|
|
|
105
106
|
: null,
|
|
106
107
|
);
|
|
107
108
|
return createElement(HostText as any, { ...props, ref, "data-gloom-remote-node-id": remoteNodeId ?? undefined });
|
|
108
|
-
});
|
|
109
|
+
}), samePureProps));
|
|
109
110
|
Text.displayName = "Text";
|
|
110
111
|
|
|
111
|
-
export const Span = forwardRef<any, ComponentProps<UiHost["Span"]>>((props, ref) => {
|
|
112
|
+
export const Span = markPure(memo(forwardRef<any, ComponentProps<UiHost["Span"]>>((props, ref) => {
|
|
112
113
|
const { Span: HostSpan } = useUiHost();
|
|
113
114
|
return createElement(HostSpan as any, { ...props, ref });
|
|
114
|
-
});
|
|
115
|
+
}), samePureProps));
|
|
115
116
|
Span.displayName = "Span";
|
|
116
117
|
|
|
117
|
-
export const Strong = forwardRef<any, ComponentProps<UiHost["Strong"]>>((props, ref) => {
|
|
118
|
+
export const Strong = markPure(memo(forwardRef<any, ComponentProps<UiHost["Strong"]>>((props, ref) => {
|
|
118
119
|
const { Strong: HostStrong } = useUiHost();
|
|
119
120
|
return createElement(HostStrong as any, { ...props, ref });
|
|
120
|
-
});
|
|
121
|
+
}), samePureProps));
|
|
121
122
|
Strong.displayName = "Strong";
|
|
122
123
|
|
|
123
|
-
export const Underline = forwardRef<any, ComponentProps<UiHost["Underline"]>>((props, ref) => {
|
|
124
|
+
export const Underline = markPure(memo(forwardRef<any, ComponentProps<UiHost["Underline"]>>((props, ref) => {
|
|
124
125
|
const { Underline: HostUnderline } = useUiHost();
|
|
125
126
|
return createElement(HostUnderline as any, { ...props, ref });
|
|
126
|
-
});
|
|
127
|
+
}), samePureProps));
|
|
127
128
|
Underline.displayName = "Underline";
|
|
128
129
|
|
|
129
130
|
export const ScrollBox = forwardRef<any, ComponentProps<UiHost["ScrollBox"]>>((props, ref) => {
|
|
@@ -242,7 +243,7 @@ export const Textarea = forwardRef<any, ComponentProps<UiHost["Textarea"]>>(({
|
|
|
242
243
|
});
|
|
243
244
|
Textarea.displayName = "Textarea";
|
|
244
245
|
|
|
245
|
-
export const ChartSurface = forwardRef<any, ComponentProps<UiHost["ChartSurface"]>>((props, ref) => {
|
|
246
|
+
export const ChartSurface = markPure(memo(forwardRef<any, ComponentProps<UiHost["ChartSurface"]>>((props, ref) => {
|
|
246
247
|
const { ChartSurface: HostChartSurface } = useUiHost();
|
|
247
248
|
const rawProps = props as Record<string, unknown>;
|
|
248
249
|
const localRef = useRef<any>(null);
|
|
@@ -285,7 +286,7 @@ export const ChartSurface = forwardRef<any, ComponentProps<UiHost["ChartSurface"
|
|
|
285
286
|
},
|
|
286
287
|
});
|
|
287
288
|
return createElement(HostChartSurface as any, { ...props, ref: setSurfaceRef, "data-gloom-remote-node-id": remoteNodeId ?? undefined });
|
|
288
|
-
});
|
|
289
|
+
}), samePureProps));
|
|
289
290
|
ChartSurface.displayName = "ChartSurface";
|
|
290
291
|
|
|
291
292
|
export const ImageSurface = forwardRef<any, ComponentProps<UiHost["ImageSurface"]>>((props, ref) => {
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { isValidElement } from "react";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Memoized components that render from their props and context alone, such
|
|
5
|
+
* as the kit's Box and Text: two elements of one with equal props render the
|
|
6
|
+
* same thing.
|
|
7
|
+
*/
|
|
8
|
+
const pureTypes = new WeakSet<object>();
|
|
9
|
+
|
|
10
|
+
/** Marks a memoized component as rendering from its props and context alone. */
|
|
11
|
+
export function markPure<T extends object>(type: T): T {
|
|
12
|
+
pureTypes.add(type);
|
|
13
|
+
return type;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/** How many elements and arrays deep a comparison looks before calling props different. */
|
|
17
|
+
const MAX_DEPTH = 6;
|
|
18
|
+
|
|
19
|
+
function sameValue(left: unknown, right: unknown, depth: number): boolean {
|
|
20
|
+
if (Object.is(left, right)) return true;
|
|
21
|
+
if (depth >= MAX_DEPTH || typeof left !== "object" || typeof right !== "object" || !left || !right) return false;
|
|
22
|
+
if (Array.isArray(left)) {
|
|
23
|
+
if (!Array.isArray(right) || left.length !== right.length) return false;
|
|
24
|
+
for (let index = 0; index < left.length; index += 1) {
|
|
25
|
+
if (!sameValue(left[index], right[index], depth + 1)) return false;
|
|
26
|
+
}
|
|
27
|
+
return true;
|
|
28
|
+
}
|
|
29
|
+
if (!isValidElement(left) || !isValidElement(right)) return false;
|
|
30
|
+
// Any other component may read more than its props while it renders, so
|
|
31
|
+
// only a pure component's element counts as the same for equal props.
|
|
32
|
+
return left.type === right.type
|
|
33
|
+
&& left.key === right.key
|
|
34
|
+
&& typeof left.type === "object"
|
|
35
|
+
&& pureTypes.has(left.type)
|
|
36
|
+
&& sameProps(left.props as Record<string, unknown>, right.props as Record<string, unknown>, depth + 1);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* The memo test for a pure component: props are the same when each is equal,
|
|
41
|
+
* where elements of pure components (a Box of Texts) compare by their props
|
|
42
|
+
* instead of by identity, as a parent builds them afresh on each render.
|
|
43
|
+
* Functions and other objects still compare by identity.
|
|
44
|
+
*/
|
|
45
|
+
export function samePureProps<P extends object>(left: Readonly<P>, right: Readonly<P>): boolean {
|
|
46
|
+
return sameProps(left as Record<string, unknown>, right as Record<string, unknown>, 0);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function sameProps(left: Record<string, unknown>, right: Record<string, unknown>, depth: number): boolean {
|
|
50
|
+
if (left === right) return true;
|
|
51
|
+
let count = 0;
|
|
52
|
+
for (const key in left) {
|
|
53
|
+
count += 1;
|
|
54
|
+
if (!Object.prototype.hasOwnProperty.call(right, key) || !sameValue(left[key], right[key], depth)) return false;
|
|
55
|
+
}
|
|
56
|
+
for (const _key in right) count -= 1;
|
|
57
|
+
return count === 0;
|
|
58
|
+
}
|
package/src/utils/cli-output.ts
CHANGED
|
@@ -389,21 +389,50 @@ export interface CliStatsOptions {
|
|
|
389
389
|
width?: number | null;
|
|
390
390
|
}
|
|
391
391
|
|
|
392
|
+
/** The fewest cells a stat's value is given beside its label; a longer label goes on a line of its own. */
|
|
393
|
+
const MIN_STAT_VALUE_WIDTH = 20;
|
|
394
|
+
|
|
395
|
+
/**
|
|
396
|
+
* The label column of a stats block: its longest label, unless that leaves
|
|
397
|
+
* the values fewer than MIN_STAT_VALUE_WIDTH cells of `width`. Then it is the
|
|
398
|
+
* longest label that leaves them that many, and longer ones go above their values.
|
|
399
|
+
*/
|
|
400
|
+
function statLabelWidth(entries: readonly CliStatEntry[], width: number | null, indent: number): number {
|
|
401
|
+
const widths = entries.map(([label]) => visibleLength(label));
|
|
402
|
+
const longest = Math.max(0, ...widths);
|
|
403
|
+
if (width == null) return longest;
|
|
404
|
+
const fits = width - indent - COLUMN_GAP - MIN_STAT_VALUE_WIDTH;
|
|
405
|
+
return longest <= fits ? longest : Math.max(0, ...widths.filter((labelWidth) => labelWidth <= fits));
|
|
406
|
+
}
|
|
407
|
+
|
|
392
408
|
/** Cells left for values after a block's labels, for callers that build nested values. */
|
|
393
409
|
export function statValueWidth(entries: readonly CliStatEntry[], options: CliStatsOptions = {}): number | null {
|
|
394
410
|
const width = options.width === undefined ? cliTerminalWidth() : options.width;
|
|
395
411
|
if (width == null) return null;
|
|
396
|
-
const
|
|
397
|
-
return Math.max(
|
|
412
|
+
const indent = options.indent ?? 0;
|
|
413
|
+
return Math.max(MIN_STAT_VALUE_WIDTH, width - indent - statLabelWidth(entries, width, indent) - COLUMN_GAP);
|
|
398
414
|
}
|
|
399
415
|
|
|
400
|
-
/**
|
|
416
|
+
/**
|
|
417
|
+
* A block of label/value lines aligned on the longest label. Values wrap under
|
|
418
|
+
* themselves; in a narrow width a label too long to leave its value room is
|
|
419
|
+
* on its own line, its value indented under it.
|
|
420
|
+
*/
|
|
401
421
|
export function renderStats(entries: readonly CliStatEntry[], options: CliStatsOptions = {}): string {
|
|
402
422
|
const indent = " ".repeat(options.indent ?? 0);
|
|
403
|
-
const
|
|
423
|
+
const width = options.width === undefined ? cliTerminalWidth() : options.width;
|
|
424
|
+
const labelWidth = statLabelWidth(entries, width, indent.length);
|
|
404
425
|
const valueIndent = `${indent}${" ".repeat(labelWidth + COLUMN_GAP)}`;
|
|
405
426
|
const valueWidth = statValueWidth(entries, options);
|
|
406
427
|
return entries.map(([label, value]) => {
|
|
428
|
+
if (width != null && visibleLength(label) > labelWidth) {
|
|
429
|
+
// Above its value, which is indented under it across the width.
|
|
430
|
+
const under = `${indent}${" ".repeat(COLUMN_GAP)}`;
|
|
431
|
+
return [
|
|
432
|
+
...wrapText(label, Math.max(1, width - indent.length)).map((line) => `${indent}${cliStyles.muted(line)}`),
|
|
433
|
+
...wrapText(value, Math.max(1, width - under.length)).map((line) => `${under}${line}`.trimEnd()),
|
|
434
|
+
].join("\n");
|
|
435
|
+
}
|
|
407
436
|
const valueLines = valueWidth == null ? value.split("\n") : wrapText(value, valueWidth);
|
|
408
437
|
const [first = "", ...rest] = valueLines;
|
|
409
438
|
return [
|
|
@@ -23,10 +23,11 @@ export function resetDoubleEscapeClose(state: DoubleEscapeCloseState) {
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
|
-
* Key handling for a double-Esc close: `take`
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
26
|
+
* Key handling for a double-Esc close: `take` closes on the second Esc of a
|
|
27
|
+
* pair, before the pane sees it, and `arm` makes an Esc the first half. Every
|
|
28
|
+
* Esc arms, whatever the pane does with it (back out of a detail, clear a
|
|
29
|
+
* selection, leave a chart), except an Esc that leaves a draft or closes a
|
|
30
|
+
* menu: see `countEscapeTowardClose` and `keepEscapeFromClosing`.
|
|
30
31
|
*/
|
|
31
32
|
export function takeDoubleEscapeClose(
|
|
32
33
|
state: DoubleEscapeCloseState,
|
|
@@ -42,24 +43,45 @@ export function takeDoubleEscapeClose(
|
|
|
42
43
|
return matched;
|
|
43
44
|
}
|
|
44
45
|
|
|
45
|
-
|
|
46
|
+
interface EscapeOffer {
|
|
47
|
+
count(): void;
|
|
48
|
+
keep(): void;
|
|
49
|
+
kept: boolean;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const escapeOffers = new WeakMap<object, EscapeOffer>();
|
|
46
53
|
|
|
47
54
|
/**
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
* The shell offers every Esc in its `before` phase, focused field or not; a
|
|
51
|
-
* pane handler that runs later takes the offer with `countEscapeTowardClose`
|
|
52
|
-
* and consumes the Esc as usual. Anything the Esc backs out of (a draft, a
|
|
53
|
-
* reply, a menu) keeps it from counting.
|
|
55
|
+
* The shell offers every Esc to the pane before any handler runs, so a
|
|
56
|
+
* handler in any phase can say what its Esc did to the close.
|
|
54
57
|
*/
|
|
55
|
-
export function offerEscapeTowardClose(event: object,
|
|
56
|
-
|
|
58
|
+
export function offerEscapeTowardClose(event: object, offer: { count(): void; keep(): void }) {
|
|
59
|
+
escapeOffers.set(event, { ...offer, kept: false });
|
|
57
60
|
}
|
|
58
61
|
|
|
62
|
+
/**
|
|
63
|
+
* In a text field, or while a pane is editing, an Esc counts only when the
|
|
64
|
+
* pane says it left nothing typed behind: Esc Esc from an empty composer
|
|
65
|
+
* closes the pane, from a draft it never does.
|
|
66
|
+
*/
|
|
59
67
|
export function countEscapeTowardClose(event: object) {
|
|
60
|
-
const
|
|
61
|
-
|
|
62
|
-
|
|
68
|
+
const offer = escapeOffers.get(event);
|
|
69
|
+
if (offer && !offer.kept) offer.count();
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* An Esc that closes a menu or popover of the pane's own, or backs out of a
|
|
74
|
+
* draft, is not the first half of a close.
|
|
75
|
+
*/
|
|
76
|
+
export function keepEscapeFromClosing(event: object) {
|
|
77
|
+
const offer = escapeOffers.get(event);
|
|
78
|
+
if (!offer) return;
|
|
79
|
+
offer.kept = true;
|
|
80
|
+
offer.keep();
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export function isEscapeKeptFromClosing(event: object): boolean {
|
|
84
|
+
return escapeOffers.get(event)?.kept === true;
|
|
63
85
|
}
|
|
64
86
|
|
|
65
87
|
export function armDoubleEscapeClose(
|
package/src/utils/format.ts
CHANGED
|
@@ -132,11 +132,31 @@ export function formatPercentRaw(value: number | undefined): string {
|
|
|
132
132
|
return `${signedFixed(value, 2)}%`;
|
|
133
133
|
}
|
|
134
134
|
|
|
135
|
+
let figureColumnCells = 0;
|
|
136
|
+
|
|
135
137
|
/**
|
|
136
|
-
*
|
|
137
|
-
*
|
|
138
|
+
* Formats one cell of a right-aligned table column. Inside it `formatCompact`
|
|
139
|
+
* keeps its decimals unless the caller passes `fixedDecimals: false`, so a
|
|
140
|
+
* column of compact figures lines up: 12.00M over 10.73M, 10.0k over 12.5k.
|
|
141
|
+
* The table kit draws, reports and exports every right-aligned cell through
|
|
142
|
+
* this, so a pane's cell keeps the short 12M wherever else it says it (a
|
|
143
|
+
* figure, a sentence, a label).
|
|
138
144
|
*/
|
|
139
|
-
export function
|
|
145
|
+
export function inFigureColumn<T>(format: () => T): T {
|
|
146
|
+
figureColumnCells += 1;
|
|
147
|
+
try {
|
|
148
|
+
return format();
|
|
149
|
+
} finally {
|
|
150
|
+
figureColumnCells -= 1;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Format large numbers compactly (e.g., 1.5T, 234B, 12.3M, 5k). In a table
|
|
156
|
+
* column (`inFigureColumn`), or with `fixedDecimals`, the decimals stay so
|
|
157
|
+
* 1.70T lines up with 1.33T.
|
|
158
|
+
*/
|
|
159
|
+
export function formatCompact(value: number | undefined, { fixedDecimals = figureColumnCells > 0 }: { fixedDecimals?: boolean } = {}): string {
|
|
140
160
|
if (value == null || !Number.isFinite(value)) return MISSING_VALUE;
|
|
141
161
|
const { fixed, suffix } = compactParts(Math.abs(value));
|
|
142
162
|
// Strip unnecessary trailing zeros after decimal point
|
|
@@ -204,9 +224,14 @@ export function formatNumber(value: number | undefined, decimals = 2): string {
|
|
|
204
224
|
export function formatSignificant(value: number | undefined, digits = 4): string {
|
|
205
225
|
if (value == null || !Number.isFinite(value)) return formatNumber(undefined);
|
|
206
226
|
if (value === 0) return getNumberFormatter(0).format(0);
|
|
227
|
+
return getNumberFormatter(significantDecimals(value, digits)).format(Number(value.toPrecision(digits)));
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/** The decimals `formatSignificant` writes a value to: 0.8904 has 4, 1.123 has 3, 0 none. */
|
|
231
|
+
export function significantDecimals(value: number, digits = 4): number {
|
|
232
|
+
if (value === 0 || !Number.isFinite(value)) return 0;
|
|
207
233
|
const rounded = Number(value.toPrecision(digits));
|
|
208
|
-
|
|
209
|
-
return getNumberFormatter(decimals).format(rounded);
|
|
234
|
+
return Math.min(12, Math.max(0, digits - 1 - Math.floor(Math.log10(Math.abs(rounded)))));
|
|
210
235
|
}
|
|
211
236
|
|
|
212
237
|
/** A percentile rank with its window: "73 pctl 1Y", "-- pctl 1Y" when unranked, "73 pctl" without a window. */
|
|
@@ -68,6 +68,18 @@ const STANDARD_ROLL_DAYS: Readonly<Record<string, number>> = {
|
|
|
68
68
|
VX: 0,
|
|
69
69
|
};
|
|
70
70
|
|
|
71
|
+
/**
|
|
72
|
+
* Continuous symbols written as other roots' are (`CL=F`) for a root that has
|
|
73
|
+
* none, Cboe's VIX futures: `VX=F` is the front generic VX1, which follows
|
|
74
|
+
* the same front contract.
|
|
75
|
+
*/
|
|
76
|
+
const GENERIC_FOR_ALIAS: Readonly<Record<string, string>> = { "VX=F": "VX1" };
|
|
77
|
+
|
|
78
|
+
/** The front generic a continuous symbol the root does not list stands for (VX=F: VX1), or null. */
|
|
79
|
+
export function continuousAliasGeneric(symbol: string): string | null {
|
|
80
|
+
return GENERIC_FOR_ALIAS[symbol.trim().toUpperCase()] ?? null;
|
|
81
|
+
}
|
|
82
|
+
|
|
71
83
|
/** A root's standard roll: what a bare generic (NG1) and the continuous alias (NG=F) follow. */
|
|
72
84
|
export function standardFuturesGenericRoll(root: string): FuturesGenericRoll {
|
|
73
85
|
return { rule: "first-notice", days: STANDARD_ROLL_DAYS[root] ?? 1, standard: true };
|
|
@@ -53,6 +53,10 @@ export async function fetchCheckingRedirects(
|
|
|
53
53
|
init: ProxiedRequestInit,
|
|
54
54
|
options: { fetch: typeof fetch; check: ProxyTargetCheck; signal: AbortSignal },
|
|
55
55
|
): Promise<ProxyUpstreamResult> {
|
|
56
|
+
// Taken off `options` before calling: `options.fetch(...)` would call the
|
|
57
|
+
// runtime's fetch with `options` as `this`, which Cloudflare Workers reject
|
|
58
|
+
// with "Illegal invocation", failing every proxied request.
|
|
59
|
+
const { fetch: fetchUpstream, check, signal } = options;
|
|
56
60
|
const headers = upstreamHeaders(init.headers);
|
|
57
61
|
const mode = init.redirect ?? "follow";
|
|
58
62
|
let url = first;
|
|
@@ -60,7 +64,7 @@ export async function fetchCheckingRedirects(
|
|
|
60
64
|
let body = init.body;
|
|
61
65
|
|
|
62
66
|
for (let followed = 0; ; followed += 1) {
|
|
63
|
-
const response = await
|
|
67
|
+
const response = await fetchUpstream(url, { method, headers, body, redirect: "manual", signal });
|
|
64
68
|
const location = REDIRECT_STATUSES.has(response.status) ? response.headers.get("location") : null;
|
|
65
69
|
// "manual" hands the redirect back to the plugin. If it follows it, that
|
|
66
70
|
// comes back through here as a new request and is checked like one.
|
|
@@ -77,7 +81,7 @@ export async function fetchCheckingRedirects(
|
|
|
77
81
|
// Intentional ignore: a Location that does not parse is reported as an invalid redirect, never followed.
|
|
78
82
|
return { error: "The upstream sent an invalid redirect.", status: 502 };
|
|
79
83
|
}
|
|
80
|
-
const target = await
|
|
84
|
+
const target = await check(next);
|
|
81
85
|
if ("error" in target) return { error: `The upstream redirect was refused. ${target.error}`, status: 502 };
|
|
82
86
|
|
|
83
87
|
if (target.url.origin !== url.origin) {
|