@gloom-sh/terminal 0.20.11 → 0.20.12
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 +2 -1
- package/src/api-client/awards.ts +16 -0
- package/src/api-client/central-bank-rates.ts +5 -0
- package/src/api-client/data.ts +55 -2
- package/src/api-client/index.ts +18 -1
- package/src/api-client/request.ts +86 -3
- package/src/api-client/socket-connection.ts +12 -1
- package/src/api-client/socket.ts +21 -3
- package/src/api-client/supply-chain-graph.ts +4 -2
- package/src/api-client/supply-chain.ts +8 -0
- package/src/api-client/types/econ.ts +10 -7
- package/src/api-client/types/filings-and-calls.ts +8 -0
- package/src/app/global-shortcuts.ts +2 -1
- package/src/app/keybindings/actions.ts +19 -0
- package/src/app/pane-runtime/index.tsx +18 -3
- package/src/app/pane-runtime/layout-placement.ts +63 -0
- package/src/app/pane-runtime/ticker-open-runtime.ts +10 -2
- package/src/capabilities/chart-series.ts +4 -1
- package/src/cli/board-coins.ts +10 -1
- package/src/cli/commands/crypto-hints.ts +3 -2
- package/src/cli/commands/fred-series.ts +0 -54
- package/src/cli/commands/market.ts +209 -31
- package/src/cli/commands/overview.ts +47 -14
- package/src/cli/commands/search.ts +37 -8
- package/src/cli/commands/ticker.ts +15 -4
- package/src/cli/desktop-pane-shot.ts +27 -2
- package/src/cli/fx-quote-rate.ts +1 -1
- package/src/cli/glossary.ts +14 -5
- package/src/cli/history-catalog-series.ts +85 -0
- package/src/cli/index.ts +1 -1
- package/src/cli/list-progress.ts +45 -0
- package/src/cli/listing-arg.ts +71 -7
- package/src/cli/name-entries.ts +8 -4
- package/src/cli/not-a-ticker.ts +2 -2
- package/src/cli/pane-functions/freshness.ts +50 -3
- package/src/cli/pane-functions/index.ts +7 -4
- package/src/cli/pane-functions/market-session.ts +66 -14
- package/src/cli/pane-functions/options.ts +5 -0
- package/src/cli/pane-functions/resolver.ts +9 -2
- package/src/cli/pane-functions/screenshot-assessment.ts +28 -3
- package/src/cli/pane-functions/screenshot-types.ts +6 -0
- package/src/cli/quote-answer.ts +49 -10
- package/src/cli/quote-list-reads.ts +87 -0
- package/src/cli/report-tables.ts +70 -13
- package/src/cli/result.ts +24 -2
- package/src/cli/symbol-list.ts +31 -4
- package/src/cli/terminal-code-hints.ts +83 -0
- package/src/cli/ticker-resolution.ts +2 -1
- package/src/cli/treasury-yields.ts +5 -0
- package/src/components/command-bar/action-runtime.ts +2 -0
- package/src/components/command-bar/routing/launch-request.ts +2 -1
- package/src/components/command-bar/routing/navigation-state.ts +4 -2
- package/src/components/command-bar/workflow/types.ts +6 -0
- package/src/components/layout/detached-pane-shell.tsx +3 -0
- package/src/components/layout/double-escape-close.ts +34 -3
- package/src/components/layout/floating-pane.tsx +10 -4
- package/src/components/layout/pane/cycle-order.ts +66 -2
- package/src/components/layout/pane/header.tsx +140 -31
- package/src/components/layout/pane/sidebar.tsx +13 -5
- package/src/components/layout/pane/status-footer.ts +3 -1
- package/src/components/layout/shell/drag/runtime.ts +5 -0
- package/src/components/layout/shell/index.tsx +25 -0
- package/src/components/layout/shell/menu.ts +9 -0
- package/src/components/layout/shell/pane/actions.ts +36 -0
- package/src/components/layout/shell/pane/management-shortcuts.ts +27 -3
- package/src/components/layout/shell/pane-occlusion.ts +40 -0
- package/src/components/layout/shell/shortcuts.ts +17 -1
- package/src/components/layout/shell/terminal-pointer-runtime.ts +39 -6
- package/src/components/layout/shell/window-mode/index.ts +5 -16
- package/src/components/layout/shell/window-mode/overlays.tsx +3 -1
- package/src/components/market-board/index.tsx +14 -5
- package/src/components/metric-treemap/index.tsx +3 -1
- package/src/components/ui/button.tsx +48 -4
- package/src/components/ui/data-table/opentui/index.tsx +24 -9
- package/src/components/ui/data-table/types.ts +7 -0
- package/src/components/ui/inline-quick-add.tsx +19 -3
- package/src/components/ui/list-view.tsx +11 -5
- package/src/components/ui/query-bar.tsx +16 -1
- package/src/components/ui/selection-fill.ts +39 -0
- package/src/core/state/app/layout-reducer.ts +2 -1
- package/src/core/state/app/pane-choices.ts +68 -0
- package/src/core/state/app/state.ts +14 -6
- package/src/core/state/app/types.ts +8 -0
- package/src/layout/pane-manager/dock-tree.ts +19 -0
- package/src/layout/pane-manager/index.ts +3 -0
- package/src/market-data/market/freshness.ts +33 -0
- package/src/market-data/market/status.ts +5 -1
- package/src/market-data/quotes/contributions.ts +10 -0
- package/src/market-data/quotes/freshness.ts +19 -0
- package/src/market-data/quotes/live-valuation.ts +31 -4
- package/src/market-data/quotes/resolution.ts +4 -0
- package/src/market-data/quotes/time.ts +0 -14
- package/src/plugins/builtin/account-management/index.tsx +1 -0
- package/src/plugins/builtin/awards/detail.tsx +12 -4
- package/src/plugins/builtin/awards/headless.ts +29 -8
- package/src/plugins/builtin/awards/model.ts +36 -2
- package/src/plugins/builtin/awards/pane.tsx +7 -4
- package/src/plugins/builtin/broker-manager/index.tsx +1 -0
- package/src/plugins/builtin/broker-trading/index.tsx +1 -1
- package/src/plugins/builtin/central-bank-rates/headless.ts +6 -6
- package/src/plugins/builtin/central-bank-rates/index.tsx +1 -1
- package/src/plugins/builtin/central-bank-rates/model.ts +21 -3
- package/src/plugins/builtin/central-bank-rates/pane.tsx +15 -5
- package/src/plugins/builtin/chart-composer/headless.ts +5 -1
- package/src/plugins/builtin/chart-composer/pane.tsx +1 -0
- package/src/plugins/builtin/chat/content/handle-prompt.tsx +4 -0
- package/src/plugins/builtin/chat/controller/realtime.ts +17 -1
- package/src/plugins/builtin/chat/message/terminal.tsx +4 -1
- package/src/plugins/builtin/chat/sidebar.tsx +3 -4
- package/src/plugins/builtin/cloud/askg/pane.tsx +4 -0
- package/src/plugins/builtin/cloud/plugin.tsx +1 -0
- package/src/plugins/builtin/cloud/team/module.tsx +1 -0
- package/src/plugins/builtin/cloud/thesis/detail.tsx +9 -4
- package/src/plugins/builtin/commodity-balances/pane.tsx +13 -5
- package/src/plugins/builtin/company-kpis/model.ts +3 -3
- package/src/plugins/builtin/connections/index.ts +1 -0
- package/src/plugins/builtin/credit-boards/cdx-pane.tsx +9 -5
- package/src/plugins/builtin/credit-boards/client.ts +5 -0
- package/src/plugins/builtin/credit-boards/headless.ts +1 -6
- package/src/plugins/builtin/credit-boards/model.ts +0 -6
- package/src/plugins/builtin/credit-boards/series.ts +19 -8
- package/src/plugins/builtin/credit-boards/sovr-pane.tsx +9 -5
- package/src/plugins/builtin/crypto-etf-flows/headless.ts +23 -13
- package/src/plugins/builtin/crypto-etf-flows/pane.tsx +8 -3
- package/src/plugins/builtin/debt-maturities/headless.ts +16 -7
- package/src/plugins/builtin/debt-maturities/model.ts +9 -15
- package/src/plugins/builtin/debt-maturities/pane.tsx +9 -10
- package/src/plugins/builtin/earnings/board-model.ts +33 -4
- package/src/plugins/builtin/earnings/board.tsx +15 -3
- package/src/plugins/builtin/earnings/calendar.tsx +10 -6
- package/src/plugins/builtin/earnings/client.ts +0 -9
- package/src/plugins/builtin/earnings/headless.ts +10 -7
- package/src/plugins/builtin/earnings/history.tsx +21 -14
- package/src/plugins/builtin/earnings-calls/data.ts +24 -4
- package/src/plugins/builtin/earnings-calls/format.ts +23 -5
- package/src/plugins/builtin/earnings-calls/headless.ts +23 -3
- package/src/plugins/builtin/earnings-calls/index.tsx +1 -0
- package/src/plugins/builtin/earnings-calls/model.ts +11 -1
- package/src/plugins/builtin/earnings-calls/pane.tsx +2 -5
- package/src/plugins/builtin/econ/calendar-model.ts +27 -0
- package/src/plugins/builtin/econ/fred-catalog.ts +3 -0
- package/src/plugins/builtin/econ/index.tsx +9 -2
- package/src/plugins/builtin/econ-statistics/headless.ts +3 -1
- package/src/plugins/builtin/econ-statistics/index.tsx +1 -1
- package/src/plugins/builtin/fear-greed/headless.ts +16 -13
- package/src/plugins/builtin/fear-greed/pane.tsx +12 -4
- package/src/plugins/builtin/filing-events/index.tsx +1 -0
- package/src/plugins/builtin/fx-matrix/index.tsx +30 -19
- package/src/plugins/builtin/insider/table.tsx +10 -7
- package/src/plugins/builtin/insider/tickers.tsx +1 -1
- package/src/plugins/builtin/iv-history/headless.ts +9 -8
- package/src/plugins/builtin/jobs/index.tsx +1 -0
- package/src/plugins/builtin/macro-day/headless.ts +3 -3
- package/src/plugins/builtin/macro-day/model.ts +1 -1
- package/src/plugins/builtin/macro-day/releases.ts +25 -16
- package/src/plugins/builtin/market-movers/index.tsx +20 -8
- package/src/plugins/builtin/market-movers/model.ts +5 -0
- package/src/plugins/builtin/market-movers/session-body.tsx +2 -1
- package/src/plugins/builtin/money-markets/headless.ts +12 -2
- package/src/plugins/builtin/money-markets/pane.tsx +10 -1
- package/src/plugins/builtin/options/view.tsx +1 -0
- package/src/plugins/builtin/options-positioning/pane.tsx +1 -1
- package/src/plugins/builtin/portfolio-list/cli/bulk-symbols.ts +4 -31
- package/src/plugins/builtin/portfolio-list/pane/index.tsx +6 -1
- package/src/plugins/builtin/portfolio-list/quick-add/index.tsx +22 -8
- package/src/plugins/builtin/portfolio-list/summary/index.tsx +6 -8
- package/src/plugins/builtin/portfolio-list/table.tsx +10 -1
- package/src/plugins/builtin/realized-vol/headless.ts +28 -2
- package/src/plugins/builtin/risk-factors/index.tsx +1 -0
- package/src/plugins/builtin/shared/source-footer.ts +70 -0
- package/src/plugins/builtin/short-interest/publications-pane.tsx +5 -1
- package/src/plugins/builtin/short-volume/pane.tsx +5 -1
- package/src/plugins/builtin/social-mentions/outliers.tsx +10 -1
- package/src/plugins/builtin/social-mentions/pane.tsx +7 -0
- package/src/plugins/builtin/supply-chain/client.ts +3 -1
- package/src/plugins/builtin/supply-chain/flow.tsx +25 -8
- package/src/plugins/builtin/supply-chain/graph-client.ts +1 -1
- package/src/plugins/builtin/supply-chain/graph-evidence.ts +1 -1
- package/src/plugins/builtin/supply-chain/graph-model.ts +12 -1
- package/src/plugins/builtin/supply-chain/graph-pane.tsx +9 -8
- package/src/plugins/builtin/supply-chain/graph.tsx +12 -6
- package/src/plugins/builtin/supply-chain/headless.ts +13 -7
- package/src/plugins/builtin/supply-chain/model.ts +68 -11
- package/src/plugins/builtin/supply-chain/pane.tsx +9 -6
- package/src/plugins/builtin/supply-chain/row-evidence.tsx +5 -5
- package/src/plugins/builtin/ticker-detail/overview/components.tsx +14 -1
- package/src/plugins/builtin/ticker-detail/overview-tab.tsx +2 -0
- package/src/plugins/builtin/ticker-detail/pane.tsx +48 -24
- package/src/plugins/builtin/ticker-detail/quote-footer.ts +5 -0
- package/src/plugins/builtin/ticker-detail/quote-monitor/card.tsx +6 -3
- package/src/plugins/builtin/treasury-auctions/after.ts +50 -23
- package/src/plugins/builtin/treasury-auctions/cache.ts +23 -5
- package/src/plugins/builtin/treasury-auctions/headless.ts +226 -37
- package/src/plugins/builtin/treasury-auctions/hk-headless.ts +11 -5
- package/src/plugins/builtin/treasury-auctions/hk-view.tsx +27 -25
- package/src/plugins/builtin/treasury-auctions/hk.ts +60 -8
- package/src/plugins/builtin/treasury-auctions/index.tsx +3 -0
- package/src/plugins/builtin/treasury-auctions/keys.ts +27 -0
- package/src/plugins/builtin/treasury-auctions/like.ts +137 -0
- package/src/plugins/builtin/treasury-auctions/model.ts +100 -22
- package/src/plugins/builtin/treasury-auctions/pane.tsx +39 -11
- package/src/plugins/builtin/vol-surface/heat-grid.tsx +4 -2
- package/src/plugins/builtin/vol-surface/pane.tsx +5 -2
- package/src/plugins/runtime/index.tsx +1 -0
- package/src/plugins/runtime/state.ts +20 -0
- package/src/portfolio/column-values.ts +8 -2
- package/src/public/__snapshots__/public-api.test.ts.snap +5 -0
- package/src/public/react.ts +7 -0
- package/src/react/auto-refresh.ts +29 -0
- package/src/renderers/browser/deeplink-bridge.ts +24 -3
- package/src/renderers/dom/desktop/query-bar.tsx +229 -60
- package/src/renderers/dom/host/overflow-fade-px.ts +2 -0
- package/src/renderers/dom/host/overflow-fade.ts +1 -2
- package/src/renderers/dom/styles.css +25 -5
- package/src/renderers/electrobun/view/cli-pane-shot-entry.tsx +2 -1
- package/src/series/types.ts +2 -0
- package/src/sources/gloomberb-cloud/fred-attribution.ts +86 -0
- package/src/sources/gloomberb-cloud/index.ts +25 -1
- package/src/sources/gloomberb-cloud/normalizers.ts +22 -3
- package/src/sources/provider-errors.ts +64 -1
- package/src/sources/provider-router/batches.ts +19 -0
- package/src/sources/provider-router/index.ts +7 -1
- package/src/state/app/context/index.tsx +24 -1
- package/src/state/pane-unsent-work.ts +47 -0
- package/src/test-support/shell-pane-keys.tsx +5 -0
- package/src/test-support/telemetry-guard.ts +83 -0
- package/src/test-support/test-env.ts +12 -0
- package/src/theme/colors.ts +17 -1
- package/src/theme/ui-tokens.ts +50 -1
- package/src/tickers/listing-venues.ts +11 -1
- package/src/tickers/search/japanese-names.json +1 -0
- package/src/tickers/search/japanese-names.ts +152 -0
- package/src/tickers/terminal-codes.ts +55 -6
- package/src/time-series/base-series.ts +3 -0
- package/src/types/data-provider.ts +6 -0
- package/src/types/financials.ts +11 -0
- package/src/types/plugin-contributions.ts +7 -0
- package/src/types/plugin-panes.ts +7 -0
- package/src/ui/host.tsx +6 -0
- package/src/utils/double-escape-close.ts +42 -0
- package/src/utils/fx-status.ts +30 -7
- package/src/utils/network-failure.ts +23 -0
|
@@ -2,7 +2,8 @@ import { useThemeColors } from "../../theme/theme-context";
|
|
|
2
2
|
import { Box, ScrollBox, Text, useUiHost } from "../../ui";
|
|
3
3
|
import { useCallback, useEffect, useRef, useState, type ComponentType, type ReactNode } from "react";
|
|
4
4
|
import { TextAttributes, type ScrollBoxRenderable } from "../../ui";
|
|
5
|
-
import { hoverBg } from "../../theme/colors";
|
|
5
|
+
import { hoverBg, inactiveSelectedText } from "../../theme/colors";
|
|
6
|
+
import { useSelectionFill } from "./selection-fill";
|
|
6
7
|
import { t } from "../../i18n";
|
|
7
8
|
import { useRemoteUiNode, useRemoteUiScope } from "../../remote/semantic-tree";
|
|
8
9
|
import { resolveRemoteListIndex } from "../../remote/semantic-helpers";
|
|
@@ -145,11 +146,15 @@ export function listCursorMove(event: KeyboardModifierEventLike, pageSize: numbe
|
|
|
145
146
|
function DefaultRow({
|
|
146
147
|
item,
|
|
147
148
|
selected,
|
|
149
|
+
lit,
|
|
148
150
|
}: {
|
|
149
151
|
item: ListViewItem;
|
|
150
152
|
selected: boolean;
|
|
153
|
+
/** The selection is the one the keys move (`useSelectionFill`); off, the row's colours are lifted to read on the quieter fill. */
|
|
154
|
+
lit: boolean;
|
|
151
155
|
}) {
|
|
152
156
|
const colors = useThemeColors();
|
|
157
|
+
const ink = (color: string) => (selected && !lit ? inactiveSelectedText(color, colors) : color);
|
|
153
158
|
if (item.kind === "heading") return <Text fg={colors.textMuted}>{t(item.label)}</Text>;
|
|
154
159
|
// The label gives way to the detail: a long label is cut with an ellipsis
|
|
155
160
|
// instead of wrapping under the row or running into the right column.
|
|
@@ -160,7 +165,7 @@ function DefaultRow({
|
|
|
160
165
|
{selected ? "\u25b8 " : " "}
|
|
161
166
|
</Text>
|
|
162
167
|
<Text
|
|
163
|
-
fg={item.color ?? (selected ? colors.text : colors.textDim)}
|
|
168
|
+
fg={ink(item.color ?? (selected ? colors.text : colors.textDim))}
|
|
164
169
|
attributes={selected ? TextAttributes.BOLD : 0}
|
|
165
170
|
wrapMode="none"
|
|
166
171
|
truncate
|
|
@@ -172,7 +177,7 @@ function DefaultRow({
|
|
|
172
177
|
</Box>
|
|
173
178
|
{item.detail && (
|
|
174
179
|
<Box flexShrink={0} paddingLeft={1}>
|
|
175
|
-
<Text fg={colors.textMuted}>{t(item.detail)}</Text>
|
|
180
|
+
<Text fg={ink(colors.textMuted)}>{t(item.detail)}</Text>
|
|
176
181
|
</Box>
|
|
177
182
|
)}
|
|
178
183
|
</Box>
|
|
@@ -212,6 +217,7 @@ export function ListView({
|
|
|
212
217
|
remoteMetadata,
|
|
213
218
|
}: ListViewProps) {
|
|
214
219
|
const colors = useThemeColors();
|
|
220
|
+
const selectionFill = useSelectionFill();
|
|
215
221
|
// Drawn inside a prompt (a dialog that lists a prompt's answers), it carries the prompt's scope.
|
|
216
222
|
const contextScope = useRemoteUiScope();
|
|
217
223
|
useRemoteUiNode({
|
|
@@ -290,7 +296,7 @@ export function ListView({
|
|
|
290
296
|
const [hoveredIndex, setHoveredIndex] = useState<number | null>(null);
|
|
291
297
|
const scrollRef = useRef<ScrollBoxRenderable>(null);
|
|
292
298
|
const baseBg = bgColor ?? colors.bg;
|
|
293
|
-
const activeBg = selectedBgColor ??
|
|
299
|
+
const activeBg = selectedBgColor ?? selectionFill.bg;
|
|
294
300
|
const rowHoverBg = hoverBgColor ?? hoverBg(colors);
|
|
295
301
|
const selectedItem = selectedIndex >= 0 ? items[selectedIndex] : undefined;
|
|
296
302
|
const activeScrollIndex = scrollIndex ?? selectedIndex;
|
|
@@ -366,7 +372,7 @@ export function ListView({
|
|
|
366
372
|
>
|
|
367
373
|
{renderRow
|
|
368
374
|
? renderRow(item, state, index)
|
|
369
|
-
: <DefaultRow item={item} selected={selected} />}
|
|
375
|
+
: <DefaultRow item={item} selected={selected} lit={selectionFill.lit || selectedBgColor !== undefined} />}
|
|
370
376
|
</Box>
|
|
371
377
|
);
|
|
372
378
|
});
|
|
@@ -61,6 +61,12 @@ export interface QueryBarSelectFilter<T extends string = string> extends QueryBa
|
|
|
61
61
|
title?: string;
|
|
62
62
|
/** Draw the options inline (one click) instead of a menu. For four or fewer short values. */
|
|
63
63
|
inline?: boolean;
|
|
64
|
+
/**
|
|
65
|
+
* Inline filters: a long list that runs past the bar's edge (expiries). On
|
|
66
|
+
* the desktop it is a strip that scrolls by itself, where other inline
|
|
67
|
+
* choices fold into their menu when the bar runs short of room.
|
|
68
|
+
*/
|
|
69
|
+
scrolls?: boolean;
|
|
64
70
|
/**
|
|
65
71
|
* The options are the range a chart in this pane shows (1D, 1Y, MAX). Choosing
|
|
66
72
|
* the one already selected sends the pane's charts back to it, as `0` does
|
|
@@ -84,7 +90,7 @@ export interface QueryBarMultiFilter extends QueryBarFilterBase {
|
|
|
84
90
|
export interface QueryBarToggleFilter extends QueryBarFilterBase {
|
|
85
91
|
kind: "toggle";
|
|
86
92
|
value: boolean;
|
|
87
|
-
/** A shorter label for the terminal's single row. */
|
|
93
|
+
/** A shorter label for the terminal's single row, and for a desktop bar short of room. */
|
|
88
94
|
short?: string;
|
|
89
95
|
onChange: (value: boolean) => void;
|
|
90
96
|
/**
|
|
@@ -123,6 +129,12 @@ export interface QueryBarView<T extends string = string> {
|
|
|
123
129
|
value: T;
|
|
124
130
|
options: readonly { value: T; label: string; hint?: string; disabled?: boolean }[];
|
|
125
131
|
onChange: (value: T) => void;
|
|
132
|
+
/**
|
|
133
|
+
* What the choice is ("Interval", "Sort"): its name for a screen reader, and
|
|
134
|
+
* its menu's on the desktop when a bar short of room folds it. A chart's range
|
|
135
|
+
* is "Range" and any other unnamed view "View".
|
|
136
|
+
*/
|
|
137
|
+
label?: string;
|
|
126
138
|
/** Terminal: left/right cycle the view while this is true. */
|
|
127
139
|
focused?: boolean;
|
|
128
140
|
shortcutScope?: string;
|
|
@@ -413,6 +425,7 @@ export function QueryBar({ width, search, filters = [], view, meta, asOf: given,
|
|
|
413
425
|
id: filter.id,
|
|
414
426
|
kind: "toggle",
|
|
415
427
|
label: filter.label,
|
|
428
|
+
short: filter.short,
|
|
416
429
|
valueLabel: filter.label,
|
|
417
430
|
narrowing: isNarrowing(filter),
|
|
418
431
|
checked: filter.value,
|
|
@@ -449,6 +462,7 @@ export function QueryBar({ width, search, filters = [], view, meta, asOf: given,
|
|
|
449
462
|
valueLabel: current?.short ?? current?.label ?? String(filter.value),
|
|
450
463
|
narrowing: isNarrowing(filter),
|
|
451
464
|
inline: filter.inline === true,
|
|
465
|
+
scrolls: filter.scrolls,
|
|
452
466
|
options: filter.options.map((option) => ({
|
|
453
467
|
value: option.value,
|
|
454
468
|
label: option.label,
|
|
@@ -500,6 +514,7 @@ export function QueryBar({ width, search, filters = [], view, meta, asOf: given,
|
|
|
500
514
|
else if (view.chartRange) resetChartView();
|
|
501
515
|
},
|
|
502
516
|
start: view.start,
|
|
517
|
+
label: view.label ?? (view.chartRange ? "Range" : undefined),
|
|
503
518
|
} : undefined}
|
|
504
519
|
onClearAll={narrowingCount >= 2 ? resetAll : undefined}
|
|
505
520
|
meta={meta}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { usePaneFocused } from "../../state/app/activity";
|
|
2
|
+
import { inactiveSelectedBg, inactiveSelectedText } from "../../theme/colors";
|
|
3
|
+
import { useThemeColors } from "../../theme/theme-context";
|
|
4
|
+
import { useUiCapabilities } from "../../ui/host";
|
|
5
|
+
|
|
6
|
+
export interface SelectionFill {
|
|
7
|
+
/** The chosen row's or tile's fill. */
|
|
8
|
+
bg: string;
|
|
9
|
+
/**
|
|
10
|
+
* The keys move this selection: the selected text colour goes with the fill.
|
|
11
|
+
* Off, the row keeps its own text colours on the quieter fill.
|
|
12
|
+
*/
|
|
13
|
+
lit: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* A colour of the chosen item's own drawn on the fill: as it is under the
|
|
16
|
+
* lit selection (which draws its own text colour where it has one), lifted
|
|
17
|
+
* where it would not read on the inactive fill.
|
|
18
|
+
*/
|
|
19
|
+
ink(color: string): string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* The fill of a list's, table's or grid's chosen item in the terminal: the
|
|
24
|
+
* selection in the focused pane (and outside any pane, a dialog's list), the
|
|
25
|
+
* inactive selection in a pane that does not have the keyboard, so only one
|
|
26
|
+
* pane reads as the one the arrows move. The desktop marks focus its own way,
|
|
27
|
+
* so it keeps the selection.
|
|
28
|
+
*/
|
|
29
|
+
export function useSelectionFill(): SelectionFill {
|
|
30
|
+
const colors = useThemeColors();
|
|
31
|
+
const paneFocused = usePaneFocused();
|
|
32
|
+
const { nativePaneChrome } = useUiCapabilities();
|
|
33
|
+
const lit = nativePaneChrome === true || paneFocused !== false;
|
|
34
|
+
return {
|
|
35
|
+
bg: lit ? colors.selected : inactiveSelectedBg(colors),
|
|
36
|
+
lit,
|
|
37
|
+
ink: (color) => (lit ? color : inactiveSelectedText(color, colors)),
|
|
38
|
+
};
|
|
39
|
+
}
|
|
@@ -100,7 +100,8 @@ export function reduceLayoutAction(state: AppState, action: AppAction): AppState
|
|
|
100
100
|
state.focusedPaneId,
|
|
101
101
|
);
|
|
102
102
|
const target = currentConfig.layouts[action.index]!;
|
|
103
|
-
|
|
103
|
+
// A desk opens as it was saved: nothing on it was chosen in this session yet (pane-choices.ts).
|
|
104
|
+
return withFocusedPane({ ...state, paneChoices: undefined }, {
|
|
104
105
|
...currentConfig,
|
|
105
106
|
layout: cloneLayout(target.layout),
|
|
106
107
|
activeLayoutIndex: action.index,
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type { AppState, PaneRuntimeState } from "./types";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Which pane-state values were chosen in this session, as opposed to restored
|
|
5
|
+
* with a workspace: a start, a desk switch, a layout or a snapshot applied
|
|
6
|
+
* brings back what an earlier session chose. A write of the key in this
|
|
7
|
+
* session, by any route (a pick in the pane, a command, a link, a plugin) and
|
|
8
|
+
* even of the value it already holds, is the user asking for it.
|
|
9
|
+
*
|
|
10
|
+
* Some choices need Gloom Cloud Pro. Restored for an account without it, the
|
|
11
|
+
* pane shows its free default instead of a wall nobody asked for
|
|
12
|
+
* (`shownPaneChoice`), and keeps the saved choice for when the plan has Pro.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
const NO_CHOICES: Readonly<Record<string, true>> = {};
|
|
16
|
+
|
|
17
|
+
/** The choice key of a plugin's pane-state value (`usePluginPaneState`). */
|
|
18
|
+
export function pluginChoiceKey(pluginId: string, key: string): string {
|
|
19
|
+
return `plugin:${pluginId}:${key}`;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** `state` with `keys` of `paneId` marked as chosen in this session; the same object when they already were. */
|
|
23
|
+
export function withPaneChoices(state: AppState, paneId: string, keys: Iterable<string>): AppState {
|
|
24
|
+
const current = state.paneChoices?.[paneId] ?? NO_CHOICES;
|
|
25
|
+
let next: Record<string, true> | null = null;
|
|
26
|
+
for (const key of keys) {
|
|
27
|
+
if (current[key] || next?.[key]) continue;
|
|
28
|
+
next ??= { ...current };
|
|
29
|
+
next[key] = true;
|
|
30
|
+
}
|
|
31
|
+
return next ? { ...state, paneChoices: { ...state.paneChoices, [paneId]: next } } : state;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** Every key a replaced pane state holds, its plugins' values included. */
|
|
35
|
+
export function paneStateChoiceKeys(paneState: PaneRuntimeState): string[] {
|
|
36
|
+
const keys = Object.keys(paneState);
|
|
37
|
+
for (const [pluginId, values] of Object.entries(paneState.pluginState ?? {})) {
|
|
38
|
+
for (const key of Object.keys(values ?? {})) keys.push(pluginChoiceKey(pluginId, key));
|
|
39
|
+
}
|
|
40
|
+
return keys;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** `state` with every pane-state value it holds marked as chosen now. */
|
|
44
|
+
export function withAllPaneChoices(state: AppState): AppState {
|
|
45
|
+
return Object.entries(state.paneState).reduce(
|
|
46
|
+
(current, [paneId, paneState]) => withPaneChoices(current, paneId, paneStateChoiceKeys(paneState)),
|
|
47
|
+
state,
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export function isPaneChoice(state: AppState, paneId: string, key: string): boolean {
|
|
52
|
+
return state.paneChoices?.[paneId]?.[key] === true;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* What a pane shows for its saved `value`: the value itself, except one only
|
|
57
|
+
* Pro opens (`proOnly`) restored for an account without Pro, which shows
|
|
58
|
+
* `fallback` until the user chooses it in this session. Nothing is rewritten:
|
|
59
|
+
* the same account after upgrading, or a Pro one, gets the saved value back.
|
|
60
|
+
*/
|
|
61
|
+
export function shownPaneChoice<T>(value: T, options: {
|
|
62
|
+
chosen: boolean;
|
|
63
|
+
hasProAccess: boolean;
|
|
64
|
+
proOnly: (value: T) => boolean;
|
|
65
|
+
fallback: T;
|
|
66
|
+
}): T {
|
|
67
|
+
return options.chosen || options.hasProAccess || !options.proOnly(value) ? value : options.fallback;
|
|
68
|
+
}
|
|
@@ -25,6 +25,7 @@ import {
|
|
|
25
25
|
withFocusedPane,
|
|
26
26
|
} from "./layout";
|
|
27
27
|
import { reduceLayoutAction } from "./layout-reducer";
|
|
28
|
+
import { paneStateChoiceKeys, pluginChoiceKey, withPaneChoices } from "./pane-choices";
|
|
28
29
|
import type { AppAction, AppState, CollectionSortPreference, PaneRuntimeState } from "./types";
|
|
29
30
|
import type { AppSessionSnapshot } from "../session-persistence";
|
|
30
31
|
|
|
@@ -287,9 +288,11 @@ export function appReducer(state: AppState, action: AppAction): AppState {
|
|
|
287
288
|
return hydrateDesktopSnapshot(state, action.snapshot);
|
|
288
289
|
|
|
289
290
|
case "UPDATE_PANE_STATE": {
|
|
291
|
+
// Written in this session, even with the value it holds: see pane-choices.ts.
|
|
292
|
+
const chosen = withPaneChoices(state, action.paneId, Object.keys(action.patch));
|
|
290
293
|
const current = state.paneState[action.paneId] ?? {};
|
|
291
294
|
if (Object.keys(action.patch).every((key) => Object.is(current[key], action.patch[key]))) {
|
|
292
|
-
return
|
|
295
|
+
return chosen;
|
|
293
296
|
}
|
|
294
297
|
const nextState = { ...current, ...action.patch };
|
|
295
298
|
const recentTickers = Object.prototype.hasOwnProperty.call(action.patch, "cursorSymbol")
|
|
@@ -300,7 +303,7 @@ export function appReducer(state: AppState, action: AppAction): AppState {
|
|
|
300
303
|
[action.paneId]: nextState,
|
|
301
304
|
};
|
|
302
305
|
return {
|
|
303
|
-
...
|
|
306
|
+
...chosen,
|
|
304
307
|
config: syncConfigActiveLayoutState(state.config, paneState, state.focusedPaneId),
|
|
305
308
|
paneState,
|
|
306
309
|
recentTickers,
|
|
@@ -308,9 +311,10 @@ export function appReducer(state: AppState, action: AppAction): AppState {
|
|
|
308
311
|
}
|
|
309
312
|
|
|
310
313
|
case "REPLACE_PANE_STATE": {
|
|
314
|
+
const chosen = withPaneChoices(state, action.paneId, paneStateChoiceKeys(action.state));
|
|
311
315
|
const current = state.paneState[action.paneId] ?? {};
|
|
312
316
|
const nextState = action.state;
|
|
313
|
-
if (Object.is(current, nextState)) return
|
|
317
|
+
if (Object.is(current, nextState)) return chosen;
|
|
314
318
|
const paneState = {
|
|
315
319
|
...state.paneState,
|
|
316
320
|
[action.paneId]: nextState,
|
|
@@ -319,7 +323,7 @@ export function appReducer(state: AppState, action: AppAction): AppState {
|
|
|
319
323
|
? nextRecentTickers(state.recentTickers, typeof nextState.cursorSymbol === "string" ? nextState.cursorSymbol : null)
|
|
320
324
|
: state.recentTickers;
|
|
321
325
|
return {
|
|
322
|
-
...
|
|
326
|
+
...chosen,
|
|
323
327
|
config: syncConfigActiveLayoutState(state.config, paneState, state.focusedPaneId),
|
|
324
328
|
paneState,
|
|
325
329
|
recentTickers,
|
|
@@ -327,11 +331,12 @@ export function appReducer(state: AppState, action: AppAction): AppState {
|
|
|
327
331
|
}
|
|
328
332
|
|
|
329
333
|
case "UPDATE_PLUGIN_PANE_STATE": {
|
|
334
|
+
const chosen = withPaneChoices(state, action.paneId, [pluginChoiceKey(action.pluginId, action.key)]);
|
|
330
335
|
const current = state.paneState[action.paneId] ?? {};
|
|
331
336
|
const currentPluginState = current.pluginState ?? {};
|
|
332
337
|
const currentPluginValues = currentPluginState[action.pluginId] ?? {};
|
|
333
338
|
if (Object.is(currentPluginValues[action.key], action.value)) {
|
|
334
|
-
return
|
|
339
|
+
return chosen;
|
|
335
340
|
}
|
|
336
341
|
const paneState = {
|
|
337
342
|
...state.paneState,
|
|
@@ -347,12 +352,15 @@ export function appReducer(state: AppState, action: AppAction): AppState {
|
|
|
347
352
|
},
|
|
348
353
|
};
|
|
349
354
|
return {
|
|
350
|
-
...
|
|
355
|
+
...chosen,
|
|
351
356
|
config: syncConfigActiveLayoutState(state.config, paneState, state.focusedPaneId),
|
|
352
357
|
paneState,
|
|
353
358
|
};
|
|
354
359
|
}
|
|
355
360
|
|
|
361
|
+
case "CHOOSE_PANE_STATE":
|
|
362
|
+
return withPaneChoices(state, action.paneId, [action.key]);
|
|
363
|
+
|
|
356
364
|
default:
|
|
357
365
|
return state;
|
|
358
366
|
}
|
|
@@ -118,6 +118,12 @@ export interface AppState {
|
|
|
118
118
|
updateCheckInProgress: boolean;
|
|
119
119
|
updateNotice: string | null;
|
|
120
120
|
layoutHistory: Record<number, LayoutHistoryEntry>;
|
|
121
|
+
/**
|
|
122
|
+
* The pane-state keys set in this session, by pane id, as opposed to
|
|
123
|
+
* restored with the workspace (see `pane-choices.ts`). Session only: never
|
|
124
|
+
* saved and never sent to another window.
|
|
125
|
+
*/
|
|
126
|
+
paneChoices?: Record<string, Readonly<Record<string, true>>>;
|
|
121
127
|
}
|
|
122
128
|
|
|
123
129
|
export type AppAction =
|
|
@@ -226,4 +232,6 @@ export type AppAction =
|
|
|
226
232
|
value: unknown;
|
|
227
233
|
}
|
|
228
234
|
| { type: "REPLACE_PANE_STATE"; paneId: string; state: PaneRuntimeState }
|
|
235
|
+
/** The user chose this pane-state value now, even if it already holds what they chose (see `pane-choices.ts`). */
|
|
236
|
+
| { type: "CHOOSE_PANE_STATE"; paneId: string; key: string }
|
|
229
237
|
| { type: "UPDATE_PANE_STATE"; paneId: string; patch: Partial<PaneRuntimeState> };
|
|
@@ -90,6 +90,25 @@ export function getDockedInstanceIds(node: DockLayoutNode | null): string[] {
|
|
|
90
90
|
return collectDockLeafRefs(node).map((entry) => entry.instanceId);
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
+
/** The docked panes behind the tab their stack shows. */
|
|
94
|
+
export function hiddenDockTabIds(layout: LayoutConfig): Set<string> {
|
|
95
|
+
const hidden = new Set<string>();
|
|
96
|
+
for (const leaf of collectDockLeafRefs(layout.dockRoot)) {
|
|
97
|
+
if (!leaf.stackPath) continue;
|
|
98
|
+
const stack = getNodeAtPath(layout.dockRoot, leaf.stackPath);
|
|
99
|
+
if (stack && dockStackShown(stack) !== leaf.instanceId) hidden.add(leaf.instanceId);
|
|
100
|
+
}
|
|
101
|
+
return hidden;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/** The tabs of the dock stack `instanceId` is in, in tab order; empty when it is not in one. */
|
|
105
|
+
export function dockStackTabIds(layout: LayoutConfig, instanceId: string): string[] {
|
|
106
|
+
const leaf = findDockLeaf(layout, instanceId);
|
|
107
|
+
if (!leaf?.stackPath) return [];
|
|
108
|
+
const stack = getNodeAtPath(layout.dockRoot, leaf.stackPath);
|
|
109
|
+
return stack && isDockStack(stack) ? getDockedInstanceIds(stack) : [];
|
|
110
|
+
}
|
|
111
|
+
|
|
93
112
|
export function getRepresentativeLeafId(node: DockLayoutNode, preferStart: boolean): string {
|
|
94
113
|
if (node.kind === "pane") return node.instanceId;
|
|
95
114
|
if (isDockStack(node)) return dockStackShown(node);
|
|
@@ -8,17 +8,20 @@ export {
|
|
|
8
8
|
} from "./floating";
|
|
9
9
|
|
|
10
10
|
export {
|
|
11
|
+
dockStackTabIds,
|
|
11
12
|
findDockLeaf,
|
|
12
13
|
getDockDividerLayouts,
|
|
13
14
|
getDockedPaneIds,
|
|
14
15
|
getDockLeafLayouts,
|
|
15
16
|
getDockResizeTargets,
|
|
16
17
|
getDockSplitGeometry,
|
|
18
|
+
hiddenDockTabIds,
|
|
17
19
|
showDockTab,
|
|
18
20
|
type DockDividerLayout,
|
|
19
21
|
type DockGeometryOptions,
|
|
20
22
|
type DockLeafLayout,
|
|
21
23
|
type DockResizeTarget,
|
|
24
|
+
type DockTarget,
|
|
22
25
|
type LayoutBounds,
|
|
23
26
|
} from "./dock-tree";
|
|
24
27
|
|
|
@@ -128,6 +128,39 @@ const REGULAR_CLOSE_MINUTES: Record<string, number> = {
|
|
|
128
128
|
// Borsa Istanbul: continuous trading to 18:00, then the closing auction and trading at the close to 18:10.
|
|
129
129
|
BIST: 18 * 60 + 10,
|
|
130
130
|
};
|
|
131
|
+
// How long before its calendar's close (REGULAR_CLOSE_MINUTES, rounded up and
|
|
132
|
+
// running through any trading at the close, or the after-hours session the
|
|
133
|
+
// calendar keeps) a venue's closing price is set: the end of its closing
|
|
134
|
+
// auction, or of regular trading where the calendar runs on (TWSE's close is
|
|
135
|
+
// 13:30, its calendar 14:30 for after-hours fixed-price trading). A venue not
|
|
136
|
+
// listed sets its close at the calendar's. Rounded early, never late: a print
|
|
137
|
+
// is only called the close from this time on (closingPriceTime).
|
|
138
|
+
const CLOSING_PRICE_LEAD_MINUTES: Record<string, number> = {
|
|
139
|
+
// The closing auctions: Xetra, Vienna, Euronext and London to 17:35 (16:35), SIX and Milan to 17:30 and 17:35,
|
|
140
|
+
// Nasdaq Stockholm and Helsinki to 17:30 and 18:30, Copenhagen to 17:00, Oslo to 16:25, Iceland to 15:35, Warsaw to 17:00.
|
|
141
|
+
XETRA: 5, VIE: 5, EPA: 5, AMS: 5, BRU: 5, LIS: 5, LSE: 5, SWX: 10, BIT: 10,
|
|
142
|
+
SFB: 10, HEL: 10, CPH: 10, OSL: 5, ICEX: 5, WSE: 10, PSE: 5,
|
|
143
|
+
// Hong Kong's auction ends at random from 16:08, Sydney's from 16:10, Singapore's at 17:06, Wellington's by 16:50.
|
|
144
|
+
HKEX: 2, ASX: 5, SGX: 15, NZX: 10,
|
|
145
|
+
// Regular trading ends 13:30 in Taipei, 15:30 in Mumbai and Seoul and 15:00 in Shanghai and Shenzhen;
|
|
146
|
+
// the calendars run on through after-hours or closing-price sessions.
|
|
147
|
+
TWSE: 60, TPEX: 60, NSE: 30, BSE: 30, KRX: 30, KOSDAQ: 30, SSE: 30, SZSE: 30,
|
|
148
|
+
// Mexico, Buenos Aires and Johannesburg close at 15:00, 17:00 and 17:00; B3's close is 17:00 or 18:00 with New
|
|
149
|
+
// York's clocks, and the earlier is taken.
|
|
150
|
+
BMV: 10, BYMA: 10, JSE: 15, B3: 90,
|
|
151
|
+
// The Gulf and Tel Aviv: the closing auction's end, before trading at last.
|
|
152
|
+
TASE: 6, TADAWUL: 10, QE: 5, DFM: 5, MSX: 5, BIST: 5,
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* When a venue's closing price was set for the session its calendar closes at
|
|
157
|
+
* `close` (latestRegularSessionClose's): the closing auction's end or the end
|
|
158
|
+
* of regular trading, before any trading at the close or after-hours session
|
|
159
|
+
* the calendar runs through (CLOSING_PRICE_LEAD_MINUTES).
|
|
160
|
+
*/
|
|
161
|
+
export function closingPriceTime(exchange: string | undefined, close: number): number {
|
|
162
|
+
return close - (CLOSING_PRICE_LEAD_MINUTES[canonicalExchange(exchange)] ?? 0) * 60_000;
|
|
163
|
+
}
|
|
131
164
|
// Venues whose week is not Monday to Friday, as their days off (0 is Sunday).
|
|
132
165
|
// Tadawul, Qatar, Boursa Kuwait and the Egyptian Exchange trade Sunday to
|
|
133
166
|
// Thursday. Dubai's DFM has traded Monday to Friday since 2022, like the
|
|
@@ -74,6 +74,8 @@ const STALE_SESSION_LABEL = "STALE";
|
|
|
74
74
|
* one (Quote.nominalPrice).
|
|
75
75
|
*/
|
|
76
76
|
const NO_TRADES_SESSION_LABEL = "NO TRADES";
|
|
77
|
+
/** What a quote's session reads as when no live quote prices it: the close of its latest daily bar (Quote.dailyClose). */
|
|
78
|
+
const DAILY_CLOSE_SESSION_LABEL = "DAILY CLOSE";
|
|
77
79
|
|
|
78
80
|
const WEEKDAYS = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"] as const;
|
|
79
81
|
const MONTHS = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"] as const;
|
|
@@ -147,6 +149,7 @@ function quoteMarketState(quote: Quote | null | undefined, now = Date.now()): Ma
|
|
|
147
149
|
export function quoteMarketStateLabel(quote: Quote | null | undefined, now = Date.now()): string | null {
|
|
148
150
|
if (quote?.delisting) return delistingLabel(quote.delisting);
|
|
149
151
|
if (quote?.nominalPrice) return NO_TRADES_SESSION_LABEL;
|
|
152
|
+
if (quote?.dailyClose) return DAILY_CLOSE_SESSION_LABEL;
|
|
150
153
|
if (!quote?.marketState) return null;
|
|
151
154
|
if (isQuoteBeforeLatestSession(quote, now)) return STALE_SESSION_LABEL;
|
|
152
155
|
const awaiting = preMarketCloseAwaitingPrint(quote);
|
|
@@ -254,6 +257,7 @@ export function quoteSessionStateLabel(quote: Quote | null | undefined, now = Da
|
|
|
254
257
|
function sessionLabel(quote: Quote | null | undefined, now: number, standingClose: boolean): string | null {
|
|
255
258
|
if (quote?.delisting) return standingClose ? delistingLabel(quote.delisting) : delistingStateLabel(quote.delisting);
|
|
256
259
|
if (quote?.nominalPrice) return NO_TRADES_SESSION_LABEL;
|
|
260
|
+
if (quote?.dailyClose) return DAILY_CLOSE_SESSION_LABEL;
|
|
257
261
|
if (!quote?.marketState) return null;
|
|
258
262
|
if (isQuoteBeforeLatestSession(quote, now)) return STALE_SESSION_LABEL;
|
|
259
263
|
if (overnightSessionDisplay(quote)) return "OVERNIGHT";
|
|
@@ -268,7 +272,7 @@ function sessionLabel(quote: Quote | null | undefined, now: number, standingClos
|
|
|
268
272
|
* pre-market still stands at.
|
|
269
273
|
*/
|
|
270
274
|
export function quoteSessionColor(quote: Quote | null | undefined, palette: ThemeColors = colors, now = Date.now()): string {
|
|
271
|
-
if (quote?.delisting || quote?.nominalPrice) return palette.warning;
|
|
275
|
+
if (quote?.delisting || quote?.nominalPrice || quote?.dailyClose) return palette.warning;
|
|
272
276
|
if (!quote?.marketState) return palette.textDim;
|
|
273
277
|
if (isQuoteBeforeLatestSession(quote, now)) return palette.warning;
|
|
274
278
|
if (overnightSessionDisplay(quote)) return marketStateColor("POST", palette);
|
|
@@ -230,6 +230,16 @@ export function mergeQuoteContribution(
|
|
|
230
230
|
regularChangePercent: next.regularClose != null ? next.regularChangePercent : undefined,
|
|
231
231
|
};
|
|
232
232
|
|
|
233
|
+
// Where a 52-week range comes from is said of that range: it goes with the range the merge keeps. A tick that
|
|
234
|
+
// relays the same range without saying (a stream's quote built on the served one) keeps the word; one with
|
|
235
|
+
// another range, or a copy saved before the word existed, says its own, or none.
|
|
236
|
+
if (next.high52w !== undefined || next.low52w !== undefined) {
|
|
237
|
+
const relayed = next.yearRangeBasis === undefined && next.high52w === current.high52w && next.low52w === current.low52w;
|
|
238
|
+
const basis = relayed ? current.yearRangeBasis : next.yearRangeBasis;
|
|
239
|
+
if (basis) merged.yearRangeBasis = basis;
|
|
240
|
+
else delete merged.yearRangeBasis;
|
|
241
|
+
}
|
|
242
|
+
|
|
233
243
|
// What this observation's move is from, when not its previous close (a coin's
|
|
234
244
|
// 24 hours), is said with each one: a quote back on its
|
|
235
245
|
// previous close drops an earlier "24h", and one on 24 hours drops the
|
|
@@ -224,6 +224,25 @@ export function nominalSessionLabel(quote: Pick<Quote, "nominalPrice"> | null |
|
|
|
224
224
|
return day && Number.isFinite(day.getTime()) ? `${day.getUTCDate()} ${PRINT_MONTHS[day.getUTCMonth()]} close` : null;
|
|
225
225
|
}
|
|
226
226
|
|
|
227
|
+
/**
|
|
228
|
+
* What a quote with no live price says beside it (Quote.dailyClose): "no live
|
|
229
|
+
* quote, daily close of Wed 11 Nov". Null for any other quote.
|
|
230
|
+
*/
|
|
231
|
+
export function dailyCloseText(quote: Pick<Quote, "dailyClose"> | null | undefined): string | null {
|
|
232
|
+
const session = quote?.dailyClose?.session;
|
|
233
|
+
const day = session ? new Date(`${session}T00:00:00Z`) : null;
|
|
234
|
+
return day && Number.isFinite(day.getTime())
|
|
235
|
+
? `no live quote, daily close of ${PRINT_WEEKDAYS[day.getUTCDay()]} ${day.getUTCDate()} ${PRINT_MONTHS[day.getUTCMonth()]}`
|
|
236
|
+
: null;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
/** When a daily close is from, as an Updated cell names it: "11 Nov daily close" (Quote.dailyClose). Null for any other quote. */
|
|
240
|
+
export function dailyCloseSessionLabel(quote: Pick<Quote, "dailyClose"> | null | undefined): string | null {
|
|
241
|
+
const session = quote?.dailyClose?.session;
|
|
242
|
+
const day = session ? new Date(`${session}T00:00:00Z`) : null;
|
|
243
|
+
return day && Number.isFinite(day.getTime()) ? `${day.getUTCDate()} ${PRINT_MONTHS[day.getUTCMonth()]} daily close` : null;
|
|
244
|
+
}
|
|
245
|
+
|
|
227
246
|
/** A US listing's after-hours session ends four hours past its regular close (17:00 New York after an early close). */
|
|
228
247
|
const US_AFTER_HOURS_MS = 4 * 60 * 60_000;
|
|
229
248
|
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { AnalystResearchData, CorporateActionsData, Fundamentals, Quote, TickerFinancials } from "../../types/financials";
|
|
2
2
|
import { atRegularSessionPrice, regularSessionValuationPrice } from "./regular-session-valuation";
|
|
3
|
+
import { isIndexLevel } from "../market/index-level";
|
|
4
|
+
import { isYieldIndexSymbol } from "../../tickers/index-roots";
|
|
3
5
|
import { hasLikelyQuoteUnitMismatch, resolveCurrencyUnit } from "../../utils/currency-units";
|
|
4
6
|
import { cashInMajorUnits } from "../../utils/dividend-cash";
|
|
5
7
|
import { cashDistribution, dividendReferencePrice, trailingDividendYield, type CashDistribution } from "../../utils/trailing-dividend";
|
|
@@ -196,6 +198,30 @@ export function liveMarketCapitalization(
|
|
|
196
198
|
return { ...stored, value: shares * price, live: true };
|
|
197
199
|
}
|
|
198
200
|
|
|
201
|
+
/** Whether a value is one of the quote's levels: above 0, or any finite yield for a Treasury yield index (^IRX can read 0). */
|
|
202
|
+
function quoteLevel(quote: Quote): (value: number | null | undefined) => value is number {
|
|
203
|
+
return isYieldIndexSymbol(quote.symbol)
|
|
204
|
+
? (value: number | null | undefined): value is number => value != null && Number.isFinite(value)
|
|
205
|
+
: positive;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* The 52-week range a quote states, when it is one: both bounds above 0 (a
|
|
210
|
+
* Treasury yield index's at any level, 0 and below included), and for an index
|
|
211
|
+
* not its day's range again (a source that repeats the session's low and high
|
|
212
|
+
* as the year's: the EGX 30's 52,691.30 high on a day its bars spanned 39,537
|
|
213
|
+
* to 56,931). A range the service read from the stored daily bars instead
|
|
214
|
+
* (Quote.yearRangeBasis) is one whatever it equals.
|
|
215
|
+
*/
|
|
216
|
+
export function statedYearRange(quote: Quote | null | undefined): { low: number; high: number } | null {
|
|
217
|
+
if (!quote) return null;
|
|
218
|
+
const level = quoteLevel(quote);
|
|
219
|
+
if (!level(quote.low52w) || !level(quote.high52w) || quote.high52w < quote.low52w) return null;
|
|
220
|
+
const repeatsDay = quote.low52w === quote.low && quote.high52w === quote.high;
|
|
221
|
+
if (repeatsDay && quote.yearRangeBasis !== "daily-bars" && isIndexLevel(quote.instrumentType)) return null;
|
|
222
|
+
return { low: quote.low52w, high: quote.high52w };
|
|
223
|
+
}
|
|
224
|
+
|
|
199
225
|
/**
|
|
200
226
|
* The 52-week extremes with today's session folded in, so a new high or low
|
|
201
227
|
* reads 100% or 0% instead of pinning against a stale bound. A caller that
|
|
@@ -205,10 +231,11 @@ export function liveFiftyTwoWeekRange(
|
|
|
205
231
|
quote: Quote | null | undefined,
|
|
206
232
|
displayedPrice?: number | null,
|
|
207
233
|
): { low: number; high: number } | null {
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
const
|
|
211
|
-
const
|
|
234
|
+
const stated = statedYearRange(quote);
|
|
235
|
+
if (!quote || !stated) return null;
|
|
236
|
+
const session = [quote.price, quote.high, quote.low, displayedPrice].filter(quoteLevel(quote));
|
|
237
|
+
const low = Math.min(stated.low, ...session);
|
|
238
|
+
const high = Math.max(stated.high, ...session);
|
|
212
239
|
return high > low ? { low, high } : null;
|
|
213
240
|
}
|
|
214
241
|
|
|
@@ -510,6 +510,10 @@ export function resolveCanonicalQuote(
|
|
|
510
510
|
changeSessionDate: resolved.changeSessionDate as Quote["changeSessionDate"],
|
|
511
511
|
high52w: resolved.high52w as Quote["high52w"],
|
|
512
512
|
low52w: resolved.low52w as Quote["low52w"],
|
|
513
|
+
// Said of the range, so it comes with the provider whose range it is.
|
|
514
|
+
yearRangeBasis: contributions.find((quote) => quote.high52w === resolved.high52w && quote.low52w === resolved.low52w)?.yearRangeBasis,
|
|
515
|
+
// Said of the price, so it comes with it.
|
|
516
|
+
dailyClose: priceProvider?.dailyClose,
|
|
513
517
|
marketCap: resolved.marketCap as Quote["marketCap"],
|
|
514
518
|
volume: resolved.volume as Quote["volume"],
|
|
515
519
|
name: resolved.name as Quote["name"],
|
|
@@ -108,17 +108,3 @@ export function formatQuoteAgeWithSource(
|
|
|
108
108
|
const prefix = quote.dataSource === "delayed" ? "◷" : "";
|
|
109
109
|
return prefix ? `${prefix}${age}` : age;
|
|
110
110
|
}
|
|
111
|
-
|
|
112
|
-
export function getMostRecentQuoteUpdate(
|
|
113
|
-
quotes: Iterable<Pick<Quote, "lastUpdated" | "receivedAt"> | null | undefined>,
|
|
114
|
-
now = Date.now(),
|
|
115
|
-
): number | null {
|
|
116
|
-
let latest: number | null = null;
|
|
117
|
-
for (const quote of quotes) {
|
|
118
|
-
const timestamp = resolveQuoteAgeTimestamp(quote, now);
|
|
119
|
-
if (timestamp != null && (latest == null || timestamp > latest)) {
|
|
120
|
-
latest = timestamp;
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
return latest;
|
|
124
|
-
}
|
|
@@ -10,6 +10,7 @@ export const accountManagementModule: PluginModule = {
|
|
|
10
10
|
reportFreshness: { status: "not-a-feed", basis: "account data", local: true },
|
|
11
11
|
defaultPosition: "right",
|
|
12
12
|
defaultMode: "floating",
|
|
13
|
+
utilityWindow: true,
|
|
13
14
|
defaultFloatingSize: { width: 72, height: 36 },
|
|
14
15
|
portableShare: {
|
|
15
16
|
private: { title: true, params: true, settings: true, state: true },
|