@gloom-sh/terminal 0.20.4 → 0.20.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/bin/gloom +9 -0
- package/bin/without-bun.cjs +98 -0
- package/package.json +3 -1
- package/src/api-client/data.ts +138 -35
- package/src/api-client/types/econ.ts +12 -0
- package/src/api-client/yield-curves.ts +1 -1
- package/src/app/global-shortcuts.ts +4 -1
- package/src/app/keybindings/actions.ts +6 -0
- package/src/app/keybindings/config.ts +2 -1
- package/src/app/keybindings/index.ts +1 -0
- package/src/app/keybindings/labels.ts +6 -1
- package/src/app/keybindings/resolve.ts +23 -4
- package/src/app/keybindings/terminal-keys.ts +35 -0
- package/src/app/pane-runtime/index.tsx +2 -2
- package/src/app/pane-runtime/ticker-open-runtime.ts +68 -40
- package/src/architecture/ui-literals-allowlist.json +1 -1
- package/src/capabilities/chart-series.ts +27 -1
- package/src/cli/commands/keybindings.ts +5 -5
- package/src/cli/commands/market.ts +78 -21
- package/src/cli/commands/news-search.ts +59 -7
- package/src/cli/commands/overview.ts +16 -1
- package/src/cli/commands/remote.ts +16 -17
- package/src/cli/commands/system.ts +1 -1
- package/src/cli/fx-forward.ts +25 -7
- package/src/cli/glossary.ts +19 -5
- package/src/cli/history-rows.ts +5 -3
- package/src/cli/known-gaps.ts +27 -1
- package/src/cli/listing-arg.ts +11 -1
- package/src/cli/name-entries.ts +5 -1
- package/src/cli/not-a-ticker.ts +4 -0
- package/src/cli/pane-functions/function-help.ts +2 -2
- package/src/components/command-bar/pane-settings.ts +2 -2
- package/src/components/command-bar/routes/root/results.ts +6 -2
- package/src/components/input-search-bar.tsx +9 -2
- package/src/components/layout/pane/header.tsx +2 -0
- package/src/components/layout/shell/pane/capture.ts +4 -1
- package/src/components/layout/status-bar.tsx +6 -1
- package/src/components/onboarding/first-run-workspace.ts +44 -2
- package/src/components/onboarding/onboarding-frame.tsx +11 -2
- package/src/components/onboarding/onboarding-keyboard.ts +16 -0
- package/src/components/onboarding/onboarding-wizard.tsx +8 -8
- package/src/components/onboarding/portfolio-step/positions-panel.tsx +62 -1
- package/src/components/onboarding/use-onboarding-progress.ts +12 -4
- package/src/components/pane-settings-dialog/desktop.tsx +2 -2
- package/src/components/pane-settings-dialog/tui.tsx +2 -2
- package/src/components/pane-settings-dialog/value.ts +6 -0
- package/src/components/pane-settings-dialog.tsx +3 -3
- package/src/components/reader/detail-reader.tsx +4 -0
- package/src/components/ui/index.ts +1 -1
- package/src/components/ui/page-stack-view.tsx +3 -0
- package/src/components/ui/pane-link-chip.tsx +269 -54
- package/src/components/ui/query-bar.tsx +2 -1
- package/src/components/ui/tabs.tsx +97 -19
- package/src/core/state/app/layout-reducer.ts +7 -0
- package/src/core/state/app/layout.ts +44 -7
- package/src/core/state/app/state.ts +1 -1
- package/src/core/state/app/types.ts +22 -2
- package/src/docs/snapshot.json +27 -10
- package/src/market-data/depositary-pair.ts +5 -3
- package/src/market-data/market/dated-previous-close.ts +94 -15
- package/src/market-data/market/status.ts +17 -1
- package/src/plugins/builtin/analytics/risk-client.ts +10 -4
- package/src/plugins/builtin/analytics/risk-episodes.ts +5 -4
- package/src/plugins/builtin/analytics/risk-headless.ts +4 -2
- package/src/plugins/builtin/analytics/risk-sectors.ts +91 -0
- package/src/plugins/builtin/awards/index.tsx +1 -1
- package/src/plugins/builtin/buildout/index.tsx +1 -0
- package/src/plugins/builtin/catalysts/index.tsx +2 -2
- package/src/plugins/builtin/cds/headless.ts +4 -0
- package/src/plugins/builtin/chart-composer/headless.ts +2 -1
- package/src/plugins/builtin/chart-composer/index.tsx +1 -0
- package/src/plugins/builtin/chat/content/composer.tsx +5 -4
- package/src/plugins/builtin/chat/content/index.tsx +12 -2
- package/src/plugins/builtin/chat/content/layout-metrics.ts +3 -3
- package/src/plugins/builtin/chat/content/open-targets.ts +3 -3
- package/src/plugins/builtin/chat/layout.ts +5 -2
- package/src/plugins/builtin/chat/message/pane-chip.tsx +61 -40
- package/src/plugins/builtin/chat/message/terminal.tsx +13 -15
- package/src/plugins/builtin/chat/pane-links/previews.ts +51 -5
- package/src/plugins/builtin/chat/pane-links/share-card.ts +36 -0
- package/src/plugins/builtin/cloud/askg/tool-display.ts +1 -0
- package/src/plugins/builtin/cloud/terminal-relay/redact.ts +5 -3
- package/src/plugins/builtin/commodity-balances/index.tsx +1 -0
- package/src/plugins/builtin/company-attention/index.tsx +1 -1
- package/src/plugins/builtin/company-kpis/headless.ts +3 -1
- package/src/plugins/builtin/company-kpis/index.tsx +2 -2
- package/src/plugins/builtin/cot/index.tsx +1 -1
- package/src/plugins/builtin/cpi/index.tsx +1 -1
- package/src/plugins/builtin/crypto-board/index.tsx +1 -0
- package/src/plugins/builtin/dividend-yield/index.tsx +1 -0
- package/src/plugins/builtin/doe/index.tsx +1 -1
- package/src/plugins/builtin/earnings-calls/headless.ts +5 -1
- package/src/plugins/builtin/earnings-calls/index.tsx +1 -0
- package/src/plugins/builtin/econ/calendar-model.ts +74 -1
- package/src/plugins/builtin/econ/fred-catalog.ts +3 -1
- package/src/plugins/builtin/econ/index.tsx +1 -0
- package/src/plugins/builtin/econ-statistics/index.tsx +1 -0
- package/src/plugins/builtin/econ-statistics/pane.tsx +6 -0
- package/src/plugins/builtin/estimate-revisions/index.tsx +1 -0
- package/src/plugins/builtin/executives/index.tsx +1 -0
- package/src/plugins/builtin/filing-events/index.tsx +1 -0
- package/src/plugins/builtin/fixed-income/index.tsx +1 -0
- package/src/plugins/builtin/futures-curve/headless.ts +3 -3
- package/src/plugins/builtin/futures-curve/index.tsx +1 -1
- package/src/plugins/builtin/futures-curve/model.ts +18 -0
- package/src/plugins/builtin/gpu/index.tsx +1 -1
- package/src/plugins/builtin/help/functions-table.tsx +1 -1
- package/src/plugins/builtin/help/index.tsx +11 -1
- package/src/plugins/builtin/help/keybindings-editor.tsx +1 -1
- package/src/plugins/builtin/holders/index.tsx +1 -0
- package/src/plugins/builtin/holders/report-header.ts +2 -2
- package/src/plugins/builtin/insider/index.tsx +1 -0
- package/src/plugins/builtin/iv-history/index.tsx +1 -1
- package/src/plugins/builtin/jobs/index.tsx +1 -0
- package/src/plugins/builtin/macro-day/headless.ts +27 -8
- package/src/plugins/builtin/macro-day/index.tsx +1 -1
- package/src/plugins/builtin/macro-day/model.ts +19 -3
- package/src/plugins/builtin/macro-day/pane.tsx +14 -9
- package/src/plugins/builtin/macro-day/releases.ts +25 -7
- package/src/plugins/builtin/market-valuation/index.tsx +1 -0
- package/src/plugins/builtin/market-valuation/pane.tsx +8 -0
- package/src/plugins/builtin/members/index.tsx +1 -1
- package/src/plugins/builtin/mna/index.tsx +1 -0
- package/src/plugins/builtin/news/index.tsx +1 -0
- package/src/plugins/builtin/news/wire/index.tsx +5 -1
- package/src/plugins/builtin/news/wire/news/detail-view.tsx +4 -0
- package/src/plugins/builtin/news/wire/news/list-search.ts +5 -2
- package/src/plugins/builtin/options/index.tsx +1 -0
- package/src/plugins/builtin/options-positioning/index.tsx +1 -0
- package/src/plugins/builtin/pe-band/index.tsx +1 -1
- package/src/plugins/builtin/portfolio-list/cli/portfolio-command.ts +25 -0
- package/src/plugins/builtin/portfolio-list/headless.ts +15 -6
- package/src/plugins/builtin/power/index.tsx +1 -1
- package/src/plugins/builtin/realized-vol/index.tsx +1 -1
- package/src/plugins/builtin/research/headless.ts +10 -4
- package/src/plugins/builtin/research/index.tsx +4 -0
- package/src/plugins/builtin/research-search/index.tsx +1 -0
- package/src/plugins/builtin/research-search/pane.tsx +8 -0
- package/src/plugins/builtin/revenue-breakdown/index.tsx +1 -0
- package/src/plugins/builtin/reverse-dcf/index.tsx +1 -1
- package/src/plugins/builtin/risk-factors/index.tsx +1 -0
- package/src/plugins/builtin/scanner/headless.ts +52 -13
- package/src/plugins/builtin/seasonality/index.tsx +1 -1
- package/src/plugins/builtin/sec/index.tsx +1 -0
- package/src/plugins/builtin/series-inventory.ts +1 -1
- package/src/plugins/builtin/shared/scanner-capture.ts +11 -3
- package/src/plugins/builtin/shared/series-list-detail.tsx +5 -0
- package/src/plugins/builtin/short-interest/index.tsx +1 -0
- package/src/plugins/builtin/social-mentions/index.tsx +1 -1
- package/src/plugins/builtin/supply-chain/index.tsx +1 -0
- package/src/plugins/builtin/thirteenf/data.ts +43 -10
- package/src/plugins/builtin/thirteenf/headless.ts +55 -11
- package/src/plugins/builtin/thirteenf/model.ts +25 -9
- package/src/plugins/builtin/thirteenf/report-notes.ts +27 -6
- package/src/plugins/builtin/thirteenf/types.ts +2 -0
- package/src/plugins/builtin/ticker-detail/adr-pair/model.ts +1 -1
- package/src/plugins/builtin/ticker-detail/financials/model.ts +12 -0
- package/src/plugins/builtin/ticker-detail/financials/ratio-table.tsx +3 -3
- package/src/plugins/builtin/ticker-detail/financials/tab.tsx +5 -5
- package/src/plugins/builtin/ticker-detail/headless.ts +18 -13
- package/src/plugins/builtin/ticker-detail/index.tsx +4 -0
- package/src/plugins/builtin/ticker-detail/overview/model.ts +6 -4
- package/src/plugins/builtin/ticker-detail/overview-tab.tsx +6 -4
- package/src/plugins/builtin/time-sales/client.ts +9 -11
- package/src/plugins/builtin/time-sales/index.tsx +1 -1
- package/src/plugins/builtin/treasury-auctions/after.ts +267 -0
- package/src/plugins/builtin/treasury-auctions/cache.ts +18 -3
- package/src/plugins/builtin/treasury-auctions/client.ts +33 -2
- package/src/plugins/builtin/treasury-auctions/headless.ts +109 -19
- package/src/plugins/builtin/treasury-auctions/index.tsx +14 -4
- package/src/plugins/builtin/treasury-auctions/model.ts +256 -28
- package/src/plugins/builtin/treasury-auctions/pane.tsx +139 -28
- package/src/plugins/builtin/treasury-auctions/treasury-direct.ts +5 -2
- package/src/plugins/builtin/treasury-auctions/types.ts +7 -1
- package/src/plugins/builtin/vol-surface/index.tsx +1 -1
- package/src/plugins/builtin/world-venue-map/index.ts +1 -0
- package/src/plugins/builtin/yield-curve/curves.ts +10 -4
- package/src/plugins/builtin/yield-curve/headless.ts +6 -2
- package/src/plugins/builtin/yield-curve/index.tsx +3 -3
- package/src/plugins/builtin/yield-curve/series.ts +10 -0
- package/src/plugins/builtin/yield-curve/world.ts +3 -1
- package/src/portfolio/column-values.ts +2 -1
- package/src/public/__snapshots__/public-api.test.ts.snap +4 -0
- package/src/public/remote.ts +7 -1
- package/src/remote/client.ts +191 -11
- package/src/remote/controller-utils.ts +13 -1
- package/src/remote/controller.ts +88 -26
- package/src/remote/endpoint.ts +24 -0
- package/src/remote/form.ts +59 -4
- package/src/remote/resources.ts +44 -18
- package/src/remote/schema.ts +21 -9
- package/src/remote/secrets.ts +12 -0
- package/src/remote/semantic-tree.tsx +14 -2
- package/src/remote/server.ts +2 -1
- package/src/remote/surface.tsx +192 -0
- package/src/remote/types.ts +5 -0
- package/src/renderers/opentui/host.tsx +6 -0
- package/src/series/standalone.ts +2 -2
- package/src/shares/api.ts +21 -4
- package/src/shares/item.ts +73 -0
- package/src/shares/pane-item.ts +205 -0
- package/src/shares/pane.ts +4 -0
- package/src/shares/payload.ts +9 -5
- package/src/sources/gloomberb-cloud/news.ts +2 -0
- package/src/tickers/renamed-listings.ts +105 -0
- package/src/tickers/search/index.ts +103 -16
- package/src/time-series/resolve.ts +2 -2
- package/src/types/financials.ts +1 -0
- package/src/types/plugin-pane-settings.ts +2 -0
- package/src/types/plugin-panes.ts +22 -0
- package/src/utils/central-banks.ts +86 -1
- package/src/utils/datetime-format.ts +12 -3
- package/src/utils/depositary-receipt.ts +28 -3
- package/src/utils/fundamentals.ts +14 -0
- package/src/utils/max-drawdown.ts +97 -16
- package/src/utils/untrusted-text.ts +29 -0
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
import { useEffect, useRef } from "react";
|
|
2
|
+
import { usePaneFooterScopeActive } from "../components/layout/pane/footer/registration";
|
|
3
|
+
import type { ResolvedPane } from "../layout/pane-manager";
|
|
4
|
+
import { listExternalPlugins } from "../plugins/external-runtime";
|
|
5
|
+
import type { PluginRegistry } from "../plugins/registry";
|
|
6
|
+
import { resolveTickerForPane, useOptionalPaneInstanceId, type AppState } from "../state/app/context";
|
|
7
|
+
import type { PaneTemplateDef } from "../types/plugin";
|
|
8
|
+
import { logFailure } from "../utils/log-failure";
|
|
9
|
+
import { shareItem, type ShareItem } from "./item";
|
|
10
|
+
|
|
11
|
+
/** What a pane, or a part of the kit it is drawn with, says it is on. */
|
|
12
|
+
export interface PaneShareItemPart {
|
|
13
|
+
title?: string | null;
|
|
14
|
+
excerpt?: string | null;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
type PaneShareItemInput = PaneShareItemPart | null | (() => PaneShareItemPart | null);
|
|
18
|
+
|
|
19
|
+
interface Entry {
|
|
20
|
+
read(): PaneShareItemPart | null;
|
|
21
|
+
/** Said by the kit (a stack's open detail, a reader's text), which a pane's own word outranks. */
|
|
22
|
+
kit: boolean;
|
|
23
|
+
order: number;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const entries = new Map<string, Set<Entry>>();
|
|
27
|
+
let nextOrder = 0;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Says what the pane is on now, for Share to keep with its link: the story
|
|
31
|
+
* it has open, the result it has picked. Pass null when it is on nothing in
|
|
32
|
+
* particular, and a function for an item that takes work to put together:
|
|
33
|
+
* it is read only when a link is made. A tab that is not shown says nothing. `kit` marks the shared components'
|
|
34
|
+
* own guesses (a stack's detail title, a reader's opening), which a pane's
|
|
35
|
+
* own item outranks; they combine, so a stack's title takes its reader's
|
|
36
|
+
* opening as its excerpt. Any pane may say; a link reads it only from a pane
|
|
37
|
+
* that opts in with `shareItem.open` (paneShareItemFor).
|
|
38
|
+
*/
|
|
39
|
+
export function usePaneShareItem(item: PaneShareItemInput, options: { paneId?: string; kit?: boolean } = {}): void {
|
|
40
|
+
const contextPaneId = useOptionalPaneInstanceId();
|
|
41
|
+
const paneId = options.paneId ?? contextPaneId;
|
|
42
|
+
const shown = usePaneFooterScopeActive();
|
|
43
|
+
const latest = useRef(item);
|
|
44
|
+
latest.current = item;
|
|
45
|
+
const kit = options.kit === true;
|
|
46
|
+
useEffect(() => {
|
|
47
|
+
if (!paneId || !shown) return;
|
|
48
|
+
const entry: Entry = {
|
|
49
|
+
read: () => {
|
|
50
|
+
const current = latest.current;
|
|
51
|
+
return typeof current === "function" ? current() : current;
|
|
52
|
+
},
|
|
53
|
+
kit,
|
|
54
|
+
order: ++nextOrder,
|
|
55
|
+
};
|
|
56
|
+
let set = entries.get(paneId);
|
|
57
|
+
if (!set) entries.set(paneId, set = new Set());
|
|
58
|
+
set.add(entry);
|
|
59
|
+
return () => {
|
|
60
|
+
set.delete(entry);
|
|
61
|
+
if (set.size === 0 && entries.get(paneId) === set) entries.delete(paneId);
|
|
62
|
+
};
|
|
63
|
+
}, [kit, paneId, shown]);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function readEntry(entry: Entry): PaneShareItemPart | null {
|
|
67
|
+
try {
|
|
68
|
+
return entry.read();
|
|
69
|
+
} catch (error) {
|
|
70
|
+
logFailure("shares.pane-item", "Reading what a pane is on failed")(error);
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* What the pane says it is on: the pane's own item first, then the kit's,
|
|
77
|
+
* the one shown last first within each. A title without an excerpt takes the
|
|
78
|
+
* kit's excerpt (a stack's title, its reader's opening).
|
|
79
|
+
*/
|
|
80
|
+
function declaredPaneShareItem(paneId: string): PaneShareItemPart | null {
|
|
81
|
+
const said = [...entries.get(paneId) ?? []]
|
|
82
|
+
.sort((a, b) => Number(a.kit) - Number(b.kit) || b.order - a.order)
|
|
83
|
+
.map((entry) => ({ entry, part: readEntry(entry) }))
|
|
84
|
+
.filter((said): said is { entry: Entry; part: PaneShareItemPart } => !!said.part);
|
|
85
|
+
const titled = said.find(({ part }) => part.title?.trim());
|
|
86
|
+
if (!titled) return null;
|
|
87
|
+
const excerpt = titled.part.excerpt?.trim()
|
|
88
|
+
|| said.find(({ entry, part }) => entry.kit && entry !== titled.entry && part.excerpt?.trim())?.part.excerpt;
|
|
89
|
+
return { title: titled.part.title, excerpt: excerpt || null };
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export interface PaneShareItemSource {
|
|
93
|
+
/** The pane's instance id, when what it says it is on may name the item (`shareItem.open`); null when not. */
|
|
94
|
+
paneId: string | null;
|
|
95
|
+
/** The pane's name. */
|
|
96
|
+
paneName: string;
|
|
97
|
+
/** The one ticker the pane shows, with what is known of it; not a list's cursor. */
|
|
98
|
+
ticker?: { symbol: string; name?: string; exchange?: string; sector?: string; industry?: string } | null;
|
|
99
|
+
/** The argument the pane's function was opened with (`NI CRYPTO`), as its option names it. */
|
|
100
|
+
argument?: { label: string; description?: string } | null;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* The item a share keeps: what the pane says it is on, else the ticker it
|
|
105
|
+
* shows, else the argument its function was opened with; null when it is on
|
|
106
|
+
* none of these.
|
|
107
|
+
*/
|
|
108
|
+
export function resolvePaneShareItem(source: PaneShareItemSource): ShareItem | null {
|
|
109
|
+
const declared = source.paneId ? shareItem(source.paneName, declaredPaneShareItem(source.paneId)) : null;
|
|
110
|
+
if (declared) return declared;
|
|
111
|
+
const ticker = source.ticker;
|
|
112
|
+
if (ticker?.symbol) {
|
|
113
|
+
const symbol = ticker.symbol.split(":")[0] || ticker.symbol;
|
|
114
|
+
const name = ticker.name?.trim();
|
|
115
|
+
return shareItem(source.paneName, {
|
|
116
|
+
title: name && name !== symbol ? `${name} (${symbol})` : ticker.symbol,
|
|
117
|
+
excerpt: [ticker.exchange, ticker.sector, ticker.industry].filter(Boolean).join(" · "),
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
if (source.argument) return shareItem(source.paneName, { title: source.argument.label, excerpt: source.argument.description });
|
|
121
|
+
return null;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* The argument a pane's function was opened with, read from its title as the
|
|
126
|
+
* function wrote it (`NI CRYPTO`), named as the function's options name it.
|
|
127
|
+
* Only an option the function lists: words typed after it (a search, a note)
|
|
128
|
+
* are the person's own, and a ticker is not one (the pane's ticker says more).
|
|
129
|
+
*/
|
|
130
|
+
function functionArgument(
|
|
131
|
+
templates: ReadonlyMap<string, PaneTemplateDef>,
|
|
132
|
+
paneType: string,
|
|
133
|
+
title: string | undefined,
|
|
134
|
+
): PaneShareItemSource["argument"] {
|
|
135
|
+
const [code = "", ...words] = (title ?? "").trim().split(/\s+/);
|
|
136
|
+
const argument = words.join(" ");
|
|
137
|
+
if (!argument) return null;
|
|
138
|
+
const opens = (prefix: string) => prefix.toUpperCase() === code.toUpperCase();
|
|
139
|
+
const template = [...templates.values()].find((candidate) => candidate.paneId === paneType
|
|
140
|
+
&& !!candidate.shortcut
|
|
141
|
+
&& (opens(candidate.shortcut.prefix) || (candidate.shortcut.aliases ?? []).some(opens)));
|
|
142
|
+
const options = template?.shortcut?.argKind === "ticker" ? undefined : template?.shortcut?.argOptions;
|
|
143
|
+
if (!template || !options) return null;
|
|
144
|
+
try {
|
|
145
|
+
const label = options().find((option) => option.value.toUpperCase() === argument.toUpperCase())?.label;
|
|
146
|
+
return label ? { label, description: template.description } : null;
|
|
147
|
+
} catch (error) {
|
|
148
|
+
logFailure("shares.pane-item", "Reading a function's argument options failed")(error);
|
|
149
|
+
return null;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/** Fields the pane keeps on the device when shared, so nothing it shows may stand in for them. */
|
|
154
|
+
function keepsFieldsPrivate(pane: Pick<ResolvedPane, "def">): boolean {
|
|
155
|
+
const kept = pane.def.portableShare?.private;
|
|
156
|
+
return !!kept && Object.values(kept).some((fields) => fields === true || (Array.isArray(fields) && fields.length > 0));
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/** Whether a plugin loaded from outside the app (a registry or local plugin) owns the pane. */
|
|
160
|
+
function fromExternalPlugin(registry: Pick<PluginRegistry, "getPanePluginId">, paneType: string): boolean {
|
|
161
|
+
const owner = registry.getPanePluginId(paneType);
|
|
162
|
+
return !!owner && listExternalPlugins().some((entry) => entry.plugin.id === owner);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/** Whether the pane shows one ticker now: a chart of one security, not a comparison or a list. */
|
|
166
|
+
function showsOneTicker(pane: Pick<ResolvedPane, "instance" | "def">): boolean {
|
|
167
|
+
const { def, instance } = pane;
|
|
168
|
+
if (def.tickerSource) return false;
|
|
169
|
+
return typeof def.tickerFollower === "function" ? def.tickerFollower(instance) : def.tickerFollower === true;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* The item a public link to the pane keeps, or null. Only from what the pane
|
|
174
|
+
* opts into (`PaneDef.shareItem`): an alert, a form's title or a search typed
|
|
175
|
+
* in a pane that says nothing never reaches a link, nor anything from a
|
|
176
|
+
* plugin loaded from outside the app. A pane that shows the person's own data,
|
|
177
|
+
* or keeps fields of its own off a share, keeps none either: what it is on
|
|
178
|
+
* would say what its settings leave out.
|
|
179
|
+
*/
|
|
180
|
+
export function paneShareItemFor({ pane, state, registry, personal }: {
|
|
181
|
+
pane: Pick<ResolvedPane, "instance" | "def">;
|
|
182
|
+
state: Pick<AppState, "tickers"> & Parameters<typeof resolveTickerForPane>[0];
|
|
183
|
+
registry: Pick<PluginRegistry, "paneTemplates" | "getPanePluginId">;
|
|
184
|
+
/** Whether the pane shows the person's own data now (personal-pane.ts). */
|
|
185
|
+
personal: boolean;
|
|
186
|
+
}): ShareItem | null {
|
|
187
|
+
const { instance, def } = pane;
|
|
188
|
+
const allowed = def.shareItem;
|
|
189
|
+
if (!allowed || personal || keepsFieldsPrivate(pane) || fromExternalPlugin(registry, instance.paneId)) return null;
|
|
190
|
+
// The one ticker it shows; a list's cursor is where the list is, not something picked to share.
|
|
191
|
+
const symbol = allowed.ticker && showsOneTicker(pane) ? resolveTickerForPane(state, instance.instanceId) : null;
|
|
192
|
+
const metadata = symbol ? state.tickers.get(symbol)?.metadata : undefined;
|
|
193
|
+
return resolvePaneShareItem({
|
|
194
|
+
paneId: allowed.open ? instance.instanceId : null,
|
|
195
|
+
paneName: def.name,
|
|
196
|
+
ticker: symbol ? {
|
|
197
|
+
symbol,
|
|
198
|
+
name: metadata?.name,
|
|
199
|
+
exchange: metadata?.exchange,
|
|
200
|
+
sector: metadata?.sector,
|
|
201
|
+
industry: metadata?.industry,
|
|
202
|
+
} : null,
|
|
203
|
+
argument: allowed.argument ? functionArgument(registry.paneTemplates, instance.paneId, instance.title) : null,
|
|
204
|
+
});
|
|
205
|
+
}
|
package/src/shares/pane.ts
CHANGED
|
@@ -6,6 +6,7 @@ import type { PluginRegistry } from "../plugins/registry";
|
|
|
6
6
|
import type { PaneInstanceConfig } from "../types/config";
|
|
7
7
|
import type { PaneDef, PaneTemplateDef } from "../types/plugin";
|
|
8
8
|
import type { TickerRecord } from "../types/ticker";
|
|
9
|
+
import type { ShareItem } from "./item";
|
|
9
10
|
import { parseSharePayload, type PaneShareData, type SharePayload } from "./payload";
|
|
10
11
|
|
|
11
12
|
export function buildPaneSharePayload(
|
|
@@ -15,6 +16,8 @@ export function buildPaneSharePayload(
|
|
|
15
16
|
resolvedTicker?: string | null,
|
|
16
17
|
tickers?: ReadonlyMap<string, TickerRecord>,
|
|
17
18
|
pinnedTime?: number | null,
|
|
19
|
+
/** What the pane is on (pane-item.ts), kept beside its settings. */
|
|
20
|
+
item?: ShareItem | null,
|
|
18
21
|
): Extract<SharePayload, { kind: "pane" }> | null {
|
|
19
22
|
const def = pluginRegistry.panes.get(pane.paneId);
|
|
20
23
|
if (!def) return null;
|
|
@@ -37,6 +40,7 @@ export function buildPaneSharePayload(
|
|
|
37
40
|
...(description ? { description } : {}),
|
|
38
41
|
layout,
|
|
39
42
|
},
|
|
43
|
+
...(item ? { item } : {}),
|
|
40
44
|
});
|
|
41
45
|
return payload?.kind === "pane" ? payload : null;
|
|
42
46
|
} catch (error) {
|
package/src/shares/payload.ts
CHANGED
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
} from "./portable-layout";
|
|
5
5
|
import { safeExternalUrl } from "../utils/external-url";
|
|
6
6
|
import { isRecord } from "../utils/guards";
|
|
7
|
+
import { parseShareItem, type ShareItem } from "./item";
|
|
7
8
|
|
|
8
9
|
const MAX_SHARE_BYTES = 128 * 1024;
|
|
9
10
|
const MAX_TITLE_LENGTH = 200;
|
|
@@ -69,7 +70,8 @@ export type SharePayload =
|
|
|
69
70
|
| { kind: "table"; data: TableShareData }
|
|
70
71
|
| { kind: "chart"; data: ChartShareData }
|
|
71
72
|
| { kind: "article"; data: ArticleShareData }
|
|
72
|
-
|
|
73
|
+
/** `item` sits beside `data`, which apps before it read strictly and would refuse with it inside. */
|
|
74
|
+
| { kind: "pane"; data: PaneShareData; item?: ShareItem };
|
|
73
75
|
|
|
74
76
|
function shortString(value: unknown, max = MAX_TITLE_LENGTH): value is string {
|
|
75
77
|
return typeof value === "string" && value.length > 0 && value.length <= max;
|
|
@@ -195,12 +197,14 @@ export function parseSharePayload(value: unknown): SharePayload | null {
|
|
|
195
197
|
let json: string;
|
|
196
198
|
try { json = JSON.stringify(value); } catch { /* Intentional ignore: Circular or unserializable input is not a valid share payload. */ return null; }
|
|
197
199
|
if (new TextEncoder().encode(json).byteLength > MAX_SHARE_BYTES) return null;
|
|
198
|
-
if (value.kind === "table" && isTableData(value.data)) return
|
|
199
|
-
if (value.kind === "chart" && isChartData(value.data)) return
|
|
200
|
-
if (value.kind === "article" && isArticleData(value.data)) return
|
|
200
|
+
if (value.kind === "table" && isTableData(value.data)) return { kind: "table", data: value.data };
|
|
201
|
+
if (value.kind === "chart" && isChartData(value.data)) return { kind: "chart", data: value.data };
|
|
202
|
+
if (value.kind === "article" && isArticleData(value.data)) return { kind: "article", data: value.data };
|
|
201
203
|
if (value.kind === "pane") {
|
|
202
204
|
const data = parsePaneData(value.data);
|
|
203
|
-
|
|
205
|
+
// An item this app cannot read leaves the pane as it was shared, without one.
|
|
206
|
+
const item = parseShareItem(value.item);
|
|
207
|
+
if (data) return { kind: "pane", data, ...(item ? { item } : {}) };
|
|
204
208
|
}
|
|
205
209
|
return null;
|
|
206
210
|
}
|
|
@@ -199,6 +199,8 @@ type CloudNewsClient = Pick<typeof apiClient, "getCloudNews" | "searchCloudNews"
|
|
|
199
199
|
|
|
200
200
|
/** The NI code of the metal markets: prices, futures, bullion and the trusts that hold it, not a miner's releases. */
|
|
201
201
|
export const METALS_NEWS_TOPIC = "metals";
|
|
202
|
+
/** The topic the service tags oil, gas and power market stories with. */
|
|
203
|
+
export const ENERGY_NEWS_TOPIC = "energy";
|
|
202
204
|
|
|
203
205
|
/**
|
|
204
206
|
* What a ticker no story is filed under is searched by: a coin pair's coin
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { normalizeSearchText } from "./search/ranking";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A listing abroad whose company renamed itself and moved to a new symbol:
|
|
5
|
+
* the change history the data service keeps is of US listings, so `quote
|
|
6
|
+
* ELET3.SA` found nothing and its hint searched for the dead symbol again.
|
|
7
|
+
*/
|
|
8
|
+
export interface RenamedListing {
|
|
9
|
+
/** The symbol it left, as the venue writes it. */
|
|
10
|
+
from: string;
|
|
11
|
+
/** The symbol it trades as now. */
|
|
12
|
+
to: string;
|
|
13
|
+
/** The venue's symbol suffix, as `quote` takes it (`.SA`). */
|
|
14
|
+
suffix: string;
|
|
15
|
+
exchange: string;
|
|
16
|
+
/** Its name now. */
|
|
17
|
+
name: string;
|
|
18
|
+
/** The names people still search for, the one it went by first: its brand, then its legal name. */
|
|
19
|
+
formerNames: readonly [string, ...string[]];
|
|
20
|
+
/** The day a class that no longer trades was converted into the `to` line (YYYY-MM-DD). */
|
|
21
|
+
convertedOn?: string;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** The name it went by: "Eletrobras". */
|
|
25
|
+
function renamedListingFormerName(listing: RenamedListing): string {
|
|
26
|
+
return listing.formerNames[0];
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Checked in, each from the issuer's own notice. Eletrobras (Centrais
|
|
31
|
+
* Elétricas Brasileiras S.A.) renamed itself AXIA Energia in November 2025,
|
|
32
|
+
* and each of its B3 lines took the new code: ELET3 AXIA3, the class B
|
|
33
|
+
* preferred ELET6 AXIA6, the class A preferred ELET5 AXIA5. On 5 Jun 2026,
|
|
34
|
+
* moving to the Novo Mercado, AXIA converted both preferred classes into its
|
|
35
|
+
* common shares, which trade as AXIA3 (AXIA's release of 9 Jun 2026), so
|
|
36
|
+
* the preferred codes, old and new, lead there. Its ADSs' change (EBR to
|
|
37
|
+
* AXIA) is in the US history already. A name leads to the common shares,
|
|
38
|
+
* listed first.
|
|
39
|
+
*/
|
|
40
|
+
const ELETROBRAS = ["Eletrobras", "Centrais Elétricas Brasileiras"] as const;
|
|
41
|
+
const AXIA_PREFERRED_CONVERTED = "2026-06-05";
|
|
42
|
+
const RENAMED_LISTINGS: readonly RenamedListing[] = [
|
|
43
|
+
{ from: "ELET3", to: "AXIA3", suffix: ".SA", exchange: "B3", name: "AXIA Energia", formerNames: ELETROBRAS },
|
|
44
|
+
...["ELET6", "AXIA6", "ELET5", "AXIA5"].map((from): RenamedListing => ({ from, to: "AXIA3", suffix: ".SA", exchange: "B3",
|
|
45
|
+
name: "AXIA Energia", formerNames: ELETROBRAS, convertedOn: AXIA_PREFERRED_CONVERTED })),
|
|
46
|
+
];
|
|
47
|
+
|
|
48
|
+
/** "5 Jun 2026". */
|
|
49
|
+
function conversionDay(date: string): string {
|
|
50
|
+
return new Date(`${date}T00:00:00Z`).toLocaleDateString("en-GB", { day: "numeric", month: "short", year: "numeric", timeZone: "UTC" });
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** `AXIA3.SA`: the new listing as `quote` takes it. */
|
|
54
|
+
export function renamedListingSymbol(listing: RenamedListing): string {
|
|
55
|
+
return `${listing.to}${listing.suffix}`;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* The renamed listing a symbol (`ELET3`, `ELET3.SA`, `ELET3:B3`) or a name
|
|
60
|
+
* (`eletrobras`) means, else null.
|
|
61
|
+
*/
|
|
62
|
+
export function renamedListingFor(query: string): RenamedListing | null {
|
|
63
|
+
const typed = query.trim().toUpperCase();
|
|
64
|
+
if (!typed) return null;
|
|
65
|
+
const bySymbol = RENAMED_LISTINGS.find((listing) =>
|
|
66
|
+
typed === listing.from || typed === `${listing.from}${listing.suffix}` || typed === `${listing.from}:${listing.exchange}`);
|
|
67
|
+
if (bySymbol) return bySymbol;
|
|
68
|
+
const words = normalizeSearchText(query);
|
|
69
|
+
return words ? RENAMED_LISTINGS.find((listing) => listing.formerNames.some((name) => normalizeSearchText(name) === words)) ?? null : null;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* "It is now AXIA3.SA (AXIA Energia, formerly Eletrobras): `gloom quote
|
|
74
|
+
* AXIA3.SA`.", after the line naming the old symbol; for a converted class,
|
|
75
|
+
* "It was converted into AXIA3.SA on 5 Jun 2026 ...".
|
|
76
|
+
*/
|
|
77
|
+
export function renamedListingHint(listing: RenamedListing): string {
|
|
78
|
+
const now = renamedListingSymbol(listing);
|
|
79
|
+
const named = `${now} (${listing.name}, formerly ${renamedListingFormerName(listing)})`;
|
|
80
|
+
return listing.convertedOn
|
|
81
|
+
? `It was converted into ${named} on ${conversionDay(listing.convertedOn)}: \`gloom quote ${now}\`.`
|
|
82
|
+
: `It is now ${named}: \`gloom quote ${now}\`.`;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** What search says the new line was: "Eletrobras (ELET3)", or "Eletrobras (ELET6, converted 5 Jun 2026)". */
|
|
86
|
+
export function renamedListingFormerLine(listing: RenamedListing): string {
|
|
87
|
+
const converted = listing.convertedOn ? `, converted ${conversionDay(listing.convertedOn)}` : "";
|
|
88
|
+
return `${renamedListingFormerName(listing)} (${listing.from}${converted})`;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* "Read ELET3.SA as AXIA3.SA: Eletrobras is AXIA Energia now.", or "Read
|
|
93
|
+
* "eletrobras" as ..." for its name; for a converted class, "Read ELET6 as
|
|
94
|
+
* AXIA3.SA: those preferred shares were converted into AXIA Energia's common
|
|
95
|
+
* shares on 5 Jun 2026."
|
|
96
|
+
*/
|
|
97
|
+
export function renamedListingReadAs(typed: string, listing: RenamedListing): string {
|
|
98
|
+
const word = typed.trim();
|
|
99
|
+
// A name is quoted, as every name read as a listing is; the CLI puts it back in the user's spelling.
|
|
100
|
+
const shown = listing.formerNames.some((name) => normalizeSearchText(word) === normalizeSearchText(name)) ? `"${word}"` : word;
|
|
101
|
+
const now = renamedListingSymbol(listing);
|
|
102
|
+
return listing.convertedOn
|
|
103
|
+
? `Read ${shown} as ${now}: those preferred shares were converted into ${listing.name}'s common shares on ${conversionDay(listing.convertedOn)}.`
|
|
104
|
+
: `Read ${shown} as ${now}: ${renamedListingFormerName(listing)} is ${listing.name} now.`;
|
|
105
|
+
}
|
|
@@ -35,6 +35,7 @@ import {
|
|
|
35
35
|
} from "./result";
|
|
36
36
|
|
|
37
37
|
import { typedPerpetualListing } from "../perpetual-listing";
|
|
38
|
+
import { renamedListingFor, renamedListingFormerLine, type RenamedListing } from "../renamed-listings";
|
|
38
39
|
import { endsInLegalForm, readNearMissListing, readVenueFirstListing, readTerminalListingCode } from "../terminal-codes";
|
|
39
40
|
import { isProviderBusy, ProviderBusyError, SEARCH_BUSY_MESSAGE } from "../../sources/provider-errors";
|
|
40
41
|
import { settleWithin } from "../../utils/async-deadline";
|
|
@@ -268,13 +269,19 @@ export async function searchTickerCandidates({
|
|
|
268
269
|
// A search that hides contracts still shows them when asked: "AAPL OPT".
|
|
269
270
|
includeOptionContracts: includeOptionContracts || parseAssetClassQuery(query)?.code === "OPT",
|
|
270
271
|
});
|
|
271
|
-
const
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
272
|
+
const renamed = renamedListingFor(rawQuery);
|
|
273
|
+
const [searched, renamedRow] = await Promise.all([
|
|
274
|
+
searchProviderResults(
|
|
275
|
+
dataProvider,
|
|
276
|
+
query,
|
|
277
|
+
searchContext,
|
|
278
|
+
onPartial ? (found) => onPartial(assemble(found)) : undefined,
|
|
279
|
+
true,
|
|
280
|
+
),
|
|
281
|
+
renamed ? renamedListingRow(dataProvider, renamed, searchContext) : null,
|
|
282
|
+
]);
|
|
283
|
+
const { busy, unreachable } = searched;
|
|
284
|
+
const results = renamedRow ? withRenamedListingRow(searched.results, renamedRow) : searched.results;
|
|
278
285
|
// The symbol's lines are named at once the next time it is typed. An answer that may have
|
|
279
286
|
// been cut short and found none of the lines leaves the ones search named before standing,
|
|
280
287
|
// as the bar showed them, unless the search was a broker account's own.
|
|
@@ -319,7 +326,36 @@ export function buildTickerSearchCandidates({
|
|
|
319
326
|
);
|
|
320
327
|
const providerItems = createProviderTickerSearchCandidates(filteredProviderResults, tickers, candidateOptions);
|
|
321
328
|
const ranked = withHomeListingLead(withSuccessorFirst(rankTickerSearchItems([...localItems, ...providerItems], query), query), query);
|
|
322
|
-
return limitTickerSearchCandidates(assignTickerSearchCategories(ranked, query), totalLimit, localLimit);
|
|
329
|
+
return limitTickerSearchCandidates(companyListingsFirst(assignTickerSearchCategories(ranked, query), query), totalLimit, localLimit);
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
/**
|
|
333
|
+
* The row of the listing a renamed one moved to (AXIA3 for ELET3 or
|
|
334
|
+
* "eletrobras"), as search lists it under its new symbol, carrying the old
|
|
335
|
+
* name and symbol so it answers to them and says what it was. Null when
|
|
336
|
+
* search does not list it.
|
|
337
|
+
*/
|
|
338
|
+
async function renamedListingRow(
|
|
339
|
+
dataProvider: DataProvider,
|
|
340
|
+
renamed: RenamedListing,
|
|
341
|
+
searchContext?: SearchRequestContext,
|
|
342
|
+
): Promise<InstrumentSearchResult | null> {
|
|
343
|
+
const found = await searchProviderResults(dataProvider, renamed.to, searchContext)
|
|
344
|
+
.catch(logFailure("tickers.search", "Search for a renamed listing's new symbol failed", null));
|
|
345
|
+
const row = found?.results.find((result) => result.symbol.toUpperCase() === renamed.to
|
|
346
|
+
&& canonicalExchange(result.exchange) === canonicalExchange(renamed.exchange));
|
|
347
|
+
return row ? {
|
|
348
|
+
...row,
|
|
349
|
+
searchAliases: [...new Set([...(row.searchAliases ?? []), ...renamed.formerNames, renamed.from, `${renamed.from}${renamed.suffix}`])],
|
|
350
|
+
formerName: renamedListingFormerLine(renamed),
|
|
351
|
+
} : null;
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
/** Search's rows with the renamed listing's row first, in place of the row it already had of it and of its old symbol on the venue. */
|
|
355
|
+
function withRenamedListingRow(results: InstrumentSearchResult[], row: InstrumentSearchResult): InstrumentSearchResult[] {
|
|
356
|
+
const venue = canonicalExchange(row.exchange);
|
|
357
|
+
return [row, ...results.filter((result) => canonicalExchange(result.exchange) !== venue
|
|
358
|
+
|| (result.symbol.toUpperCase() !== row.symbol.toUpperCase() && !row.searchAliases?.includes(result.symbol.toUpperCase())))];
|
|
323
359
|
}
|
|
324
360
|
|
|
325
361
|
/** Whether a query is the start of a merged company's name, as the service matched it ("Golden Ocean"). */
|
|
@@ -386,22 +422,47 @@ export function symbolSearchQuery(query: string): string {
|
|
|
386
422
|
return trimmed.slice(0, -1).toUpperCase();
|
|
387
423
|
}
|
|
388
424
|
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
if (!requested) return Promise.resolve(null);
|
|
425
|
+
/** The symbol `resolveTickerSearch` looks a normalized query up as first, and the spellings it reads it in. */
|
|
426
|
+
function lookupSpelling(requested: string, tickers: ReadonlyMap<string, TickerRecord>) {
|
|
392
427
|
// `NET:` lists NET's venues instead of settling on one.
|
|
393
428
|
const pickListing = isListingPickerQuery(requested);
|
|
394
429
|
const typed = symbolSearchQuery(requested);
|
|
395
430
|
// A futures board code no security uses is its future (TTF is TTF=F), unless a saved ticker holds it.
|
|
396
|
-
const future = pickListing ||
|
|
431
|
+
const future = pickListing || tickers.has(typed) ? null : bareFuturesCode(typed);
|
|
397
432
|
// A currency pair is the one listing the service has for it, however it is written: EUR/USD and
|
|
398
433
|
// JPY=X are EURUSD=X and USDJPY=X. USD-NGN and USDNGN, which a security could also be written as
|
|
399
434
|
// (MNT-USD is a coin), are the pair only when nothing is listed under those letters.
|
|
400
435
|
const pair = pickListing || future ? null : currencyPairSpelling(typed);
|
|
401
436
|
// A coin pair written as crypto exchanges write it (BTC/GBP, or BTC/GBP:KRAKEN) is the crypto venue's BTC-GBP,
|
|
402
437
|
// and what was typed when the venue has no such coin.
|
|
403
|
-
const coin = pickListing || future || pair ||
|
|
438
|
+
const coin = pickListing || future || pair || tickers.has(typed) ? null : typedCoinPairListing(typed);
|
|
404
439
|
const symbol = future?.symbol ?? coin?.symbol ?? (pair && !pair.ambiguous ? pair.symbol : typed);
|
|
440
|
+
return { pickListing, typed, pair, coin, symbol };
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
/** The saved ticker a symbol names, as written or as a saved listing reads it. */
|
|
444
|
+
function savedTickerFor(symbol: string, tickers: ReadonlyMap<string, TickerRecord>): TickerRecord | null {
|
|
445
|
+
return tickers.get(symbol)
|
|
446
|
+
?? findExactTickerSearchMatch(createLocalTickerSearchCandidates(tickers.values()), symbol)?.ticker
|
|
447
|
+
?? null;
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
/**
|
|
451
|
+
* The saved ticker a query names as `resolveTickerSearch` reads it, with no
|
|
452
|
+
* source asked: `JPM US Equity` is JPM, `BRK/B` BRK-B, `TTF` its future TTF=F.
|
|
453
|
+
* Null when none is saved, or for `NET:`, which asks for a choice of listings.
|
|
454
|
+
*/
|
|
455
|
+
export function savedTickerForQuery(query: string, tickers: ReadonlyMap<string, TickerRecord>): TickerRecord | null {
|
|
456
|
+
const requested = normalizeTickerInput(null, query);
|
|
457
|
+
if (!requested) return null;
|
|
458
|
+
const { pickListing, symbol } = lookupSpelling(requested, tickers);
|
|
459
|
+
return pickListing ? null : savedTickerFor(symbol, tickers);
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
export function resolveTickerSearch(options: ResolveTickerSearchOptions): Promise<ResolvedTickerSearch | null> {
|
|
463
|
+
const requested = normalizeTickerInput(options.activeTicker, options.query);
|
|
464
|
+
if (!requested) return Promise.resolve(null);
|
|
465
|
+
const { pickListing, typed, pair, coin, symbol } = lookupSpelling(requested, options.tickers);
|
|
405
466
|
const literal = resolveTickerSymbol(symbol, options, pickListing ? requested : null);
|
|
406
467
|
const alternatives = pickListing ? [] : [...dottedVenueQueries(symbol), ...pair?.ambiguous ? [pair.symbol] : [], ...coin ? [typed] : []];
|
|
407
468
|
// A listing suffix search does not carry (CEZ.PR) is read from its own quote, as `quote` reads it.
|
|
@@ -473,9 +534,7 @@ async function resolveTickerSymbol(
|
|
|
473
534
|
/** The `NET:` text that asked for every venue, or null to settle on one. */
|
|
474
535
|
pickerQuery: string | null,
|
|
475
536
|
): Promise<ResolvedTickerSearch | null> {
|
|
476
|
-
const local =
|
|
477
|
-
?? findExactTickerSearchMatch(createLocalTickerSearchCandidates(tickers.values()), symbol)?.ticker
|
|
478
|
-
?? null;
|
|
537
|
+
const local = savedTickerFor(symbol, tickers);
|
|
479
538
|
if (local) {
|
|
480
539
|
const contracts = new Map((local.metadata.broker_contracts ?? []).flatMap((brokerContract) => {
|
|
481
540
|
const key = searchContractKey({ brokerContract, type: local.metadata.assetCategory || "" });
|
|
@@ -925,6 +984,34 @@ function assignTickerSearchCategories<T extends TickerSearchCandidate>(items: T[
|
|
|
925
984
|
}) as T[];
|
|
926
985
|
}
|
|
927
986
|
|
|
987
|
+
/**
|
|
988
|
+
* A query that names a company lists the company's listings before the
|
|
989
|
+
* mutual funds that carry its name: "banorte" is GFNORTEO (Grupo Financiero
|
|
990
|
+
* Banorte) and its other lines first, then the four Banorte Siefore pension
|
|
991
|
+
* funds search ranked above it. Only when the primary listing's name holds
|
|
992
|
+
* every word of the query and every fund ranked above it is a mutual fund: a
|
|
993
|
+
* future or an ETF the query names keeps its lead (GC=F for "gold", LIT for
|
|
994
|
+
* "lithium", Fidelity's ETFs for "fidelity"). Only the primary listing and
|
|
995
|
+
* the lines under its own name move: another company's listing keeps its
|
|
996
|
+
* place behind the funds.
|
|
997
|
+
*/
|
|
998
|
+
function companyListingsFirst<T extends TickerSearchCandidate>(items: T[], query: string): T[] {
|
|
999
|
+
const primary = items.findIndex((item) => item.category === "Primary Listing");
|
|
1000
|
+
const firstFund = items.findIndex((item) => item.category === "Funds & Derivatives");
|
|
1001
|
+
if (primary < 0 || firstFund < 0 || firstFund > primary) return items;
|
|
1002
|
+
const ahead = items.slice(0, primary).filter((item) => item.category === "Funds & Derivatives");
|
|
1003
|
+
if (!ahead.every((item) => /mutual\s*fund/i.test(item.instrumentType ?? item.result?.type ?? ""))) return items;
|
|
1004
|
+
const wanted = normalizeSearchText(query).split(" ").filter(Boolean);
|
|
1005
|
+
const lead = items[primary]!;
|
|
1006
|
+
const leadName = normalizeSearchText(lead.result?.name ?? lead.ticker?.metadata.name ?? lead.detail ?? "");
|
|
1007
|
+
if (!wanted.length || !wanted.every((word) => ` ${leadName} `.includes(` ${word} `))) return items;
|
|
1008
|
+
const listings = items.filter((item) => item === lead || (item.category === "Other Listings"
|
|
1009
|
+
&& normalizeSearchText(item.result?.name ?? item.ticker?.metadata.name ?? item.detail ?? "") === leadName));
|
|
1010
|
+
const before = items.slice(0, firstFund).filter((item) => !listings.includes(item));
|
|
1011
|
+
const rest = items.slice(firstFund).filter((item) => !listings.includes(item));
|
|
1012
|
+
return [...before, ...listings, ...rest];
|
|
1013
|
+
}
|
|
1014
|
+
|
|
928
1015
|
function limitTickerSearchCandidates<T extends TickerSearchCandidate>(
|
|
929
1016
|
items: T[],
|
|
930
1017
|
totalLimit: number,
|
|
@@ -60,7 +60,7 @@ import {
|
|
|
60
60
|
} from "./price-comparison";
|
|
61
61
|
import { chartQuoteOverrideKeyForSource } from "./live-quotes";
|
|
62
62
|
import { coinLegsAtSessionClose } from "./coin-session-close";
|
|
63
|
-
import { chartSeriesSourceKey } from "../capabilities/chart-series";
|
|
63
|
+
import { chartSeriesSourceKey, uncoveredCapabilityMessage } from "../capabilities/chart-series";
|
|
64
64
|
import { rememberSeedListingFacts } from "./parsed-history-cache";
|
|
65
65
|
import {
|
|
66
66
|
canonicalExchange,
|
|
@@ -822,7 +822,7 @@ async function resolveChartSpecPass(
|
|
|
822
822
|
try {
|
|
823
823
|
if (seriesSpec.source.kind === "capability") {
|
|
824
824
|
if (!sources.resolveCapabilitySeries) {
|
|
825
|
-
throw new Error(
|
|
825
|
+
throw new Error(uncoveredCapabilityMessage(seriesSpec.source.capabilityId, seriesSpec.source.seriesId));
|
|
826
826
|
}
|
|
827
827
|
const capabilityBounds = capabilityRequestBounds(requestVisibleBounds, initialVisibleBounds, movedWindow);
|
|
828
828
|
const capabilityViewport: ChartSpec["viewport"] = {
|
package/src/types/financials.ts
CHANGED
|
@@ -546,6 +546,7 @@ export interface AnalystRatingRecord {
|
|
|
546
546
|
}
|
|
547
547
|
|
|
548
548
|
export interface AnalystEstimateRecord {
|
|
549
|
+
epsBasis?: "gaap" | "adjusted" | "unknown";
|
|
549
550
|
date: string;
|
|
550
551
|
period: string;
|
|
551
552
|
/** Explicit currency for these estimates; independent of the listing currency. */
|
|
@@ -40,6 +40,8 @@ export interface PaneSettingTextField extends PaneSettingFieldBase {
|
|
|
40
40
|
interface PaneSettingSelectField extends PaneSettingFieldBase {
|
|
41
41
|
type: "select";
|
|
42
42
|
options: PaneSettingOption[];
|
|
43
|
+
/** The option an unset value reads as: shown as the current choice, and where the picker starts. */
|
|
44
|
+
defaultValue?: string;
|
|
43
45
|
}
|
|
44
46
|
|
|
45
47
|
interface PaneSettingMultiSelectField extends PaneSettingFieldBase {
|
|
@@ -169,6 +169,13 @@ export interface PaneDef {
|
|
|
169
169
|
settings?: PaneSettingsDef | ((context: PaneSettingsContext) => PaneSettingsDef | null);
|
|
170
170
|
/** Portable sharing is public by default; list the few pane-owned fields that must remain local. */
|
|
171
171
|
portableShare?: PanePortableShareDef;
|
|
172
|
+
/**
|
|
173
|
+
* What a public link to the pane may name as the item it was on, beside the
|
|
174
|
+
* pane (`shares/pane-item.ts`); unset, the link names the pane alone. Only for
|
|
175
|
+
* a pane of public data, and only the app's own panes: a plugin loaded from
|
|
176
|
+
* outside the app names nothing, whatever it sets here.
|
|
177
|
+
*/
|
|
178
|
+
shareItem?: PaneShareItemDef;
|
|
172
179
|
/**
|
|
173
180
|
* The person's own data the pane shows, so copying a public link to it,
|
|
174
181
|
* posting its picture in a bug report and attaching it to an Ask Gloom
|
|
@@ -189,6 +196,21 @@ export interface PaneDef {
|
|
|
189
196
|
quickSettings?: readonly PaneQuickSettingDef[];
|
|
190
197
|
}
|
|
191
198
|
|
|
199
|
+
export interface PaneShareItemDef {
|
|
200
|
+
/**
|
|
201
|
+
* What the pane has open or picked: what it says with `usePaneShareItem`,
|
|
202
|
+
* else its stack's detail title and its reader's opening.
|
|
203
|
+
*/
|
|
204
|
+
open?: true;
|
|
205
|
+
/** The one ticker the pane shows, when it follows one (`tickerFollower`). */
|
|
206
|
+
ticker?: true;
|
|
207
|
+
/**
|
|
208
|
+
* The option the pane's function was opened with (`NI CRYPTO`), when the
|
|
209
|
+
* function lists it (`argOptions`). Free text is never named.
|
|
210
|
+
*/
|
|
211
|
+
argument?: true;
|
|
212
|
+
}
|
|
213
|
+
|
|
192
214
|
/**
|
|
193
215
|
* Kinds of personal data a pane can show: `holdings` (positions, balances,
|
|
194
216
|
* orders, profit and loss), `account` (account numbers, email, plan),
|