gloomberb 0.20.3 → 0.20.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/account/auth-dialog.tsx +17 -0
- package/src/api-client/data.ts +6 -0
- package/src/api-client/fx-interventions.ts +64 -0
- package/src/api-client/index.ts +1 -0
- package/src/api-client/release-summaries.ts +21 -0
- package/src/app/keybindings/actions.ts +2 -2
- package/src/app/pane-runtime/ticker-open-runtime.ts +245 -66
- package/src/cli/commands/market.ts +77 -1
- package/src/cli/commands/news-search.ts +1 -3
- package/src/cli/commands/plugins.ts +27 -5
- package/src/cli/commands/system.ts +19 -3
- package/src/cli/commands/ticker.ts +60 -19
- package/src/cli/index.ts +8 -8
- package/src/cli/pane-functions/function-help.ts +3 -3
- package/src/cli/report-tables.ts +18 -6
- package/src/cli/result.ts +15 -7
- package/src/cli/types.ts +2 -0
- package/src/components/chart/composite/axis-overlays.tsx +22 -0
- package/src/components/chart/composite/composite-chart.tsx +54 -13
- package/src/components/chart/composite/event-captions.ts +109 -0
- package/src/components/chart/composite/event-guides.ts +74 -0
- package/src/components/chart/composite/rasterizer.ts +2 -0
- package/src/components/chart/composite/text-renderer.ts +2 -0
- package/src/components/chart/composite/types.ts +31 -0
- package/src/components/command-bar/layout-items/focused-pane.ts +5 -5
- package/src/components/command-bar/routes/root/provider-search.ts +5 -4
- package/src/components/command-bar/routes/ticker-search/results.ts +51 -0
- package/src/components/command-bar/routes/ticker-search/route.ts +3 -2
- package/src/components/layout/detached-pane-shell.tsx +1 -1
- package/src/components/layout/floating-pane.tsx +5 -1
- package/src/components/layout/pane/footer/index.tsx +21 -14
- package/src/components/layout/pane/footer/model.ts +6 -0
- package/src/components/layout/shell/action-menu-overlay.tsx +10 -5
- package/src/components/layout/shell/active-drag.ts +149 -105
- package/src/components/layout/shell/drag/drop-zones.ts +162 -0
- package/src/components/layout/shell/drag/index.ts +47 -218
- package/src/components/layout/shell/drag/live.ts +10 -3
- package/src/components/layout/shell/drag/overlays.tsx +182 -5
- package/src/components/layout/shell/drag/runtime.ts +29 -6
- package/src/components/layout/shell/drag/shared-edges.ts +156 -0
- package/src/components/layout/shell/index.tsx +11 -6
- package/src/components/layout/shell/menu.ts +11 -2
- package/src/components/layout/shell/native/pointer-runtime.ts +25 -0
- package/src/components/layout/shell/native/window-state.ts +2 -2
- package/src/components/layout/shell/pane/layers.tsx +71 -7
- package/src/components/layout/shell/terminal-pointer-runtime.ts +18 -9
- package/src/components/layout/shell/window-mode/index.ts +8 -10
- package/src/components/layout/window-edit/mode.ts +39 -7
- package/src/components/layout/window-edit/presentation.ts +1 -1
- package/src/components/onboarding/onboarding-keyboard.ts +4 -0
- package/src/components/onboarding/onboarding-wizard.tsx +8 -3
- package/src/components/ui/button.tsx +2 -0
- package/src/components/ui/choice-dialog.tsx +1 -0
- package/src/components/ui/data-table/index.tsx +4 -3
- package/src/components/ui/list-view.tsx +7 -12
- package/src/components/ui/loading.tsx +10 -3
- package/src/components/ui/menu.tsx +6 -2
- package/src/components/ui/quote.ts +14 -1
- package/src/data/config/layout.ts +5 -2
- package/src/docs/snapshot.json +29 -5
- package/src/i18n/es.ts +9 -8
- package/src/i18n/ja.ts +9 -8
- package/src/i18n/ko.ts +9 -8
- package/src/i18n/zh-cn.ts +9 -8
- package/src/i18n/zh-tw.ts +9 -8
- package/src/layout/pane-manager/floating-actions.ts +17 -0
- package/src/layout/pane-manager/floating-stack.ts +187 -0
- package/src/layout/pane-manager/floating.ts +4 -2
- package/src/layout/pane-manager/gridlock.ts +5 -1
- package/src/layout/pane-manager/index.ts +11 -0
- package/src/layout/pane-manager/layout-state.ts +10 -3
- package/src/market-data/futures-board.ts +46 -1
- package/src/market-data/futures-contract.ts +12 -3
- package/src/market-data/fx-interventions.ts +270 -0
- package/src/news/news-model.ts +44 -2
- package/src/plugins/builtin/alerts/cli.ts +4 -4
- package/src/plugins/builtin/alerts/format.ts +1 -2
- package/src/plugins/builtin/alerts/headless.ts +1 -2
- package/src/plugins/builtin/alerts/move-checks.ts +12 -6
- package/src/plugins/builtin/alerts/move.ts +30 -9
- package/src/plugins/builtin/alerts/pane.tsx +0 -2
- package/src/plugins/builtin/alerts/storage.ts +4 -2
- package/src/plugins/builtin/alerts/types.ts +12 -0
- package/src/plugins/builtin/changelog/index.tsx +292 -101
- package/src/plugins/builtin/changelog/versions.ts +293 -0
- package/src/plugins/builtin/chart-composer/intervention-events.ts +105 -0
- package/src/plugins/builtin/chart-composer/pane.tsx +21 -7
- package/src/plugins/builtin/chat/message/render-state.ts +2 -5
- package/src/plugins/builtin/cloud/askg/attached-pane.tsx +10 -5
- package/src/plugins/builtin/cloud/askg/controller.ts +141 -5
- package/src/plugins/builtin/cloud/askg/executor.ts +113 -4
- package/src/plugins/builtin/cloud/askg/manifest.ts +28 -13
- package/src/plugins/builtin/cloud/askg/model.ts +14 -4
- package/src/plugins/builtin/cloud/askg/pane.tsx +70 -46
- package/src/plugins/builtin/cloud/askg/turn-parts.tsx +70 -0
- package/src/plugins/builtin/cloud/terminal-relay/engine.ts +50 -130
- package/src/plugins/builtin/cloud/terminal-relay/policy.ts +327 -7
- package/src/plugins/builtin/cloud/terminal-relay/prompts.tsx +2 -1
- package/src/plugins/builtin/cloud/terminal-relay/redact.ts +47 -6
- package/src/plugins/builtin/commodities-energy/index.tsx +1 -3
- package/src/plugins/builtin/commodities-energy/view-state.ts +3 -0
- package/src/plugins/builtin/cot/headless.ts +14 -2
- package/src/plugins/builtin/earnings/index.tsx +2 -2
- package/src/plugins/builtin/futures/index.tsx +25 -4
- package/src/plugins/builtin/futures/model.ts +28 -32
- package/src/plugins/builtin/futures/series.ts +4 -3
- package/src/plugins/builtin/futures/table.tsx +16 -9
- package/src/plugins/builtin/futures/use-board-terms.ts +3 -3
- package/src/plugins/builtin/help/index.tsx +3 -3
- package/src/plugins/builtin/help/keybindings-editor.tsx +18 -4
- package/src/plugins/builtin/layout-manager/index.tsx +8 -8
- package/src/plugins/builtin/news/headless.ts +2 -2
- package/src/plugins/builtin/news/index.tsx +3 -3
- package/src/plugins/builtin/perps/markets-section.tsx +5 -2
- package/src/plugins/builtin/plugin-marketplace/pane.tsx +11 -11
- package/src/plugins/builtin/portfolio-list/summary/index.tsx +3 -1
- package/src/plugins/builtin/research/event-model.ts +9 -1
- package/src/plugins/builtin/research/event-sources.ts +22 -0
- package/src/plugins/builtin/research/headless.ts +3 -3
- package/src/plugins/builtin/shared/cloud-upgrade.ts +27 -3
- package/src/plugins/builtin/ticker-detail/overview/components.tsx +54 -5
- package/src/plugins/builtin/ticker-detail/overview-tab.tsx +28 -13
- package/src/plugins/builtin/ticker-detail/pane.tsx +7 -2
- package/src/plugins/installer.ts +45 -0
- package/src/remote/resources.ts +12 -1
- package/src/remote/schema.ts +1 -0
- package/src/remote/semantic-helpers.ts +29 -1
- package/src/remote/semantic-tree.tsx +32 -15
- package/src/renderers/cloudflare/worker.ts +16 -1
- package/src/renderers/dom/styles.css +40 -6
- package/src/renderers/share/layout-view.tsx +1 -1
- package/src/sources/gloomberb-cloud/news.ts +35 -12
- package/src/state/opening-ticker-panes.ts +47 -0
- package/src/test-support/cli-context.ts +2 -0
- package/src/test-support/preload.ts +4 -1
- package/src/tickers/instrument-kind.ts +23 -3
- package/src/types/config.ts +5 -0
- package/src/types/context-menu.ts +2 -0
- package/src/types/plugin-commands.ts +140 -0
- package/src/types/plugin-context.ts +125 -0
- package/src/types/plugin-contributions.ts +55 -0
- package/src/types/plugin-definition.ts +234 -0
- package/src/types/plugin-notifications.ts +38 -0
- package/src/types/plugin-pane-settings.ts +114 -0
- package/src/types/plugin-pane-templates.ts +160 -0
- package/src/types/plugin-panes.ts +221 -0
- package/src/types/plugin-reports.ts +35 -0
- package/src/types/plugin-shared.ts +14 -0
- package/src/types/plugin-state.ts +71 -0
- package/src/types/plugin.ts +14 -1169
- package/src/ui/index.tsx +14 -3
- package/src/updater/github-releases.ts +23 -0
- package/src/utils/cli-output.ts +22 -9
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ReactNode } from "react";
|
|
2
2
|
import { ActionRow, ColumnGrid, ColumnGridPair, RangeTrack, usePaneLinkMenuEntry, type ColumnGridCell, type ColumnGridColumn } from "../../../../components";
|
|
3
3
|
import { t, tf } from "../../../../i18n";
|
|
4
|
-
import { formatMarketPriceWithCurrency, liveQuoteFormatOptions, type MarketFormatOptions } from "../../../../market-data/market/format";
|
|
4
|
+
import { formatMarketPrice, formatMarketPriceWithCurrency, liveQuoteFormatOptions, type MarketFormatOptions } from "../../../../market-data/market/format";
|
|
5
5
|
import { colors, hoverBg, priceColor } from "../../../../theme/colors";
|
|
6
6
|
import type { Quote } from "../../../../types/financials";
|
|
7
7
|
import { Box, Text, useUiCapabilities } from "../../../../ui";
|
|
@@ -35,16 +35,63 @@ export function rangeRowChrome(labelWidth: number, endpointWidth: number): numbe
|
|
|
35
35
|
return labelWidth + 1 + endpointWidth * 2 + 2;
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
+
/**
|
|
39
|
+
* How a range row writes its ends: as the quote prints a price ($5,072.00),
|
|
40
|
+
* or, on a row too narrow for those beside a track even under its short
|
|
41
|
+
* label, the bare number: a 27-cell CC=F pane cut its highs, "Day $5,072.00
|
|
42
|
+
* ● $5,28". From 100 up a compact end drops the decimals the low and the
|
|
43
|
+
* high do not need to read apart (5,072 and 5,287, but 150.1 and 150.4, never
|
|
44
|
+
* 150 twice); below 100 it keeps them, or 18.13 and 18.60 would read 18 and 19.
|
|
45
|
+
*/
|
|
46
|
+
type RangeEndpointStyle = "price" | "compact";
|
|
47
|
+
|
|
48
|
+
const fractionDigits = (text: string) => /\.(\d+)\D*$/.exec(text)?.[1]!.length ?? 0;
|
|
49
|
+
|
|
50
|
+
/** The options a compact range writes its two ends with: the fewest decimals that still tell them apart. */
|
|
51
|
+
function compactRangeOptions(low: number, high: number, priceOptions: MarketFormatOptions): MarketFormatOptions {
|
|
52
|
+
if (Math.max(Math.abs(low), Math.abs(high)) < 100) return priceOptions;
|
|
53
|
+
// The decimals the price has, read without the cell cap, which drops them to fit.
|
|
54
|
+
const unbounded = { ...priceOptions, maxWidth: undefined };
|
|
55
|
+
const full = Math.max(fractionDigits(formatMarketPrice(low, unbounded)), fractionDigits(formatMarketPrice(high, unbounded)));
|
|
56
|
+
for (let digits = 0; digits < full; digits += 1) {
|
|
57
|
+
const options = { ...priceOptions, fixedFractionDigits: digits, minimumFractionDigits: digits, referencePrice: undefined };
|
|
58
|
+
if (formatMarketPrice(low, options) !== formatMarketPrice(high, options)) return options;
|
|
59
|
+
}
|
|
60
|
+
return priceOptions;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** A range's two ends, in `style`. */
|
|
64
|
+
function formatRangeEndpoints(
|
|
65
|
+
low: number,
|
|
66
|
+
high: number,
|
|
67
|
+
currency: string,
|
|
68
|
+
priceOptions: MarketFormatOptions,
|
|
69
|
+
style: RangeEndpointStyle = "price",
|
|
70
|
+
): [string, string] {
|
|
71
|
+
if (style === "price") return [formatMarketPriceWithCurrency(low, currency, priceOptions), formatMarketPriceWithCurrency(high, currency, priceOptions)];
|
|
72
|
+
const options = compactRangeOptions(low, high, priceOptions);
|
|
73
|
+
return [formatMarketPrice(low, options), formatMarketPrice(high, options)];
|
|
74
|
+
}
|
|
75
|
+
|
|
38
76
|
/** The longest endpoint among ranges drawn together, so stacked tracks start and end in one column. */
|
|
39
77
|
export function rangeEndpointWidth(
|
|
40
|
-
|
|
78
|
+
ranges: ReadonlyArray<readonly [low: number, high: number]>,
|
|
41
79
|
currency: string,
|
|
42
80
|
priceOptions: MarketFormatOptions,
|
|
81
|
+
style: RangeEndpointStyle = "price",
|
|
43
82
|
): number {
|
|
44
|
-
const widths =
|
|
83
|
+
const widths = ranges.flatMap(([low, high]) => formatRangeEndpoints(low, high, currency, priceOptions, style).map(displayWidth));
|
|
45
84
|
return Math.min(RANGE_ENDPOINT_WIDTH, Math.max(1, ...widths));
|
|
46
85
|
}
|
|
47
86
|
|
|
87
|
+
/**
|
|
88
|
+
* The ends rows of `width` write: the prices while they leave a track of
|
|
89
|
+
* RANGE_MIN_TRACK_WIDTH under the short label, else the compact numbers.
|
|
90
|
+
*/
|
|
91
|
+
export function rangeEndpointStyle(width: number, shortLabelWidth: number, priceEndpointWidth: number): RangeEndpointStyle {
|
|
92
|
+
return width - rangeRowChrome(shortLabelWidth, priceEndpointWidth) < RANGE_MIN_TRACK_WIDTH ? "compact" : "price";
|
|
93
|
+
}
|
|
94
|
+
|
|
48
95
|
/**
|
|
49
96
|
* Where the price sits in a range, on one row: the label, the low, a track
|
|
50
97
|
* with a neutral marker and the high. The marker is the position, so no
|
|
@@ -62,6 +109,7 @@ export function CompactRangeBar({
|
|
|
62
109
|
grow = false,
|
|
63
110
|
currency,
|
|
64
111
|
priceOptions,
|
|
112
|
+
endpoints = "price",
|
|
65
113
|
}: {
|
|
66
114
|
current: number;
|
|
67
115
|
low: number;
|
|
@@ -80,6 +128,8 @@ export function CompactRangeBar({
|
|
|
80
128
|
currency: string;
|
|
81
129
|
/** The quote's live price options, so the endpoints keep the price's decimals. */
|
|
82
130
|
priceOptions: MarketFormatOptions;
|
|
131
|
+
/** Shared by ranges drawn together, as `endpointWidth` is (rangeEndpointStyle). */
|
|
132
|
+
endpoints?: RangeEndpointStyle;
|
|
83
133
|
}) {
|
|
84
134
|
const { nativePaneChrome } = useUiCapabilities();
|
|
85
135
|
const range = high - low;
|
|
@@ -89,8 +139,7 @@ export function CompactRangeBar({
|
|
|
89
139
|
const shownLabel = useShortLabel ? shortLabel : label;
|
|
90
140
|
const shownLabelWidth = useShortLabel ? displayWidth(shortLabel) : labelWidth;
|
|
91
141
|
const endpointOptions = { ...priceOptions, maxWidth: endpointWidth };
|
|
92
|
-
const lowText =
|
|
93
|
-
const highText = formatMarketPriceWithCurrency(high, currency, endpointOptions);
|
|
142
|
+
const [lowText, highText] = formatRangeEndpoints(low, high, currency, endpointOptions, endpoints);
|
|
94
143
|
const barWidth = Math.max(1, width - rangeRowChrome(shownLabelWidth, endpointWidth));
|
|
95
144
|
|
|
96
145
|
// The desktop and the web size the row and its track by CSS, so the high end keeps to the pane's edge on every frame of a
|
|
@@ -49,6 +49,7 @@ import {
|
|
|
49
49
|
FunctionLinkRow,
|
|
50
50
|
PositionTable,
|
|
51
51
|
QuoteBook,
|
|
52
|
+
rangeEndpointStyle,
|
|
52
53
|
rangeEndpointWidth,
|
|
53
54
|
rangeRowChrome,
|
|
54
55
|
textGridColumns,
|
|
@@ -335,6 +336,16 @@ function ResolvedOverviewTab({ width, height, focused = false, ticker, financial
|
|
|
335
336
|
? truncateToDisplayWidth(usdPerMmbtuText({ value: gasInUsd, currency: gasCurrency, usdPerUnit: gasUsdPerUnit }),
|
|
336
337
|
Math.max(1, quoteTextWidth - displayWidth(inUsdLabel) - 1))
|
|
337
338
|
: "";
|
|
339
|
+
// The extended session's line keeps its label and price whole on a narrow pane: the move gives
|
|
340
|
+
// way to its percent, then goes, rather than wrapping a figure across two lines ("(+0." / "08%)").
|
|
341
|
+
const extendedLabelText = extendedQuote ? `${extendedSessionLineLabel(extendedQuote, t)}:` : "";
|
|
342
|
+
const extendedPriceText = extendedQuote ? formatMarketPriceWithCurrency(extendedQuote.price, quote?.currency, moneyOptions) : "";
|
|
343
|
+
const extendedMoveText = extendedQuote
|
|
344
|
+
? [
|
|
345
|
+
`${formatSignedMarketPrice(extendedQuote.change, moneyOptions)} (${formatPercentRaw(extendedQuote.changePercent)})`,
|
|
346
|
+
formatPercentRaw(extendedQuote.changePercent),
|
|
347
|
+
].find((move) => displayWidth(extendedLabelText) + 2 + displayWidth(extendedPriceText) + 2 + displayWidth(move) <= quoteTextWidth) ?? ""
|
|
348
|
+
: "";
|
|
338
349
|
const quoteChangeCells = delisted ? 0 : figureCells(quoteChangeText, "sub") + 1 + figureCells(quotePercentText, "sub");
|
|
339
350
|
const stackQuoteChange = quoteChangeCells > quoteTextWidth;
|
|
340
351
|
const stackQuoteSummary = figureCells(quotePriceText) + 2 + quoteChangeCells > quoteTextWidth;
|
|
@@ -361,14 +372,20 @@ function ResolvedOverviewTab({ width, height, focused = false, ticker, financial
|
|
|
361
372
|
yearRange ? displayWidth(yearRangeLabel) : 0,
|
|
362
373
|
);
|
|
363
374
|
// Both ranges share one endpoint width, so stacked tracks start and end in the same column.
|
|
364
|
-
const
|
|
365
|
-
...(hasDayRange ? [quote.low!, quote.high!] : []),
|
|
366
|
-
...(yearRange ? [yearRange.low, yearRange.high] : []),
|
|
367
|
-
]
|
|
375
|
+
const rangeValues: Array<[number, number]> = [
|
|
376
|
+
...(hasDayRange ? [[quote.low!, quote.high!] as [number, number]] : []),
|
|
377
|
+
...(yearRange ? [[yearRange.low, yearRange.high] as [number, number]] : []),
|
|
378
|
+
];
|
|
379
|
+
const rangePriceCells = rangeEndpointWidth(rangeValues, quoteCurrency, moneyOptions);
|
|
368
380
|
const rangeHalfWidth = Math.floor((contentWidth - RANGE_PAIR_GAP) / 2);
|
|
369
381
|
const rangeInline = hasDayRange && yearRange != null
|
|
370
|
-
&& rangeHalfWidth - rangeRowChrome(rangeLabelWidth,
|
|
382
|
+
&& rangeHalfWidth - rangeRowChrome(rangeLabelWidth, rangePriceCells) >= RANGE_INLINE_MIN_TRACK;
|
|
371
383
|
const rangeWidth = rangeInline ? rangeHalfWidth : contentWidth;
|
|
384
|
+
// A pane too narrow for both priced ends beside a track writes them compact, both ranges alike.
|
|
385
|
+
const rangeShortLabelWidth = Math.max(hasDayRange ? displayWidth(delisted ? t("Last") : t("Day")) : 0, yearRange ? displayWidth(t("52W")) : 0);
|
|
386
|
+
const rangeEndpoints = rangeEndpointStyle(rangeWidth, rangeShortLabelWidth, rangePriceCells);
|
|
387
|
+
const rangeEndpointCells = rangeEndpoints === "price" ? rangePriceCells
|
|
388
|
+
: rangeEndpointWidth(rangeValues, quoteCurrency, moneyOptions, rangeEndpoints);
|
|
372
389
|
const contractLines = contractTerms ? futuresContractLines(contractTerms, futuresSymbol) : [];
|
|
373
390
|
// Columns that keep every term whole; a narrow pane stacks them in one.
|
|
374
391
|
const contractColumns = textGridColumns(contractLines.map(contractField), contentWidth);
|
|
@@ -503,14 +520,10 @@ function ResolvedOverviewTab({ width, height, focused = false, ticker, financial
|
|
|
503
520
|
</Box>
|
|
504
521
|
) : null}
|
|
505
522
|
{extendedQuote && (
|
|
506
|
-
<Box flexDirection="row" gap={2}>
|
|
507
|
-
<Text fg={colors.textDim}>{
|
|
508
|
-
<Text fg={priceColor(extendedQuote.change ?? 0)}>
|
|
509
|
-
|
|
510
|
-
</Text>
|
|
511
|
-
<Text fg={priceColor(extendedQuote.change ?? 0)}>
|
|
512
|
-
{formatSignedMarketPrice(extendedQuote.change, moneyOptions)} ({formatPercentRaw(extendedQuote.changePercent)})
|
|
513
|
-
</Text>
|
|
523
|
+
<Box flexDirection="row" gap={2} minWidth={0} overflow="hidden">
|
|
524
|
+
<Text flexShrink={0} fg={colors.textDim}>{extendedLabelText}</Text>
|
|
525
|
+
<Text flexShrink={0} fg={priceColor(extendedQuote.change ?? 0)}>{extendedPriceText}</Text>
|
|
526
|
+
{extendedMoveText ? <Text flexShrink={0} fg={priceColor(extendedQuote.change ?? 0)}>{extendedMoveText}</Text> : null}
|
|
514
527
|
</Box>
|
|
515
528
|
)}
|
|
516
529
|
{settleText && (
|
|
@@ -559,6 +572,7 @@ function ResolvedOverviewTab({ width, height, focused = false, ticker, financial
|
|
|
559
572
|
grow={rangeInline}
|
|
560
573
|
currency={quoteCurrency}
|
|
561
574
|
priceOptions={moneyOptions}
|
|
575
|
+
endpoints={rangeEndpoints}
|
|
562
576
|
/>
|
|
563
577
|
)}
|
|
564
578
|
{yearRange && (
|
|
@@ -574,6 +588,7 @@ function ResolvedOverviewTab({ width, height, focused = false, ticker, financial
|
|
|
574
588
|
grow={rangeInline}
|
|
575
589
|
currency={quoteCurrency}
|
|
576
590
|
priceOptions={moneyOptions}
|
|
591
|
+
endpoints={rangeEndpoints}
|
|
577
592
|
/>
|
|
578
593
|
)}
|
|
579
594
|
</Box>
|
|
@@ -19,7 +19,8 @@ import {
|
|
|
19
19
|
} from "../../../state/app/context";
|
|
20
20
|
import { useQuoteUpdates } from "../../../state/hooks/quote-streaming";
|
|
21
21
|
import { getSharedRegistry } from "../../registry";
|
|
22
|
-
import { ChoiceDialog, EmptyState, NestedPaneTabs, PaneFooterScope, usePaneFooter, usePaneMenuItems, usePaneTabs } from "../../../components";
|
|
22
|
+
import { ChoiceDialog, EmptyState, NestedPaneTabs, PaneFooterScope, PaneStatusBody, usePaneFooter, usePaneMenuItems, usePaneTabs } from "../../../components";
|
|
23
|
+
import { useTickerPaneOpening } from "../../../state/opening-ticker-panes";
|
|
23
24
|
import { useOptionalDialog, type PromptContext } from "../../../ui/dialog";
|
|
24
25
|
import { useThrottledCommitValue } from "../../../react/use-throttled-commit-value";
|
|
25
26
|
import { resolveOptionsTarget } from "../../../utils/options";
|
|
@@ -155,7 +156,9 @@ export function TickerResearchPane({ focused, width, height }: PaneProps) {
|
|
|
155
156
|
const { createPaneFromTemplate } = usePluginAppActions();
|
|
156
157
|
const config = usePaneAppConfig();
|
|
157
158
|
const paneInstance = usePaneInstance();
|
|
158
|
-
const { ticker, financials, error: instrumentError } = usePaneTicker();
|
|
159
|
+
const { symbol, ticker, financials, error: instrumentError } = usePaneTicker();
|
|
160
|
+
// Opened before its listing was found: the pane says so until the lookup settles it.
|
|
161
|
+
const opening = useTickerPaneOpening(paneInstance?.instanceId);
|
|
159
162
|
const liveStreaming = useLiveStreamingSetting();
|
|
160
163
|
const streamingTarget = quoteSubscriptionTargetFromTicker(ticker, ticker?.metadata.ticker, "provider");
|
|
161
164
|
const streamingTargets = useMemo(() => (
|
|
@@ -434,6 +437,8 @@ export function TickerResearchPane({ focused, width, height }: PaneProps) {
|
|
|
434
437
|
});
|
|
435
438
|
}, [shownTabId, visibleTabIds]);
|
|
436
439
|
|
|
440
|
+
if (!ticker && opening && symbol) return <PaneStatusBody loading subject={symbol} />;
|
|
441
|
+
|
|
437
442
|
if (!ticker) {
|
|
438
443
|
const isEmptyFollowCollection = paneInstance?.binding?.kind === "follow" && !!collectionId && collectionTickerCount === 0;
|
|
439
444
|
const message = instrumentError ?? (isEmptyFollowCollection
|
package/src/plugins/installer.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { existsSync, lstatSync, mkdirSync, readdirSync, renameSync, rmSync, syml
|
|
|
4
4
|
import { execFile as execFileCallback, execFileSync, spawn } from "child_process";
|
|
5
5
|
import { promisify } from "util";
|
|
6
6
|
import { findAbsorbedPlugin, type AbsorbedPlugin } from "./absorbed";
|
|
7
|
+
import { checkPluginCompatibility, readPluginManifest } from "./compat";
|
|
7
8
|
import type { PluginPin } from "./marketplace/store";
|
|
8
9
|
import { bunCommand, missingPluginDependencies, recordDependencyInstall } from "./dependencies";
|
|
9
10
|
import { linkHostPackages, missingPeerPlugins } from "./host-link";
|
|
@@ -849,6 +850,50 @@ export function installedPluginDirectories(): string[] {
|
|
|
849
850
|
.map((entry) => entry.name);
|
|
850
851
|
}
|
|
851
852
|
|
|
853
|
+
/**
|
|
854
|
+
* The id an installed plugin goes by: the one its gloom.json declares, which
|
|
855
|
+
* every registry plugin has and which its export repeats, else its folder.
|
|
856
|
+
* Read without importing the plugin.
|
|
857
|
+
*/
|
|
858
|
+
export function installedPluginId(directory: string): string {
|
|
859
|
+
return readPluginManifest(join(PLUGINS_DIR, directory)).id ?? directory;
|
|
860
|
+
}
|
|
861
|
+
|
|
862
|
+
/**
|
|
863
|
+
* The installed folders `name` names: the folder itself, or else every
|
|
864
|
+
* folder whose plugin goes by that id. `gloom install` names the folder for
|
|
865
|
+
* the repository (`gloom-hackernews`) while `gloom plugins` and `plugin
|
|
866
|
+
* enable` use the id (`hackernews`), so every command takes either. Two
|
|
867
|
+
* checkouts of one plugin, a clone and a linked copy, share an id.
|
|
868
|
+
*/
|
|
869
|
+
export function installedPluginDirectoriesNamed(name: string): string[] {
|
|
870
|
+
const dirs = installedPluginDirectories();
|
|
871
|
+
if (dirs.includes(name)) return [name];
|
|
872
|
+
return dirs.filter((dir) => installedPluginId(dir) === name);
|
|
873
|
+
}
|
|
874
|
+
|
|
875
|
+
/**
|
|
876
|
+
* The id the plugin in `directory` registers under, which is what the running
|
|
877
|
+
* app keys it by. Read from gloom.json when it declares one, which the export
|
|
878
|
+
* repeats (`plugin doctor` warns when it does not); otherwise from the export,
|
|
879
|
+
* but only for a checkout the loader would import, so the import is the one
|
|
880
|
+
* it already made. Null when neither answers.
|
|
881
|
+
*/
|
|
882
|
+
export async function installedPluginRegistryId(directory: string): Promise<string | null> {
|
|
883
|
+
const dir = join(PLUGINS_DIR, directory);
|
|
884
|
+
const declared = readPluginManifest(dir).id;
|
|
885
|
+
if (declared) return declared;
|
|
886
|
+
if (findAbsorbedCheckout(dir) || checkPluginCompatibility(dir)) return null;
|
|
887
|
+
const entry = await resolvePluginEntry(dir);
|
|
888
|
+
if (!entry) return null;
|
|
889
|
+
try {
|
|
890
|
+
return pluginFromModule(await import(entry))?.id ?? null;
|
|
891
|
+
} catch (error) {
|
|
892
|
+
logFailure("plugin-installer", "Installed plugin id read failed")(error);
|
|
893
|
+
return null;
|
|
894
|
+
}
|
|
895
|
+
}
|
|
896
|
+
|
|
852
897
|
/**
|
|
853
898
|
* Makes a local checkout an installed plugin without cloning it. The link is
|
|
854
899
|
* what the loader sees, so edits are live on the next reload or restart.
|
package/src/remote/resources.ts
CHANGED
|
@@ -4,7 +4,8 @@ import { apiClient } from "../api-client";
|
|
|
4
4
|
import type { AppAction, AppState } from "../state/app/context";
|
|
5
5
|
import type { PaneRuntimeState } from "../core/state/app/state";
|
|
6
6
|
import { setPaneSettings } from "../pane-settings";
|
|
7
|
-
import type
|
|
7
|
+
import { findPaneInstance, type LayoutConfig } from "../types/config";
|
|
8
|
+
import { getBasePaneDisplayTitle } from "../components/layout/pane/title";
|
|
8
9
|
import { commandBarResultsFromNodes, commandBarSnapshot } from "./command-bar";
|
|
9
10
|
import { formSnapshot } from "./form";
|
|
10
11
|
import type { RemoteUiRegistry } from "./semantic-tree";
|
|
@@ -150,6 +151,16 @@ export function createRemoteResources({
|
|
|
150
151
|
if (resource === "app://accounts") return brokerAccountsResource(state);
|
|
151
152
|
if (resource === "app://remote/help") return REMOTE_AGENT_HELP;
|
|
152
153
|
if (resource === "ui://tree") return uiNodes;
|
|
154
|
+
if (resource.startsWith("ui://node/")) {
|
|
155
|
+
const nodeId = decodeURIComponent(resource.slice("ui://node/".length));
|
|
156
|
+
const node = uiRegistry?.detail(nodeId);
|
|
157
|
+
if (!node) throw new Error(`No UI node "${nodeId}" is on screen. Read ui://tree for the current ones.`);
|
|
158
|
+
const pane = node.paneId ? findPaneInstance(state.config.layout, node.paneId) : undefined;
|
|
159
|
+
const paneDef = pane ? pluginRegistry.panes.get(pane.paneId) : undefined;
|
|
160
|
+
return pane && paneDef
|
|
161
|
+
? { ...node, paneTitle: getBasePaneDisplayTitle(state, pane, paneDef, pluginRegistry.panes) }
|
|
162
|
+
: node;
|
|
163
|
+
}
|
|
153
164
|
throw new Error(`Unknown remote resource "${resource}".`);
|
|
154
165
|
};
|
|
155
166
|
|
package/src/remote/schema.ts
CHANGED
|
@@ -32,6 +32,7 @@ export const REMOTE_RESOURCES: RemoteResourceSchema[] = [
|
|
|
32
32
|
{ uri: "app://auth", description: "What the client believes about its cloud session: credential present, checked, cached user plan and verification. No secrets." },
|
|
33
33
|
{ uri: "app://remote/help", description: "Agent-oriented remote usage guide with efficient recipes and caveats." },
|
|
34
34
|
{ uri: "ui://tree", description: "Live semantic UI node tree populated by shared controls and interactive primitives." },
|
|
35
|
+
{ uri: "ui://node/{nodeId}", description: "One node of ui://tree with what the tree leaves out: the title of the pane it is in and, for a table, every row." },
|
|
35
36
|
];
|
|
36
37
|
|
|
37
38
|
const stringSchema = { type: "string" } satisfies RemoteJsonSchema;
|
|
@@ -105,7 +105,7 @@ interface RemoteIndexSelectors<T> {
|
|
|
105
105
|
value?: RemoteItemSelector<T>;
|
|
106
106
|
}
|
|
107
107
|
|
|
108
|
-
|
|
108
|
+
function resolveRemoteItemIndex<T>(
|
|
109
109
|
input: unknown,
|
|
110
110
|
items: readonly T[],
|
|
111
111
|
selectors: RemoteIndexSelectors<T>,
|
|
@@ -125,6 +125,34 @@ export function resolveRemoteItemIndex<T>(
|
|
|
125
125
|
return -1;
|
|
126
126
|
}
|
|
127
127
|
|
|
128
|
+
// How each kit control picks an item for a remote action. The control and the
|
|
129
|
+
// policy that names the item before it runs (terminal-relay/policy.ts) both
|
|
130
|
+
// call these, so the item a person is asked about is the one that runs.
|
|
131
|
+
|
|
132
|
+
/** A Menu's `select`: the id itself, or `{ id }`, and nothing else. */
|
|
133
|
+
export function remoteMenuItemId(input: unknown): string | undefined {
|
|
134
|
+
if (typeof input === "string") return input;
|
|
135
|
+
const id = remoteObjectProp(input, "id");
|
|
136
|
+
return typeof id === "string" ? id : undefined;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/** A ListView's `select` and `activate`: by index, id or label. */
|
|
140
|
+
export function resolveRemoteListIndex<T extends { id?: unknown; label?: unknown }>(input: unknown, items: readonly T[]): number {
|
|
141
|
+
return resolveRemoteItemIndex(input, items, {
|
|
142
|
+
id: (item) => (typeof item.id === "string" ? item.id : undefined),
|
|
143
|
+
label: (item) => (typeof item.label === "string" ? item.label : undefined),
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/** A DataTable's `selectRow` and `activateRow`: by index, or by the row's key as `id` or `key`. */
|
|
148
|
+
export function resolveRemoteRowIndex<T>(
|
|
149
|
+
input: unknown,
|
|
150
|
+
rows: readonly T[],
|
|
151
|
+
keyOf: (row: T, index: number) => string | undefined,
|
|
152
|
+
): number {
|
|
153
|
+
return resolveRemoteItemIndex(input, rows, { id: keyOf, key: keyOf });
|
|
154
|
+
}
|
|
155
|
+
|
|
128
156
|
function remoteChartScroll(input: unknown) {
|
|
129
157
|
if (!input || typeof input !== "object") return undefined;
|
|
130
158
|
const record = input as Record<string, unknown>;
|
|
@@ -19,6 +19,11 @@ export interface RemoteUiNodeRegistration {
|
|
|
19
19
|
metadata?: Record<string, unknown>;
|
|
20
20
|
/** Defers expensive metadata projection until a remote snapshot requests it. */
|
|
21
21
|
getMetadata?: () => Record<string, unknown>;
|
|
22
|
+
/**
|
|
23
|
+
* What the tree leaves out for its size, read only for this one node
|
|
24
|
+
* (`ui://node/{id}`): a table's every row. Merged over its metadata.
|
|
25
|
+
*/
|
|
26
|
+
getDetail?: () => Record<string, unknown>;
|
|
22
27
|
}
|
|
23
28
|
|
|
24
29
|
interface RegisteredRemoteUiNode {
|
|
@@ -30,11 +35,29 @@ export interface RemoteUiRegistry {
|
|
|
30
35
|
register(id: string, registration: RemoteUiNodeRegistration): void;
|
|
31
36
|
unregister(id: string): void;
|
|
32
37
|
snapshot(): RemoteUiNodeSnapshot[];
|
|
38
|
+
/** One node as the tree has it, with its detail; null when it is not on screen. */
|
|
39
|
+
detail(nodeId: string): RemoteUiNodeSnapshot | null;
|
|
33
40
|
invoke(nodeId: string, action: string, input?: unknown): Promise<unknown>;
|
|
34
41
|
}
|
|
35
42
|
|
|
36
43
|
const RemoteUiRegistryContext = createContext<RemoteUiRegistry | null>(null);
|
|
37
44
|
|
|
45
|
+
function nodeSnapshot(node: RegisteredRemoteUiNode): RemoteUiNodeSnapshot {
|
|
46
|
+
const registration = node.registration;
|
|
47
|
+
return {
|
|
48
|
+
id: node.id,
|
|
49
|
+
role: registration.role,
|
|
50
|
+
label: registration.label,
|
|
51
|
+
disabled: registration.disabled,
|
|
52
|
+
actions: Object.entries(registration.actions ?? {})
|
|
53
|
+
.filter((entry): entry is [string, RemoteUiAction] => typeof entry[1] === "function")
|
|
54
|
+
.map(([action]) => action)
|
|
55
|
+
.sort(),
|
|
56
|
+
metadata: registration.getMetadata?.() ?? registration.metadata,
|
|
57
|
+
...(registration.paneId ? { paneId: registration.paneId } : {}),
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
|
|
38
61
|
export function createRemoteUiRegistry(): RemoteUiRegistry {
|
|
39
62
|
const nodes = new Map<string, RegisteredRemoteUiNode>();
|
|
40
63
|
|
|
@@ -46,21 +69,14 @@ export function createRemoteUiRegistry(): RemoteUiRegistry {
|
|
|
46
69
|
nodes.delete(id);
|
|
47
70
|
},
|
|
48
71
|
snapshot() {
|
|
49
|
-
return [...nodes.values()].map(
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
.filter((entry): entry is [string, RemoteUiAction] => typeof entry[1] === "function")
|
|
58
|
-
.map(([action]) => action)
|
|
59
|
-
.sort(),
|
|
60
|
-
metadata: registration.getMetadata?.() ?? registration.metadata,
|
|
61
|
-
...(registration.paneId ? { paneId: registration.paneId } : {}),
|
|
62
|
-
};
|
|
63
|
-
});
|
|
72
|
+
return [...nodes.values()].map(nodeSnapshot);
|
|
73
|
+
},
|
|
74
|
+
detail(nodeId) {
|
|
75
|
+
const node = nodes.get(nodeId);
|
|
76
|
+
if (!node) return null;
|
|
77
|
+
const snapshot = nodeSnapshot(node);
|
|
78
|
+
const detail = node.registration.getDetail?.();
|
|
79
|
+
return detail ? { ...snapshot, metadata: { ...snapshot.metadata, ...detail } } : snapshot;
|
|
64
80
|
},
|
|
65
81
|
async invoke(nodeId, action, input) {
|
|
66
82
|
const node = nodes.get(nodeId);
|
|
@@ -149,6 +165,7 @@ export function useRemoteUiNode(registration: RemoteUiNodeRegistration | null |
|
|
|
149
165
|
get actions() { return registrationRef.current?.actions; },
|
|
150
166
|
get metadata() { return registrationRef.current?.metadata; },
|
|
151
167
|
get getMetadata() { return registrationRef.current?.getMetadata; },
|
|
168
|
+
get getDetail() { return registrationRef.current?.getDetail; },
|
|
152
169
|
};
|
|
153
170
|
}
|
|
154
171
|
const nodeId = nodeIdRef.current;
|
|
@@ -140,6 +140,20 @@ export function withSecurityHeaders(response: Response, options: { share?: boole
|
|
|
140
140
|
return new Response(response.body, { status: response.status, statusText: response.statusText, headers });
|
|
141
141
|
}
|
|
142
142
|
|
|
143
|
+
/**
|
|
144
|
+
* Where a `/api/...` request goes: the API origin followed by the rest of the
|
|
145
|
+
* path, which must start with exactly one slash. The path is appended, never
|
|
146
|
+
* resolved against the origin, since `//host/x` (or `\host/x`, which the URL
|
|
147
|
+
* parser reads as the same) resolves to another host. Anything that does not
|
|
148
|
+
* end up on the API origin gets no upstream.
|
|
149
|
+
*/
|
|
150
|
+
function apiUpstreamUrl(url: URL): URL | null {
|
|
151
|
+
const path = url.pathname.slice("/api".length) || "/";
|
|
152
|
+
if (!path.startsWith("/") || /^\/[/\\]/.test(path)) return null;
|
|
153
|
+
const upstream = new URL(`${API_ORIGIN}${path}${url.search}`);
|
|
154
|
+
return upstream.origin === API_ORIGIN ? upstream : null;
|
|
155
|
+
}
|
|
156
|
+
|
|
143
157
|
async function proxyApi(request: Request, fetchApi: ApiFetch): Promise<Response> {
|
|
144
158
|
const url = new URL(request.url);
|
|
145
159
|
if (!API_METHODS.has(request.method)) {
|
|
@@ -152,7 +166,8 @@ async function proxyApi(request: Request, fetchApi: ApiFetch): Promise<Response>
|
|
|
152
166
|
if (origin && origin !== url.origin) {
|
|
153
167
|
return Response.json({ error: "Origin not allowed" }, { status: 403 });
|
|
154
168
|
}
|
|
155
|
-
const upstreamUrl =
|
|
169
|
+
const upstreamUrl = apiUpstreamUrl(url);
|
|
170
|
+
if (!upstreamUrl) return Response.json({ error: "Not found" }, { status: 404 });
|
|
156
171
|
return fetchApi(new Request(upstreamUrl, request));
|
|
157
172
|
}
|
|
158
173
|
|
|
@@ -674,16 +674,50 @@ button, [data-gloom-interactive="true"] { cursor: pointer; }
|
|
|
674
674
|
[data-gloom-role="dock-divider"] {
|
|
675
675
|
background: transparent !important;
|
|
676
676
|
}
|
|
677
|
-
/* Where a moving pane
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
677
|
+
/* Where a moving pane can land and where it will: one look for all of it
|
|
678
|
+
(shell/drag/drop-zones.ts, shell/drag/overlays.tsx). The accent outlines a
|
|
679
|
+
tint of itself, 12% at rest and 40% under the pointer. The landing preview
|
|
680
|
+
is the exact rectangle the pane takes (a split, a tab, an edge of the
|
|
681
|
+
layout, a floating window's tab or half, window mode's keyboard move),
|
|
682
|
+
see-through so the panes under it still show. A strip along each edge of
|
|
683
|
+
the window is see-through too, and thinner. A square of the target on the
|
|
684
|
+
pane under the pointer sits raised and opaque over it. */
|
|
681
685
|
[data-gloom-role="drop-preview"],
|
|
682
|
-
[data-gloom-role="window-mode-drop-preview"]
|
|
686
|
+
[data-gloom-role="window-mode-drop-preview"],
|
|
687
|
+
[data-gloom-role="drop-strip"],
|
|
688
|
+
[data-gloom-role="drop-zone"] {
|
|
689
|
+
--drop-tint: 12%;
|
|
690
|
+
--drop-under: transparent;
|
|
683
691
|
border: 2px solid var(--gloom-accent);
|
|
684
692
|
border-radius: var(--gloom-radius-md);
|
|
685
|
-
background: color-mix(in srgb, var(--gloom-accent)
|
|
693
|
+
background: color-mix(in srgb, var(--gloom-accent) var(--drop-tint), var(--drop-under));
|
|
686
694
|
}
|
|
695
|
+
[data-gloom-role="drop-strip"] {
|
|
696
|
+
border-width: 1px;
|
|
697
|
+
border-radius: var(--gloom-radius-sm);
|
|
698
|
+
}
|
|
699
|
+
[data-gloom-role="drop-zone"] {
|
|
700
|
+
--drop-under: var(--gloom-bg);
|
|
701
|
+
box-shadow: var(--gloom-elevation);
|
|
702
|
+
}
|
|
703
|
+
[data-gloom-role="drop-strip"][data-active="true"],
|
|
704
|
+
[data-gloom-role="drop-zone"][data-active="true"] {
|
|
705
|
+
--drop-tint: 40%;
|
|
706
|
+
}
|
|
707
|
+
/* Inside a square, the part of the pane the moving one takes: all of it for a tab, a half for a side. */
|
|
708
|
+
[data-gloom-role="drop-zone"]::before {
|
|
709
|
+
content: "";
|
|
710
|
+
position: absolute;
|
|
711
|
+
inset: var(--gloom-space-xs);
|
|
712
|
+
border-radius: var(--gloom-radius-sm);
|
|
713
|
+
background: var(--gloom-accent);
|
|
714
|
+
opacity: .5;
|
|
715
|
+
}
|
|
716
|
+
[data-gloom-role="drop-zone"][data-side="left"]::before { right: 50%; }
|
|
717
|
+
[data-gloom-role="drop-zone"][data-side="right"]::before { left: 50%; }
|
|
718
|
+
[data-gloom-role="drop-zone"][data-side="top"]::before { bottom: 50%; }
|
|
719
|
+
[data-gloom-role="drop-zone"][data-side="bottom"]::before { top: 50%; }
|
|
720
|
+
[data-gloom-role="drop-zone"][data-active="true"]::before { opacity: 1; }
|
|
687
721
|
/* The gap between the panes is the divider at rest; its line shows while it
|
|
688
722
|
is dragged or resized from the keyboard. */
|
|
689
723
|
[data-gloom-role="dock-divider"]::before {
|
|
@@ -116,7 +116,7 @@ export function LayoutShareView({
|
|
|
116
116
|
<section className="layout-workspace" aria-label={`${entry.name} layout preview`}>
|
|
117
117
|
{entry.layout.dockRoot
|
|
118
118
|
? <DockPreview node={entry.layout.dockRoot} panes={panes} />
|
|
119
|
-
: <p>No
|
|
119
|
+
: <p>No panes in the layout</p>}
|
|
120
120
|
{extra.length > 0 ? (
|
|
121
121
|
<div className="layout-extra-panes">
|
|
122
122
|
{extra.map((pane) => <PaneCard key={pane.instanceId} pane={pane} />)}
|
|
@@ -12,6 +12,8 @@ import type {
|
|
|
12
12
|
import type { CloudNewsParams } from "../../api-client/paths";
|
|
13
13
|
import { parsePublicTickerKey, publicExchange } from "../../utils/exchanges";
|
|
14
14
|
import { coinSearchName } from "../../utils/crypto-pair";
|
|
15
|
+
import { commoditySearchName } from "../../market-data/commodity-names";
|
|
16
|
+
import { futuresBoardContractForTicker } from "../../market-data/futures-board";
|
|
15
17
|
import { logFailure } from "../../utils/log-failure";
|
|
16
18
|
import { getListingSymbol, tickerHasListingSuffix } from "../listing-symbols";
|
|
17
19
|
|
|
@@ -195,12 +197,33 @@ export function cloudNewsAccess(
|
|
|
195
197
|
type CloudNewsClient = Pick<typeof apiClient, "getCloudNews" | "searchCloudNews">
|
|
196
198
|
& Partial<Pick<typeof apiClient, "hasSessionCredential">>;
|
|
197
199
|
|
|
200
|
+
/** The NI code of the metal markets: prices, futures, bullion and the trusts that hold it, not a miner's releases. */
|
|
201
|
+
export const METALS_NEWS_TOPIC = "metals";
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* What a ticker no story is filed under is searched by: a coin pair's coin
|
|
205
|
+
* ("bitcoin" for BTC-USD), or a futures board symbol's commodity ("cocoa" for
|
|
206
|
+
* CC=F), as `news` searches them. A metal's future (GC=F, SI=F, HG=F, PL=F,
|
|
207
|
+
* PA=F, ALI=F) searches the metals stories only, as `news GC=F` does: the
|
|
208
|
+
* stories that merely name gold are mostly miners' releases. Null for
|
|
209
|
+
* anything else, and for a future with no commodity name (ES=F, ZN=F).
|
|
210
|
+
*/
|
|
211
|
+
function newsFallbackSearch(query: Pick<NewsQuery, "ticker" | "exchange" | "listingName">): { text: string; topics?: string[] } | null {
|
|
212
|
+
const coin = coinSearchName(query.ticker, query.exchange, query.listingName);
|
|
213
|
+
if (coin) return { text: coin };
|
|
214
|
+
const future = query.ticker ? futuresBoardContractForTicker(parsePublicTickerKey(query.ticker).symbol) : null;
|
|
215
|
+
const text = future ? commoditySearchName(future) : null;
|
|
216
|
+
if (!future || !text) return null;
|
|
217
|
+
return future.sector === "metals" ? { text, topics: [METALS_NEWS_TOPIC] } : { text };
|
|
218
|
+
}
|
|
219
|
+
|
|
198
220
|
/**
|
|
199
221
|
* A news query's first page from Gloom Cloud. Stories are filed under company
|
|
200
|
-
* tickers, and a coin pair (BTC-USD) rarely has any filed
|
|
201
|
-
* empty feed falls back to the stories that mention the coin
|
|
202
|
-
* marked with what was searched. A
|
|
203
|
-
* no name to search keeps the
|
|
222
|
+
* tickers, and a coin pair (BTC-USD) or a future (CC=F) rarely has any filed
|
|
223
|
+
* under it, so its empty feed falls back to the stories that mention the coin
|
|
224
|
+
* or the commodity ("bitcoin", "cocoa"), marked with what was searched. A
|
|
225
|
+
* later page, a failed search or a ticker with no name to search keeps the
|
|
226
|
+
* empty answer.
|
|
204
227
|
*/
|
|
205
228
|
export async function readCloudNews(client: CloudNewsClient, query: NewsQuery): Promise<CloudNewsRead> {
|
|
206
229
|
// Asked in the tick the request goes out in, which is when its headers take the session.
|
|
@@ -208,16 +231,16 @@ export async function readCloudNews(client: CloudNewsClient, query: NewsQuery):
|
|
|
208
231
|
const response = await client.getCloudNews(cloudNewsParams(query));
|
|
209
232
|
const read: CloudNewsRead = { ...response, access: cloudNewsAccess(response, sentSession) };
|
|
210
233
|
if (response.items.length > 0 || query.cursor || normalizeNewsFeed(query) !== "ticker") return read;
|
|
211
|
-
const
|
|
212
|
-
if (!
|
|
213
|
-
const found = await client.searchCloudNews(text, query.limit)
|
|
214
|
-
.catch(logFailure("sources.gloomberb-cloud.news", "Search a
|
|
234
|
+
const search = newsFallbackSearch(query);
|
|
235
|
+
if (!search) return read;
|
|
236
|
+
const found = await client.searchCloudNews(search.text, query.limit, search.topics)
|
|
237
|
+
.catch(logFailure("sources.gloomberb-cloud.news", "Search the stories that mention a ticker's coin or commodity failed", null));
|
|
215
238
|
return found && found.items.length > 0
|
|
216
|
-
? { items: found.items, nextCursor: null, searchedFor: text, access: cloudNewsAccess(found, sentSession) }
|
|
239
|
+
? { items: found.items, nextCursor: null, searchedFor: search.text, access: cloudNewsAccess(found, sentSession) }
|
|
217
240
|
: read;
|
|
218
241
|
}
|
|
219
242
|
|
|
220
|
-
/** A read's stories as articles, each marked with the text a coin's fallback searched for. */
|
|
243
|
+
/** A read's stories as articles, each marked with the text a coin's or a future's fallback searched for. */
|
|
221
244
|
export function cloudNewsReadArticles(read: CloudNewsRead, ticker?: string): NewsArticle[] {
|
|
222
245
|
return read.items.map((item) => {
|
|
223
246
|
const article = mapCloudNewsArticle(item, read.searchedFor ? undefined : ticker);
|
|
@@ -225,7 +248,7 @@ export function cloudNewsReadArticles(read: CloudNewsRead, ticker?: string): New
|
|
|
225
248
|
});
|
|
226
249
|
}
|
|
227
250
|
|
|
228
|
-
/** What a pane or report says above the stories a
|
|
229
|
-
export function
|
|
251
|
+
/** What a pane or report says above the stories a fallback found: "No stories are filed under CC=F; these mention cocoa." */
|
|
252
|
+
export function newsFallbackNotice(ticker: string, searchedFor: string): string {
|
|
230
253
|
return `No stories are filed under ${ticker}; these mention ${searchedFor}.`;
|
|
231
254
|
}
|