@gloom-sh/terminal 0.20.17 → 0.20.18
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 +3 -1
- package/src/account/auth-dialog.tsx +19 -1
- package/src/account/billing.ts +2 -1
- package/src/account/heard-from-question.tsx +235 -0
- package/src/account/heard-from.ts +97 -0
- package/src/api-client/data.ts +3 -2
- package/src/api-client/heard-from.ts +72 -0
- package/src/api-client/index.ts +63 -6
- package/src/api-client/mna.ts +18 -0
- package/src/api-client/supply-chain.ts +9 -0
- package/src/api-client/types/billing.ts +35 -1
- package/src/app/global-shortcuts.ts +5 -3
- package/src/app/pro-welcome/keys.ts +27 -0
- package/src/app/pro-welcome/model.ts +158 -0
- package/src/app/pro-welcome/row.tsx +176 -0
- package/src/app/pro-welcome/use-pro-welcome.ts +156 -0
- package/src/app/runtime/external-profile-changes.ts +135 -0
- package/src/app.tsx +33 -2
- package/src/architecture/core-builtin-allowlist.json +1 -1
- package/src/architecture/floating-promise-allowlist.json +0 -1
- package/src/architecture/shortcut-labels-allowlist.json +1 -0
- package/src/cli/alert-listing.ts +98 -0
- package/src/cli/commands/market.ts +138 -22
- package/src/cli/commands/overview.ts +7 -1
- package/src/cli/commands/plugins.ts +3 -2
- package/src/cli/commands/search.ts +30 -6
- package/src/cli/context.ts +16 -5
- package/src/cli/csv-export.ts +2 -1
- package/src/cli/desktop-pane-shot.ts +72 -9
- package/src/cli/glossary.ts +64 -10
- package/src/cli/history-demergers.ts +117 -0
- package/src/cli/history-rows.ts +6 -2
- package/src/cli/index.ts +1 -0
- package/src/cli/known-gaps.ts +16 -0
- package/src/cli/known-us-stocks.ts +18 -0
- package/src/cli/listing-arg.ts +105 -15
- package/src/cli/pane-functions/catalog-snapshot-build.ts +83 -0
- package/src/cli/pane-functions/catalog-snapshot.json +866 -0
- package/src/cli/pane-functions/catalog-snapshot.ts +62 -0
- package/src/cli/pane-functions/catalog.ts +50 -16
- package/src/cli/pane-functions/data.ts +16 -4
- package/src/cli/pane-functions/dom.ts +24 -6
- package/src/cli/pane-functions/freshness.ts +17 -1
- package/src/cli/pane-functions/index.ts +100 -42
- package/src/cli/pane-functions/resolver.ts +8 -5
- package/src/cli/pane-functions/screenshot-assessment.ts +30 -7
- package/src/cli/pane-functions/screenshot-payload.ts +21 -0
- package/src/cli/pane-functions/screenshot-render.ts +3 -1
- package/src/cli/quote-answer.ts +32 -16
- package/src/cli/registry.ts +22 -2
- package/src/cli/result.ts +5 -4
- package/src/cli/series-search.ts +45 -6
- package/src/cli/shot-temp-dir.ts +4 -9
- package/src/components/chart/composite/legend.tsx +43 -18
- package/src/components/chart/composite/panel-surface/panel-cursor.tsx +3 -3
- package/src/components/chart/composite/price-axis-labels.tsx +7 -5
- package/src/components/chart-table/header.tsx +9 -0
- package/src/components/chart-table/layout.ts +11 -11
- package/src/components/command-bar/pane-templates/items.ts +17 -1
- package/src/components/command-bar/routes/root/provider-search.ts +10 -1
- package/src/components/command-bar/routes/root/results.ts +34 -2
- package/src/components/command-bar/routes/root/runtime.ts +8 -1
- package/src/components/command-bar/routes/ticker-search/route.ts +5 -0
- package/src/components/command-bar/workflow/alert.ts +19 -8
- package/src/components/data-table/view.tsx +15 -2
- package/src/components/form-modal/content.tsx +9 -4
- package/src/components/index.ts +1 -1
- package/src/components/layout/header.tsx +9 -5
- package/src/components/layout/pane/capture-status.ts +6 -0
- package/src/components/layout/pane/footer/index.tsx +2 -0
- package/src/components/layout/pane/footer/model.ts +113 -15
- package/src/components/layout/pane/header.tsx +16 -2
- package/src/components/market-board/index.tsx +4 -2
- package/src/components/onboarding/onboarding-frame.tsx +6 -2
- package/src/components/onboarding/onboarding-keyboard.ts +7 -1
- package/src/components/onboarding/onboarding-wizard.tsx +3 -1
- package/src/components/onboarding/portfolio-step/positions-panel.tsx +24 -15
- package/src/components/onboarding/setup-cards.ts +36 -0
- package/src/components/onboarding/use-onboarding-progress.ts +22 -1
- package/src/components/onboarding/wizard-account.ts +6 -1
- package/src/components/onboarding/wizard-model.ts +32 -6
- package/src/components/onboarding/wizard-positions.ts +1 -1
- package/src/components/sign-in-gate.tsx +3 -1
- package/src/components/toggle-list.tsx +6 -8
- package/src/components/ui/confirm-dialog.tsx +47 -7
- package/src/components/ui/data-table/types.ts +8 -0
- package/src/components/ui/display.tsx +17 -2
- package/src/components/ui/index.ts +1 -1
- package/src/components/ui/stat-grid.tsx +4 -0
- package/src/components/ui/status.tsx +13 -1
- package/src/components/ui/table-layout.ts +2 -1
- package/src/components/use-pane-notice-footer.tsx +16 -3
- package/src/data/config/store/index.ts +31 -0
- package/src/data/config/store/node.ts +61 -11
- package/src/data/config/store/normalize.ts +4 -6
- package/src/data/config/store/shared-file.ts +309 -0
- package/src/data/profile-merge.ts +299 -0
- package/src/data/sqlite/checkpointer.ts +11 -1
- package/src/data/sqlite/database.ts +1 -1
- package/src/data/ticker-repository.ts +134 -10
- package/src/data/ticker-store.ts +67 -0
- package/src/data/ticker-writes.ts +5 -0
- package/src/i18n/es.ts +27 -0
- package/src/i18n/ja.ts +27 -0
- package/src/i18n/ko.ts +27 -0
- package/src/i18n/zh-cn.ts +27 -0
- package/src/i18n/zh-tw.ts +27 -0
- package/src/layout-marketplace/gallery-desktop.tsx +2 -2
- package/src/market-data/ah-pair.ts +103 -0
- package/src/market-data/depositary-pair.ts +6 -2
- package/src/market-data/hooks.tsx +33 -2
- package/src/market-data/market/change-basis.ts +2 -1
- package/src/market-data/market/header-market.ts +11 -0
- package/src/market-data/split-terms.ts +28 -0
- package/src/plugins/builtin/account-management/footer.ts +1 -1
- package/src/plugins/builtin/account-management/keyboard.ts +4 -0
- package/src/plugins/builtin/account-management/model.ts +1 -0
- package/src/plugins/builtin/account-management/pane.tsx +75 -7
- package/src/plugins/builtin/account-management/payment-recovery-row.tsx +12 -5
- package/src/plugins/builtin/account-management/pro-cancel.tsx +197 -0
- package/src/plugins/builtin/account-management/trial-cancel.ts +1 -1
- package/src/plugins/builtin/alerts/cli-move.ts +2 -2
- package/src/plugins/builtin/alerts/cli.ts +36 -30
- package/src/plugins/builtin/alerts/constants.ts +10 -0
- package/src/plugins/builtin/alerts/earnings-listing.ts +20 -0
- package/src/plugins/builtin/alerts/format.ts +24 -8
- package/src/plugins/builtin/alerts/index.tsx +38 -9
- package/src/plugins/builtin/alerts/move-checks.ts +7 -0
- package/src/plugins/builtin/alerts/pane.tsx +1 -1
- package/src/plugins/builtin/alerts/quotes.ts +26 -2
- package/src/plugins/builtin/alerts/scheduled.ts +6 -1
- package/src/plugins/builtin/alerts/types.ts +7 -0
- package/src/plugins/builtin/analytics/manual-value.ts +61 -0
- package/src/plugins/builtin/analytics/risk-book.ts +7 -7
- package/src/plugins/builtin/analytics/risk-client.ts +26 -13
- package/src/plugins/builtin/analytics/risk-headless.ts +13 -8
- package/src/plugins/builtin/analytics/risk-model.ts +92 -4
- package/src/plugins/builtin/analytics/risk-pane.tsx +85 -38
- package/src/plugins/builtin/awards/pane.tsx +1 -1
- package/src/plugins/builtin/broker-trading/orders.tsx +2 -2
- package/src/plugins/builtin/central-bank-rates/model.ts +8 -2
- package/src/plugins/builtin/central-bank-rates/pane.tsx +5 -3
- package/src/plugins/builtin/chart-composer/cli-options.ts +4 -2
- package/src/plugins/builtin/chart-composer/data-catalog-pane.tsx +2 -6
- package/src/plugins/builtin/chart-composer/pane.tsx +5 -2
- package/src/plugins/builtin/cloud/auth-actions.tsx +11 -6
- package/src/plugins/builtin/cloud/company-picker.tsx +5 -3
- package/src/plugins/builtin/cloud/upgrade-command.ts +1 -1
- package/src/plugins/builtin/company-kpis/headless.ts +9 -4
- package/src/plugins/builtin/company-kpis/latest.ts +45 -0
- package/src/plugins/builtin/company-kpis/model.ts +38 -8
- package/src/plugins/builtin/company-kpis/pane.tsx +22 -8
- package/src/plugins/builtin/composite/alt-data.ts +20 -0
- package/src/plugins/builtin/composite/application.ts +14 -0
- package/src/plugins/builtin/composite/broker.ts +12 -0
- package/src/plugins/builtin/composite/credit.ts +33 -0
- package/src/plugins/builtin/composite/crypto.ts +10 -0
- package/src/plugins/builtin/composite/earnings.ts +12 -0
- package/src/plugins/builtin/composite/filings.ts +13 -0
- package/src/plugins/builtin/composite/futures-commodities.ts +23 -0
- package/src/plugins/builtin/composite/global-markets.ts +12 -0
- package/src/plugins/builtin/composite/options-volatility.ts +23 -0
- package/src/plugins/builtin/composite/ownership.ts +23 -0
- package/src/plugins/builtin/composite/portfolio.ts +10 -0
- package/src/plugins/builtin/composite/quant.ts +15 -0
- package/src/plugins/builtin/composite/rates-macro.ts +30 -0
- package/src/plugins/builtin/composite/screeners.ts +11 -0
- package/src/plugins/builtin/composite/shared.ts +11 -0
- package/src/plugins/builtin/composite/ticker-core.ts +36 -0
- package/src/plugins/builtin/congress-trades/headless.ts +31 -3
- package/src/plugins/builtin/correlation/index.tsx +13 -17
- package/src/plugins/builtin/correlation/matrix/model.ts +18 -0
- package/src/plugins/builtin/dividend-yield/client.ts +57 -16
- package/src/plugins/builtin/dividend-yield/headless.ts +17 -11
- package/src/plugins/builtin/dividend-yield/model.ts +4 -3
- package/src/plugins/builtin/dividend-yield/pane.tsx +22 -18
- package/src/plugins/builtin/dividend-yield/ranking.ts +1 -1
- package/src/plugins/builtin/dividend-yield/types.ts +4 -0
- package/src/plugins/builtin/dividend-yield/view.ts +23 -12
- package/src/plugins/builtin/earnings/fiscal-quarter.ts +39 -0
- package/src/plugins/builtin/earnings/headless.ts +7 -4
- package/src/plugins/builtin/earnings/history-model.ts +6 -4
- package/src/plugins/builtin/earnings/history-table.ts +4 -3
- package/src/plugins/builtin/earnings-calls/pane.tsx +8 -2
- package/src/plugins/builtin/econ/calendar-model.ts +16 -0
- package/src/plugins/builtin/econ/index.tsx +3 -0
- package/src/plugins/builtin/equity-screener/headless.ts +4 -1
- package/src/plugins/builtin/equity-screener/model.ts +7 -6
- package/src/plugins/builtin/estimate-revisions/headless.ts +1 -1
- package/src/plugins/builtin/exposure/model.ts +10 -0
- package/src/plugins/builtin/exposure/pane.tsx +10 -3
- package/src/plugins/builtin/fx-matrix/amount.ts +15 -1
- package/src/plugins/builtin/fx-matrix/headless.ts +12 -6
- package/src/plugins/builtin/fx-matrix/index.tsx +23 -5
- package/src/plugins/builtin/fx-matrix/settings.ts +9 -4
- package/src/plugins/builtin/kelly-sizer/pane.tsx +9 -4
- package/src/plugins/builtin/market-valuation/pane.tsx +22 -10
- package/src/plugins/builtin/mna/detail.tsx +67 -6
- package/src/plugins/builtin/mna/headless.ts +128 -13
- package/src/plugins/builtin/mna/model.ts +219 -16
- package/src/plugins/builtin/mna/pane.tsx +34 -6
- package/src/plugins/builtin/money-markets/model.ts +14 -5
- package/src/plugins/builtin/money-markets/pane.tsx +4 -3
- package/src/plugins/builtin/news/wire/news/footer.ts +3 -8
- package/src/plugins/builtin/options-scenario/csp-screen-pane.tsx +22 -6
- package/src/plugins/builtin/options-scenario/csp-screen.ts +39 -12
- package/src/plugins/builtin/options-scenario/strategy-screen.ts +7 -5
- package/src/plugins/builtin/pe-band/client.ts +13 -1
- package/src/plugins/builtin/pe-band/headless.ts +2 -2
- package/src/plugins/builtin/pe-band/model.ts +63 -10
- package/src/plugins/builtin/pe-band/pane.tsx +5 -5
- package/src/plugins/builtin/portfolio-list/allocation-rows.ts +26 -7
- package/src/plugins/builtin/portfolio-list/cli/portfolio-command.ts +66 -13
- package/src/plugins/builtin/portfolio-list/cli/render.ts +76 -33
- package/src/plugins/builtin/portfolio-list/headless.ts +69 -22
- package/src/plugins/builtin/portfolio-list/pane/data.ts +3 -3
- package/src/plugins/builtin/portfolio-list/pane/index.tsx +29 -14
- package/src/plugins/builtin/portfolio-list/summary/index.tsx +2 -2
- package/src/plugins/builtin/relative-rotation/pane.tsx +2 -3
- package/src/plugins/builtin/research/corporate-actions-pane.tsx +5 -1
- package/src/plugins/builtin/research/event-model.ts +31 -13
- package/src/plugins/builtin/research/headless.ts +8 -1
- package/src/plugins/builtin/research/relative-valuation-pane.tsx +19 -17
- package/src/plugins/builtin/sectors/index.tsx +6 -9
- package/src/plugins/builtin/shared/cloud-upgrade.ts +1 -1
- package/src/plugins/builtin/shared/earnings-report.ts +19 -4
- package/src/plugins/builtin/shared/report-freshness.ts +2 -3
- package/src/plugins/builtin/supply-chain/client.ts +34 -9
- package/src/plugins/builtin/supply-chain/evidence.ts +3 -2
- package/src/plugins/builtin/supply-chain/flow.tsx +4 -3
- package/src/plugins/builtin/supply-chain/graph-model.ts +14 -7
- package/src/plugins/builtin/supply-chain/graph-pane.tsx +3 -1
- package/src/plugins/builtin/supply-chain/graph.tsx +6 -3
- package/src/plugins/builtin/supply-chain/headless.ts +19 -4
- package/src/plugins/builtin/supply-chain/model.ts +50 -6
- package/src/plugins/builtin/supply-chain/pane.tsx +76 -16
- package/src/plugins/builtin/ticker-detail/adr-pair/ah.ts +62 -0
- package/src/plugins/builtin/ticker-detail/adr-pair/headless.ts +119 -20
- package/src/plugins/builtin/ticker-detail/adr-pair/model.ts +51 -1
- package/src/plugins/builtin/ticker-detail/adr-pair/tab.tsx +25 -14
- package/src/plugins/builtin/ticker-detail/overview/model.ts +17 -1
- package/src/plugins/builtin/ticker-detail/overview/pane.tsx +4 -0
- package/src/plugins/builtin/ticker-detail/overview-tab.tsx +9 -2
- package/src/plugins/builtin/ticker-detail/quote-monitor/card.tsx +9 -2
- package/src/plugins/builtin/ticker-detail/quote-monitor/index.tsx +5 -2
- package/src/plugins/builtin/volatility/model.ts +17 -0
- package/src/plugins/builtin/volatility/pane.tsx +13 -4
- package/src/plugins/builtin/world-indices/index.tsx +2 -0
- package/src/plugins/builtin/world-indices/table.tsx +15 -0
- package/src/plugins/builtin/world-venue-map/evidence.ts +3 -2
- package/src/plugins/builtin/world-venue-map/headless.ts +28 -16
- package/src/plugins/builtin/world-venue-map/index.ts +19 -6
- package/src/plugins/builtin/world-venue-map/layered-pane.tsx +9 -5
- package/src/plugins/builtin/world-venue-map/layers.ts +33 -11
- package/src/plugins/builtin/world-venue-map/map.tsx +12 -0
- package/src/plugins/builtin/world-venue-map/pane.tsx +35 -6
- package/src/plugins/builtin/world-venue-map/place.ts +119 -0
- package/src/plugins/catalog-data.ts +20 -0
- package/src/plugins/catalog-lazy.ts +51 -0
- package/src/plugins/catalog-ui.ts +16 -18
- package/src/plugins/host-smoke.ts +5 -2
- package/src/portfolio/allocation.ts +79 -19
- package/src/portfolio/cash-balances.ts +76 -0
- package/src/portfolio/mutations.ts +43 -8
- package/src/public/__snapshots__/public-api.test.ts.snap +1 -0
- package/src/renderers/desktop/window-layouts.ts +14 -0
- package/src/renderers/dom/data-table/row.tsx +2 -0
- package/src/renderers/dom/host/tabs.tsx +57 -8
- package/src/renderers/dom/styles.css +13 -5
- package/src/renderers/electrobun/bun/desktop/backend-requests.ts +4 -0
- package/src/renderers/electrobun/bun/desktop/backend.ts +22 -1
- package/src/renderers/electrobun/bun/window/native-min-size.ts +6 -1
- package/src/renderers/electrobun/shared/protocol.ts +4 -0
- package/src/renderers/electrobun/view/cli-pane-shot-frame.tsx +50 -12
- package/src/renderers/electrobun/view/remote/ticker-repository.ts +10 -0
- package/src/series/standalone-catalog.ts +5 -4
- package/src/series/standalone.ts +13 -7
- package/src/sources/gloomberb-cloud/index.ts +14 -3
- package/src/sources/gloomberb-cloud/perpetuals.ts +60 -3
- package/src/sources/provider-router/financials.ts +20 -13
- package/src/sources/provider-router/index.ts +4 -0
- package/src/sources/provider-router/search.ts +1 -0
- package/src/sync/collections-contributor.ts +3 -1
- package/src/sync/config-merge.ts +10 -1
- package/src/sync/sanitize.ts +26 -2
- package/src/tickers/company-name-listing.ts +16 -2
- package/src/tickers/listing-fate.ts +12 -8
- package/src/tickers/renamed-listings.ts +43 -10
- package/src/tickers/search/home-listing.ts +28 -0
- package/src/tickers/search/index.ts +19 -7
- package/src/tickers/terminal-codes.ts +11 -1
- package/src/time-series/resolve.ts +3 -1
- package/src/time-series/spec.ts +2 -2
- package/src/time-series/types.ts +1 -1
- package/src/types/data-provider.ts +11 -0
- package/src/types/financials.ts +39 -3
- package/src/types/ticker.ts +10 -2
- package/src/utils/cli-output.ts +1 -1
- package/src/utils/declared-dividends.ts +13 -1
- package/src/utils/dividend-cash.ts +5 -1
- package/src/utils/forward-dividend.ts +4 -3
- package/src/utils/remove-folder.ts +37 -0
- package/src/utils/trailing-dividend.ts +1 -1
- package/src/plugins/builtin/composite-plugins.ts +0 -285
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
/** @jsxImportSource react */
|
|
2
2
|
import { useCallback, useEffect, useRef, useState, type ReactNode } from "react";
|
|
3
3
|
import { FloatingPaneWrapper } from "../../../components/layout/floating-pane";
|
|
4
|
-
import { CaptureDatesDataContext } from "../../../components/layout/pane/capture-status";
|
|
4
|
+
import { CaptureDatesDataContext, PaneCaptureContext } from "../../../components/layout/pane/capture-status";
|
|
5
5
|
import { PaneFooterProvider, datesPaneData, hasPaneFooterContent, type PaneFooterSegment } from "../../../components/layout/pane/footer";
|
|
6
|
+
import { noteLineParts } from "../../../components/layout/pane/footer/model";
|
|
6
7
|
import { resolvePaneBodyFrame } from "../../../components/layout/pane/sizing";
|
|
7
8
|
|
|
8
9
|
/** What a capture's status line dates (`CaptureStatusLine`): the pane's own data, the quotes on screen, or neither. */
|
|
@@ -35,19 +36,45 @@ function nextFrames(count: number): Promise<void> {
|
|
|
35
36
|
});
|
|
36
37
|
}
|
|
37
38
|
|
|
38
|
-
/**
|
|
39
|
-
|
|
39
|
+
/** What a cut line's ends do not start or end on beside the ellipsis: a separator or a space. */
|
|
40
|
+
const LOOSE_END = /^[\s·,;:]+|[\s·,;:]+$/gu;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Keeps the start and the end of a line that does not fit, `keep` characters
|
|
44
|
+
* in all, in whole words ("US trading day Mon … 15 min delayed"), never a
|
|
45
|
+
* word cut ("Mon 1…ose"); by characters only where not a word fits either end.
|
|
46
|
+
*/
|
|
47
|
+
export function middleEllipsis(text: string, keep: number): string {
|
|
40
48
|
if (keep >= text.length) return text;
|
|
41
|
-
const
|
|
42
|
-
const
|
|
43
|
-
|
|
49
|
+
const headRoom = Math.ceil(keep / 2);
|
|
50
|
+
const tailRoom = Math.max(0, keep - headRoom);
|
|
51
|
+
const words = text.split(" ");
|
|
52
|
+
let head = "";
|
|
53
|
+
for (const word of words) {
|
|
54
|
+
const next = head ? `${head} ${word}` : word;
|
|
55
|
+
if (next.length > headRoom) break;
|
|
56
|
+
head = next;
|
|
57
|
+
}
|
|
58
|
+
let tail = "";
|
|
59
|
+
for (const word of [...words].reverse()) {
|
|
60
|
+
const next = tail ? `${word} ${tail}` : word;
|
|
61
|
+
if (next.length > tailRoom) break;
|
|
62
|
+
tail = next;
|
|
63
|
+
}
|
|
64
|
+
head = head.replace(LOOSE_END, "");
|
|
65
|
+
tail = tail.replace(LOOSE_END, "");
|
|
66
|
+
if (head && tail) return `${head} … ${tail}`;
|
|
67
|
+
if (head) return `${head}…`;
|
|
68
|
+
return `${text.slice(0, headRoom).trimEnd()}…${tailRoom > 0 ? text.slice(text.length - tailRoom).trimStart() : ""}`;
|
|
44
69
|
}
|
|
45
70
|
|
|
46
71
|
/**
|
|
47
72
|
* The first variant that fits; else, when the footer can make room (the
|
|
48
73
|
* pane's own `as of` gives way), the first that fits then; else the last one
|
|
49
|
-
* cut in the middle as little as it must be.
|
|
50
|
-
*
|
|
74
|
+
* cut in the middle, between words, as little as it must be. A note line
|
|
75
|
+
* keeps its share of the row (fitPaneFooterInfo): its first words say more
|
|
76
|
+
* than the rest of a status line. `show` puts a text on screen and resolves
|
|
77
|
+
* once it is drawn.
|
|
51
78
|
*/
|
|
52
79
|
async function fitStatusLine(
|
|
53
80
|
variants: readonly string[],
|
|
@@ -133,7 +160,8 @@ function useShotStatusLine(enabled: boolean, hasAsOf: () => boolean): ShotStatus
|
|
|
133
160
|
}
|
|
134
161
|
|
|
135
162
|
/**
|
|
136
|
-
* Static captures retain warnings,
|
|
163
|
+
* Static captures retain warnings, as one note line (the first note, cut
|
|
164
|
+
* after a whole word, and how many more there are), what a filter leaves out (`capture`) and
|
|
137
165
|
* optional source status without action shortcuts. With `statusLine` the footer also carries the capture's dated
|
|
138
166
|
* status line (`Fri 9 Oct close · 15 min delayed · markets closed · regular session opens Mon 13:30 UTC, 09:30 ET`),
|
|
139
167
|
* inside the requested size: the body gives up the footer row for it. The
|
|
@@ -157,9 +185,17 @@ export function PaneShotFrame({ paneId, title, width, height, preserveStatus = f
|
|
|
157
185
|
const datesData = statusLine && dates === "data";
|
|
158
186
|
return <PaneFooterProvider>{(registeredFooter) => {
|
|
159
187
|
const status: PaneFooterSegment[] = statusLine && statusText !== null ? [{ id: "shot-status", parts: [{ text: statusText, tone: "label" }] }] : [];
|
|
160
|
-
|
|
188
|
+
// A warning whose pane gives a picture no notes to print (`captureNotes` empty) leaves no segment.
|
|
189
|
+
const info = registeredFooter.info.filter((segment) => !(segment.icon === "warning" && segment.notes?.length === 0)
|
|
190
|
+
&& (preserveStatus || segment.icon === "warning" || segment.capture)
|
|
161
191
|
&& !(datesPaneData(segment) && (datesData || crowded))
|
|
162
|
-
&& !(segment.quoteStatus && statusLine && dates !== null))
|
|
192
|
+
&& !(segment.quoteStatus && statusLine && dates !== null))
|
|
193
|
+
// Nothing opens a picture's ⚠: its notes are the footer's one note line (noteLineParts).
|
|
194
|
+
.map((segment): PaneFooterSegment => {
|
|
195
|
+
if (segment.icon !== "warning") return segment;
|
|
196
|
+
const notes = segment.notes?.length ? segment.notes : [segment.label ?? segment.title ?? segment.parts.map((part) => part.text).join(" ")];
|
|
197
|
+
return { ...segment, icon: undefined, onPress: undefined, notes, parts: noteLineParts(notes, Number.POSITIVE_INFINITY) };
|
|
198
|
+
});
|
|
163
199
|
shownAsOf.current = info.some(datesPaneData);
|
|
164
200
|
const footer = { info: [...info, ...status], hints: [], menu: [], keys: [] };
|
|
165
201
|
const bodyFrame = resolvePaneBodyFrame({
|
|
@@ -181,7 +217,9 @@ export function PaneShotFrame({ paneId, title, width, height, preserveStatus = f
|
|
|
181
217
|
showActions={false}
|
|
182
218
|
footer={footer}
|
|
183
219
|
>
|
|
184
|
-
<
|
|
220
|
+
<PaneCaptureContext.Provider value>
|
|
221
|
+
<CaptureDatesDataContext.Provider value={datesData}>{children(bodyFrame)}</CaptureDatesDataContext.Provider>
|
|
222
|
+
</PaneCaptureContext.Provider>
|
|
185
223
|
</FloatingPaneWrapper>;
|
|
186
224
|
}}</PaneFooterProvider>;
|
|
187
225
|
}
|
|
@@ -7,6 +7,16 @@ export class RemoteTickerRepository {
|
|
|
7
7
|
return backendRequest("ticker.loadAll");
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
+
/** Changes when another program (a `gloom` command, the terminal app) commits to the profile's database. */
|
|
11
|
+
changesElsewhere(): Promise<number | null> {
|
|
12
|
+
return backendRequest("ticker.changesElsewhere");
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/** The rows another program deleted that the backend held, for this window to drop from what it shows. */
|
|
16
|
+
takeRowsDeletedElsewhere(): Promise<string[]> {
|
|
17
|
+
return backendRequest("ticker.takeDeletedElsewhere");
|
|
18
|
+
}
|
|
19
|
+
|
|
10
20
|
async loadTicker(symbol: string): Promise<TickerRecord | null> {
|
|
11
21
|
return backendRequest("ticker.load", { symbol });
|
|
12
22
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { GloomPlugin } from "../types/plugin";
|
|
2
1
|
import { logFailure } from "../utils/log-failure";
|
|
3
2
|
import { SeriesRegistry } from "./registry";
|
|
3
|
+
import { type SeriesPlugins, pluginsOf } from "./standalone";
|
|
4
4
|
import type { SeriesCatalogEntry } from "./types";
|
|
5
5
|
|
|
6
6
|
let standaloneEntries: (() => readonly SeriesCatalogEntry[]) | null = null;
|
|
@@ -10,7 +10,7 @@ let standaloneEntries: (() => readonly SeriesCatalogEntry[]) | null = null;
|
|
|
10
10
|
* where no plugin runtime runs: the series the plugins declare, registered
|
|
11
11
|
* once on first read. Null forgets it.
|
|
12
12
|
*/
|
|
13
|
-
export function setStandaloneSeriesCatalog(plugins:
|
|
13
|
+
export function setStandaloneSeriesCatalog(plugins: SeriesPlugins | null, disabledPlugins: readonly string[] = []): void {
|
|
14
14
|
if (!plugins) {
|
|
15
15
|
standaloneEntries = null;
|
|
16
16
|
return;
|
|
@@ -18,8 +18,9 @@ export function setStandaloneSeriesCatalog(plugins: readonly GloomPlugin[] | nul
|
|
|
18
18
|
let entries: readonly SeriesCatalogEntry[] | null = null;
|
|
19
19
|
standaloneEntries = () => {
|
|
20
20
|
if (entries) return entries;
|
|
21
|
-
const
|
|
22
|
-
|
|
21
|
+
const all = pluginsOf(plugins);
|
|
22
|
+
const registry = new SeriesRegistry({ pluginHosts: (pluginId) => all.find((plugin) => plugin.id === pluginId)?.hosts });
|
|
23
|
+
for (const plugin of all) {
|
|
23
24
|
if (disabledPlugins.includes(plugin.id)) continue;
|
|
24
25
|
for (const definition of plugin.series ?? []) {
|
|
25
26
|
try {
|
package/src/series/standalone.ts
CHANGED
|
@@ -7,6 +7,11 @@ import { readSeriesFolder } from "./files";
|
|
|
7
7
|
import { SeriesRegistry, seriesExpression, seriesNamedBy } from "./registry";
|
|
8
8
|
import type { SeriesDefinition } from "./types";
|
|
9
9
|
|
|
10
|
+
/** The plugins a series lookup reads: a list, or a function that gives it once a series is first asked for. */
|
|
11
|
+
export type SeriesPlugins = readonly GloomPlugin[] | (() => readonly GloomPlugin[]);
|
|
12
|
+
|
|
13
|
+
export const pluginsOf = (plugins: SeriesPlugins): readonly GloomPlugin[] => typeof plugins === "function" ? plugins() : plugins;
|
|
14
|
+
|
|
10
15
|
/**
|
|
11
16
|
* Charts the catalog's loaded series where no plugin runtime runs, such as a
|
|
12
17
|
* `gloom fn G` report: the series plugins declare, and the files in the
|
|
@@ -14,13 +19,14 @@ import type { SeriesDefinition } from "./types";
|
|
|
14
19
|
* need the app.
|
|
15
20
|
*/
|
|
16
21
|
export function standaloneSeriesInvoker(
|
|
17
|
-
plugins:
|
|
22
|
+
plugins: SeriesPlugins,
|
|
18
23
|
dataDir: string,
|
|
19
24
|
disabledPlugins: readonly string[] = [],
|
|
20
25
|
): CapabilityInvoker {
|
|
21
26
|
let registry: Promise<SeriesRegistry> | null = null;
|
|
22
27
|
const build = async () => {
|
|
23
|
-
const
|
|
28
|
+
const all = pluginsOf(plugins);
|
|
29
|
+
const built = new SeriesRegistry({ pluginHosts: (pluginId) => all.find((plugin) => plugin.id === pluginId)?.hosts });
|
|
24
30
|
const register = (pluginId: string, definitions: readonly Parameters<SeriesRegistry["register"]>[1][]) => {
|
|
25
31
|
for (const definition of definitions) {
|
|
26
32
|
try {
|
|
@@ -30,7 +36,7 @@ export function standaloneSeriesInvoker(
|
|
|
30
36
|
}
|
|
31
37
|
}
|
|
32
38
|
};
|
|
33
|
-
for (const plugin of
|
|
39
|
+
for (const plugin of all) {
|
|
34
40
|
if (!disabledPlugins.includes(plugin.id)) register(plugin.id, plugin.series ?? []);
|
|
35
41
|
}
|
|
36
42
|
register("user", await readSeriesFolder(dataDir));
|
|
@@ -56,14 +62,14 @@ export function standaloneSeriesInvoker(
|
|
|
56
62
|
* the registry's `findByExpression` does.
|
|
57
63
|
*/
|
|
58
64
|
export function standaloneSeriesCatalog(
|
|
59
|
-
plugins:
|
|
65
|
+
plugins: SeriesPlugins,
|
|
60
66
|
disabledPlugins: readonly string[] = [],
|
|
61
67
|
): (expression: string) => SeriesDefinition | undefined {
|
|
62
68
|
let byExpression: Map<string, SeriesDefinition> | null = null;
|
|
63
69
|
return (expression) => {
|
|
64
70
|
if (!byExpression) {
|
|
65
71
|
byExpression = new Map();
|
|
66
|
-
for (const plugin of plugins) {
|
|
72
|
+
for (const plugin of pluginsOf(plugins)) {
|
|
67
73
|
if (disabledPlugins.includes(plugin.id)) continue;
|
|
68
74
|
for (const definition of plugin.series ?? []) {
|
|
69
75
|
if (definition.input) continue;
|
|
@@ -78,9 +84,9 @@ export function standaloneSeriesCatalog(
|
|
|
78
84
|
|
|
79
85
|
/** The catalog series a bare word is an alias of (`hashrate`), where no plugin runtime runs; see `seriesNamedBy`. */
|
|
80
86
|
export function standaloneSeriesNamed(
|
|
81
|
-
plugins:
|
|
87
|
+
plugins: SeriesPlugins,
|
|
82
88
|
disabledPlugins: readonly string[] = [],
|
|
83
89
|
): (word: string) => SeriesDefinition | undefined {
|
|
84
|
-
const definitions = () => plugins.filter((plugin) => !disabledPlugins.includes(plugin.id)).flatMap((plugin) => plugin.series ?? []);
|
|
90
|
+
const definitions = () => pluginsOf(plugins).filter((plugin) => !disabledPlugins.includes(plugin.id)).flatMap((plugin) => plugin.series ?? []);
|
|
85
91
|
return (word) => seriesNamedBy(definitions(), word);
|
|
86
92
|
}
|
|
@@ -88,6 +88,7 @@ import {
|
|
|
88
88
|
perpetualTarget,
|
|
89
89
|
searchPerpetualMarkets,
|
|
90
90
|
boardSearchesFrom,
|
|
91
|
+
PerpetualBoardCache,
|
|
91
92
|
} from "./perpetuals";
|
|
92
93
|
import { predictionMarketListing } from "../../tickers/prediction-listing";
|
|
93
94
|
import { cleanListingName } from "../../tickers/company-name";
|
|
@@ -105,6 +106,11 @@ const QUOTE_BATCHES_IN_FLIGHT = 3;
|
|
|
105
106
|
const PERPETUAL_SEARCH_WAIT_MS = 2_000;
|
|
106
107
|
/** How long a batched search waits for the board it answers every query's perpetual markets from. */
|
|
107
108
|
const PERPETUAL_BOARD_WAIT_MS = 5_000;
|
|
109
|
+
/** A bare symbol a command looks up (AAPL, MCO), not a search the person typed to browse: `search` and the command bar keep the contracts. */
|
|
110
|
+
function isSymbolLookup(query: string, context?: SearchRequestContext): boolean {
|
|
111
|
+
return !context?.interactive && context?.perpetuals !== "always" && /^[A-Za-z][A-Za-z0-9]{1,5}$/.test(query.trim());
|
|
112
|
+
}
|
|
113
|
+
|
|
108
114
|
const CLOUD_RESOLUTION_SUPPORT = normalizeChartResolutionSupport([
|
|
109
115
|
{ resolution: "1m", maxRange: "1W" },
|
|
110
116
|
{ resolution: "5m", maxRange: "1M" },
|
|
@@ -524,6 +530,10 @@ function perpetualFinancials(quote: Quote): TickerFinancials {
|
|
|
524
530
|
}
|
|
525
531
|
|
|
526
532
|
export class GloomberbCloudProvider implements AssetDataProvider {
|
|
533
|
+
/** See `AssetDataProvider.knownUsStock`; this provider asks for no perpetual contracts of such a symbol either. */
|
|
534
|
+
knownUsStock?: (symbol: string) => boolean;
|
|
535
|
+
private readonly perpetualBoards = new PerpetualBoardCache();
|
|
536
|
+
|
|
527
537
|
readonly id = providerId;
|
|
528
538
|
readonly name = "Gloom Cloud";
|
|
529
539
|
readonly priority = 100;
|
|
@@ -733,7 +743,8 @@ export class GloomberbCloudProvider implements AssetDataProvider {
|
|
|
733
743
|
async search(query: string, context?: SearchRequestContext): Promise<InstrumentSearchResult[]> {
|
|
734
744
|
// Perpetual markets are listings too, asked for beside the others. They are optional: a failed lookup leaves the
|
|
735
745
|
// other results, and a keystroke waits for them only briefly once the listings are in, unless the query names one.
|
|
736
|
-
const pending =
|
|
746
|
+
const pending = isSymbolLookup(query, context) && this.knownUsStock?.(query) === true ? null
|
|
747
|
+
: searchPerpetualMarkets(query, apiClient, this.perpetualBoards).catch(logFailure("sources.gloomberb-cloud.index", "Searching perpetual markets failed", [] as InstrumentSearchResult[]));
|
|
737
748
|
// A crypto exchange's line of a coin pair, which no source quotes, is offered as the crypto venue's listing.
|
|
738
749
|
const listings = await withCloudFallback(
|
|
739
750
|
async () => withExchangeLinesAsCoinListings(withCleanNames(
|
|
@@ -743,7 +754,7 @@ export class GloomberbCloudProvider implements AssetDataProvider {
|
|
|
743
754
|
// Rate limited or overloaded: the search was not run, which is not a search that found nothing.
|
|
744
755
|
throw isRetryableApiError(error) ? new ProviderBusyError("Cloud search is busy", { cause: error }) : error;
|
|
745
756
|
});
|
|
746
|
-
const perpetuals = await settleWithin(pending, namesPerpetualMarket(query) || !context?.interactive ? PERPETUAL_SEARCH_WAIT_MS : 250) ?? [];
|
|
757
|
+
const perpetuals = pending ? await settleWithin(pending, namesPerpetualMarket(query) || !context?.interactive ? PERPETUAL_SEARCH_WAIT_MS : 250) ?? [] : [];
|
|
747
758
|
// Ahead of the listings, so a contract found by its plain name ("brent" for BZUSDT:BINANCE) is not cut
|
|
748
759
|
// behind every warrant that names it; an exact symbol still leads.
|
|
749
760
|
return perpetuals.length ? [...perpetuals, ...listings] : listings;
|
|
@@ -860,7 +871,7 @@ export class GloomberbCloudProvider implements AssetDataProvider {
|
|
|
860
871
|
// on its own, which finds them then; a board that does not answer leaves them out, as a search does.
|
|
861
872
|
const found = queries.filter((query) => answers.get(query)?.length);
|
|
862
873
|
const board = found.length
|
|
863
|
-
? await settleWithin(
|
|
874
|
+
? await settleWithin(this.perpetualBoards.read(apiClient).catch(logFailure("sources.gloomberb-cloud.index", "Reading the perpetual board failed", null)), PERPETUAL_BOARD_WAIT_MS)
|
|
864
875
|
: null;
|
|
865
876
|
if (!board) return answers;
|
|
866
877
|
const client = boardSearchesFrom(board);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { apiClient } from "../../api-client";
|
|
2
|
+
import { logFailure } from "../../utils/log-failure";
|
|
2
3
|
import type { PerpBoardPayload, PerpBoardRow, PerpMarketPayload } from "../../api-client/perps";
|
|
3
4
|
import type { InstrumentSearchResult } from "../../types/instrument";
|
|
4
5
|
import type { PricePoint, Quote } from "../../types/financials";
|
|
@@ -23,7 +24,7 @@ import { GLOOMBERB_CLOUD_PROVIDER_ID } from "./normalizers";
|
|
|
23
24
|
* its history is Pro, as in PERP.
|
|
24
25
|
*/
|
|
25
26
|
|
|
26
|
-
type PerpsClient = Pick<typeof apiClient, "getCloudPerpsMarket" | "getCloudPerpsBoard" | "getCloudPerpsHistory"
|
|
27
|
+
type PerpsClient = Pick<typeof apiClient, "getCloudPerpsMarket" | "getCloudPerpsBoard" | "getCloudPerpsHistory"> & Partial<Pick<typeof apiClient, "hasSessionCredential" | "getSessionToken">>;
|
|
27
28
|
|
|
28
29
|
/** What the history of a perpetual says to a free account, as PERP's History tab does. */
|
|
29
30
|
export const PERPETUAL_HISTORY_LOCKED = "Full history requires Gloom Pro.";
|
|
@@ -207,6 +208,57 @@ export function boardSearchesFrom(board: PerpBoardPayload, client: PerpsClient =
|
|
|
207
208
|
};
|
|
208
209
|
}
|
|
209
210
|
|
|
211
|
+
/** How long the board a signed-out search reads stays in memory: a command lives for seconds, an open app for much longer. */
|
|
212
|
+
const SEARCH_BOARD_TTL_MS = 5 * 60_000;
|
|
213
|
+
|
|
214
|
+
/** Who a client is asking for: no one, the session it holds, or the browser's own cookie. The board differs between them. */
|
|
215
|
+
function boardAudience(client: PerpsClient): string {
|
|
216
|
+
if (!client.hasSessionCredential?.()) return "signed-out";
|
|
217
|
+
return client.getSessionToken?.() ?? "cookie";
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* The board without a search, read once while it is fresh and for whom it was read. A signed-out account's search is
|
|
222
|
+
* the preview rows that hold its word (`boardSearchesFrom`), so every search of a command costs this one request. A
|
|
223
|
+
* signed-in account's board is the whole of it, which only a list's searches (`searchBatch`) read. A provider holds
|
|
224
|
+
* one, so a process reads the board once however many symbols it looks up; signing in, out or into another account
|
|
225
|
+
* reads it again, since the rows a signed-out preview leaves out are the ones a Pro account is shown.
|
|
226
|
+
*/
|
|
227
|
+
export class PerpetualBoardCache {
|
|
228
|
+
private kept: { readAt: number; audience: string; board: Promise<PerpBoardPayload> } | null = null;
|
|
229
|
+
|
|
230
|
+
read(client: PerpsClient = apiClient): Promise<PerpBoardPayload> {
|
|
231
|
+
const audience = boardAudience(client);
|
|
232
|
+
const kept = this.kept;
|
|
233
|
+
if (kept && kept.audience === audience && Date.now() - kept.readAt < SEARCH_BOARD_TTL_MS) return kept.board;
|
|
234
|
+
const entry = { readAt: Date.now(), audience, board: client.getCloudPerpsBoard({}) };
|
|
235
|
+
this.kept = entry;
|
|
236
|
+
void entry.board.catch(() => {
|
|
237
|
+
if (this.kept === entry) this.kept = null;
|
|
238
|
+
});
|
|
239
|
+
return entry.board;
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* The client a search asks the board with: a signed-out account's one-word search is answered from the board read
|
|
245
|
+
* once, with the rows the service would have sent; any other search goes to the service.
|
|
246
|
+
*/
|
|
247
|
+
function searchBoardClient(client: PerpsClient, boards: PerpetualBoardCache): PerpsClient {
|
|
248
|
+
if (client.hasSessionCredential?.()) return client;
|
|
249
|
+
return {
|
|
250
|
+
getCloudPerpsMarket: client.getCloudPerpsMarket,
|
|
251
|
+
getCloudPerpsHistory: client.getCloudPerpsHistory,
|
|
252
|
+
getCloudPerpsBoard: async (query = {}) => {
|
|
253
|
+
const { search, ...rest } = query;
|
|
254
|
+
const word = search?.trim();
|
|
255
|
+
if (!word || /\s/.test(word) || Object.values(rest).some((value) => value !== undefined)) return client.getCloudPerpsBoard(query);
|
|
256
|
+
const board = await boards.read(client).catch(logFailure("sources.gloomberb-cloud.perpetuals", "Reading the perpetual board for a search failed", null));
|
|
257
|
+
return board ? boardSearchesFrom(board, client).getCloudPerpsBoard({ search: word }) : client.getCloudPerpsBoard(query);
|
|
258
|
+
},
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
|
|
210
262
|
/** The one market a query names by its market id or listing key; null for a search. */
|
|
211
263
|
const namedListing = (query: string) => typedPerpetualListing(query) ?? (query.includes(":") ? perpetualListing(query) : null);
|
|
212
264
|
|
|
@@ -224,7 +276,11 @@ const MAX_ALIAS_SEARCHES = 3;
|
|
|
224
276
|
* Hyperliquid's BRENTOIL). A free account searches the board's preview, as
|
|
225
277
|
* PERP's own search does, but can still name any one market.
|
|
226
278
|
*/
|
|
227
|
-
export async function searchPerpetualMarkets(
|
|
279
|
+
export async function searchPerpetualMarkets(
|
|
280
|
+
query: string,
|
|
281
|
+
client: PerpsClient = apiClient,
|
|
282
|
+
cache: PerpetualBoardCache = new PerpetualBoardCache(),
|
|
283
|
+
): Promise<InstrumentSearchResult[]> {
|
|
228
284
|
const trimmed = query.trim();
|
|
229
285
|
const named = namedListing(trimmed);
|
|
230
286
|
if (named) {
|
|
@@ -252,8 +308,9 @@ export async function searchPerpetualMarkets(query: string, client: PerpsClient
|
|
|
252
308
|
keep: (row: PerpBoardRow) => row.assetClass === assetClass && row.baseAsset.toUpperCase() === symbol,
|
|
253
309
|
})),
|
|
254
310
|
];
|
|
311
|
+
const boardClient = searchBoardClient(client, cache);
|
|
255
312
|
const boards = await Promise.all(searches.map(async ({ search, keep }) => {
|
|
256
|
-
const board = await
|
|
313
|
+
const board = await boardClient.getCloudPerpsBoard({ search });
|
|
257
314
|
return (Array.isArray(board?.rows) ? board.rows : []).filter((row) => !row.delisted && keep(row));
|
|
258
315
|
}));
|
|
259
316
|
const seen = new Set<string>();
|
|
@@ -148,35 +148,42 @@ function isQuoteInActiveSession(quote: Quote, now: number): boolean {
|
|
|
148
148
|
const OPENING_AUCTION_MS = 15 * 60_000;
|
|
149
149
|
|
|
150
150
|
/**
|
|
151
|
-
* Whether Gloom Cloud vouches that a
|
|
152
|
-
*
|
|
153
|
-
*
|
|
154
|
-
*
|
|
155
|
-
*
|
|
151
|
+
* Whether Gloom Cloud vouches that a quote is current, however long ago its
|
|
152
|
+
* last trade was. The service judges more than that trade's age: it knows
|
|
153
|
+
* when it asked for the quote and how often the listing trades, so a thinly
|
|
154
|
+
* traded listing's hour-old trade can be the current price while its venue
|
|
155
|
+
* trades. Its verdict stands in for the age bound when:
|
|
156
156
|
* - the service answered on this request, or a cache entry still inside its
|
|
157
157
|
* TTL holds that answer (`recentAnswer`); a copy past the TTL is not vouched for;
|
|
158
158
|
* - the answer says `stale: false`. One without the flag vouches for nothing,
|
|
159
159
|
* and one flagged stale never gets this far;
|
|
160
|
-
* - the quote is delayed. The service bounds a delayed quote's feed age itself
|
|
161
|
-
* but not a real-time one's, so real-time quotes keep the age bound;
|
|
162
|
-
* - it reports the regular session, the venue's session is in progress as
|
|
163
|
-
* the delayed feed shows it, and the trade belongs to that session; a
|
|
164
|
-
* currency pair's session is the service's to judge; or
|
|
165
160
|
* - it reports a US extended-hours session and the trade is no older than
|
|
166
161
|
* the regular session that session extends: after the close, today's
|
|
167
162
|
* regular session or its after-hours; before the open, the previous
|
|
168
163
|
* regular session or anything since. Whether the quote carries the
|
|
169
|
-
* session's price is the freshness rule's call, made before this one.
|
|
164
|
+
* session's price is the freshness rule's call, made before this one. The
|
|
165
|
+
* service bounds an extended-hours print's age itself, real-time or
|
|
166
|
+
* delayed: past half an hour it asks the source again and keeps the print
|
|
167
|
+
* only when the source shows nothing has traded since. GS after hours on
|
|
168
|
+
* 16 Nov 2026 went more than ten minutes between trades, and its real-time
|
|
169
|
+
* quote was dropped as stuck, so the put screen had no price for it; or
|
|
170
|
+
* - the quote is delayed, it reports the regular session, the venue's
|
|
171
|
+
* session is in progress as the delayed feed shows it, and the trade
|
|
172
|
+
* belongs to that session; a currency pair's session is the service's to
|
|
173
|
+
* judge. The service bounds a delayed quote's feed age in the regular
|
|
174
|
+
* session but not a real-time one's, so there real-time quotes keep the
|
|
175
|
+
* age bound.
|
|
170
176
|
* The answer says nothing about how often a listing trades, so a liquid
|
|
171
177
|
* listing the service wrongly vouches for is accepted too. The service's own
|
|
172
178
|
* bound for liquid listings, about twenty minutes, is tighter than this one.
|
|
173
179
|
*/
|
|
174
180
|
function isVouchedCurrentByService(quote: Quote, exchange: string | undefined, now: number): boolean {
|
|
175
|
-
if (quote.providerId !== "gloomberb-cloud" || quote.stale !== false
|
|
181
|
+
if (quote.providerId !== "gloomberb-cloud" || quote.stale !== false) return false;
|
|
182
|
+
if (quote.dataSource !== "live" && quote.dataSource !== "delayed") return false;
|
|
176
183
|
if (quote.marketState === "PRE" || quote.marketState === "POST") {
|
|
177
184
|
return isUsExtendedHoursSessionPrint(quote.lastUpdated, exchange, quote.marketState, now);
|
|
178
185
|
}
|
|
179
|
-
if (quote.marketState !== "REGULAR") return false;
|
|
186
|
+
if (quote.dataSource !== "delayed" || quote.marketState !== "REGULAR") return false;
|
|
180
187
|
// A currency pair trades around the clock through the week, and the service
|
|
181
188
|
// measures its silence against how often that pair prints: a pegged or
|
|
182
189
|
// exotic pair such as SAR=X goes hours without a print while its feed is fine.
|
|
@@ -409,6 +409,10 @@ export class AssetDataRouter implements DataProvider {
|
|
|
409
409
|
return this.searchRoutes.searchBatch(queries, options);
|
|
410
410
|
}
|
|
411
411
|
|
|
412
|
+
knownUsStock(symbol: string): boolean {
|
|
413
|
+
return this.providersInPriorityOrder().some((provider) => provider.knownUsStock?.(symbol) === true);
|
|
414
|
+
}
|
|
415
|
+
|
|
412
416
|
/** The first source that answers a batch of symbol changes; null when none can or it fails. */
|
|
413
417
|
async getTickerChangesBatch(symbols: string[], options?: { signal?: AbortSignal }): Promise<Map<string, TickerChanges | null> | null> {
|
|
414
418
|
const provider = this.providersInPriorityOrder().find((candidate) => candidate.getTickerChangesBatch);
|
|
@@ -24,7 +24,7 @@ import {
|
|
|
24
24
|
} from "./analytics-payload";
|
|
25
25
|
import { idEntries } from "./broker-instances";
|
|
26
26
|
import { CORE_CONFIG_CONTRIBUTOR_ID, log } from "./config-contributor";
|
|
27
|
-
import { sanitizePortfolio, sanitizeWatchlist, WATCHLISTS_CARRY_GROUPS } from "./sanitize";
|
|
27
|
+
import { PORTFOLIOS_CARRY_OTHER_CASH, sanitizePortfolio, sanitizeWatchlist, WATCHLISTS_CARRY_GROUPS } from "./sanitize";
|
|
28
28
|
import {
|
|
29
29
|
lastSyncedTickersById,
|
|
30
30
|
latestBrokerPortfolioSyncs,
|
|
@@ -55,6 +55,8 @@ export function collectCoreCollectionsPayload(
|
|
|
55
55
|
baseCurrency: config.baseCurrency,
|
|
56
56
|
exchangeRates: { USD: 1 },
|
|
57
57
|
portfolios: config.portfolios.map(sanitizePortfolio),
|
|
58
|
+
// The portfolios carry their cash in other currencies, as the config payload's do.
|
|
59
|
+
[PORTFOLIOS_CARRY_OTHER_CASH]: true,
|
|
58
60
|
watchlists: config.watchlists.map(sanitizeWatchlist),
|
|
59
61
|
// The lists carry their groups, as the config payload's do: a reader can tell a list without them from an older build's.
|
|
60
62
|
[WATCHLISTS_CARRY_GROUPS]: true,
|
package/src/sync/config-merge.ts
CHANGED
|
@@ -29,11 +29,13 @@ import {
|
|
|
29
29
|
type LayoutMergeContext,
|
|
30
30
|
} from "./layout-merge";
|
|
31
31
|
import {
|
|
32
|
+
PORTFOLIOS_CARRY_OTHER_CASH,
|
|
32
33
|
sanitizeBrokerInstance,
|
|
33
34
|
sanitizePortfolio,
|
|
34
35
|
sanitizeUnknown,
|
|
35
36
|
sanitizeWatchlist,
|
|
36
37
|
WATCHLISTS_CARRY_GROUPS,
|
|
38
|
+
withLocalOtherCash,
|
|
37
39
|
withLocalPluginSecrets,
|
|
38
40
|
withLocalWatchlistGroups,
|
|
39
41
|
} from "./sanitize";
|
|
@@ -44,6 +46,8 @@ export function collectCoreConfigPayload(config: AppConfig) {
|
|
|
44
46
|
baseCurrency: config.baseCurrency,
|
|
45
47
|
refreshIntervalMinutes: config.refreshIntervalMinutes,
|
|
46
48
|
portfolios: config.portfolios.map(sanitizePortfolio),
|
|
49
|
+
// The portfolios carry their cash in other currencies: one without it holds no more.
|
|
50
|
+
[PORTFOLIOS_CARRY_OTHER_CASH]: true,
|
|
47
51
|
watchlists: config.watchlists.map(sanitizeWatchlist),
|
|
48
52
|
[WATCHLISTS_CARRY_GROUPS]: true,
|
|
49
53
|
...collectLayoutPayload(config),
|
|
@@ -166,10 +170,15 @@ export function mergeConfigPayload(
|
|
|
166
170
|
payload.brokerInstancesMergedById === true,
|
|
167
171
|
);
|
|
168
172
|
}
|
|
173
|
+
// An older build pushes its portfolios without their cash in other currencies: they keep what they hold here.
|
|
169
174
|
if ("portfolios" in payload && canApply("portfolios")) {
|
|
170
175
|
const syncedPortfolios = payload.portfolios;
|
|
171
176
|
next.portfolios = Array.isArray(syncedPortfolios)
|
|
172
|
-
? mergeLocalBrokerPortfolioIdentity(
|
|
177
|
+
? mergeLocalBrokerPortfolioIdentity(
|
|
178
|
+
config.portfolios,
|
|
179
|
+
withLocalOtherCash(syncedPortfolios, config.portfolios, payload[PORTFOLIOS_CARRY_OTHER_CASH] === true),
|
|
180
|
+
next.brokerInstances,
|
|
181
|
+
)
|
|
173
182
|
: syncedPortfolios as AppConfig["portfolios"];
|
|
174
183
|
}
|
|
175
184
|
// An older build pushes its lists without their groups: they keep the groups they have here.
|
package/src/sync/sanitize.ts
CHANGED
|
@@ -2,6 +2,7 @@ import type { AppConfig, BrokerInstanceConfig } from "../types/config";
|
|
|
2
2
|
import type { Portfolio, TickerPosition, Watchlist } from "../types/ticker";
|
|
3
3
|
import { isRecord } from "../utils/guards";
|
|
4
4
|
import { normalizeWatchlistGroups } from "../portfolio/watchlist-groups";
|
|
5
|
+
import { portfolioCashBalances, withKeptOtherCash } from "../portfolio/cash-balances";
|
|
5
6
|
|
|
6
7
|
const SENSITIVE_KEY_PATTERN = /(token|secret|password|credential|private|api[_-]?key|access[_-]?key|refresh[_-]?key|session|cookie|dataDir|path|directory|localPath)/i;
|
|
7
8
|
|
|
@@ -57,6 +58,7 @@ export function withLocalPluginSecrets(
|
|
|
57
58
|
}
|
|
58
59
|
|
|
59
60
|
export function sanitizePortfolio(portfolio: Portfolio): Portfolio {
|
|
61
|
+
const [cash, ...otherCash] = portfolioCashBalances(portfolio);
|
|
60
62
|
return {
|
|
61
63
|
id: portfolio.id,
|
|
62
64
|
name: portfolio.name,
|
|
@@ -66,8 +68,10 @@ export function sanitizePortfolio(portfolio: Portfolio): Portfolio {
|
|
|
66
68
|
brokerId: portfolio.brokerId,
|
|
67
69
|
lastSyncedAt: portfolio.lastSyncedAt,
|
|
68
70
|
// Cash and targets are the user's own entries: a pulled portfolio without
|
|
69
|
-
// them would erase them on this device.
|
|
70
|
-
|
|
71
|
+
// them would erase them on this device. `cash` is the first balance, as an
|
|
72
|
+
// older build reads it, and `otherCash` the other currencies'.
|
|
73
|
+
...(cash ? { cash } : {}),
|
|
74
|
+
...(otherCash.length > 0 ? { otherCash } : {}),
|
|
71
75
|
...(portfolio.targetWeights ? { targetWeights: { ...portfolio.targetWeights } } : {}),
|
|
72
76
|
...(portfolio.importedFrom ? {
|
|
73
77
|
importedFrom: {
|
|
@@ -78,6 +82,26 @@ export function sanitizePortfolio(portfolio: Portfolio): Portfolio {
|
|
|
78
82
|
};
|
|
79
83
|
}
|
|
80
84
|
|
|
85
|
+
/**
|
|
86
|
+
* Set on every payload this build pushes with portfolios: they carry their
|
|
87
|
+
* cash in other currencies (`otherCash`), so one without it holds cash in one
|
|
88
|
+
* currency at most. An older build strips `otherCash` from every push, and
|
|
89
|
+
* its portfolios taken as they came would erase those balances here and then
|
|
90
|
+
* everywhere this device pushes to.
|
|
91
|
+
*/
|
|
92
|
+
export const PORTFOLIOS_CARRY_OTHER_CASH = "portfoliosCarryOtherCash";
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Pulled portfolios, each one an older build pushed (no
|
|
96
|
+
* `PORTFOLIOS_CARRY_OTHER_CASH`) keeping the other currencies' cash it holds
|
|
97
|
+
* here (`withKeptOtherCash`); a build that sends them is taken as it came, so
|
|
98
|
+
* a balance cleared there is cleared here.
|
|
99
|
+
*/
|
|
100
|
+
export function withLocalOtherCash(pulled: unknown[], local: readonly Portfolio[], carriesOtherCash: boolean): Portfolio[] {
|
|
101
|
+
if (carriesOtherCash) return pulled as Portfolio[];
|
|
102
|
+
return pulled.map((entry) => withKeptOtherCash(entry, isRecord(entry) ? local.find((portfolio) => portfolio.id === entry.id) : null) as Portfolio);
|
|
103
|
+
}
|
|
104
|
+
|
|
81
105
|
/**
|
|
82
106
|
* Set on every payload this build pushes with watchlists: its lists carry their
|
|
83
107
|
* groups, so one without `groups` has none. An older build's lists never carry
|
|
@@ -95,6 +95,18 @@ function homeLineQuery(typed: string): string | null {
|
|
|
95
95
|
return words.length >= 3 ? words.slice(1).join(" ") : null;
|
|
96
96
|
}
|
|
97
97
|
|
|
98
|
+
/** A word written as a ticker: capitals and digits, short, with a class or venue mark after a dot, dash, slash or colon. */
|
|
99
|
+
const TICKER_WORD = /^\$?[A-Z0-9]{1,6}(?:[.\-/:][A-Z0-9]{1,6})*$/;
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Whether every word of a line is written as a ticker (`V MCO CPRT`, `0700 0005`), as a company's name, which has
|
|
103
|
+
* words longer than a ticker or in lower case (`Turk Hava Yollari`, `TURK HAVA YOLLARI`), is not.
|
|
104
|
+
*/
|
|
105
|
+
function wordsAreTickers(typed: string): boolean {
|
|
106
|
+
const words = typed.trim().split(/\s+/).filter(Boolean);
|
|
107
|
+
return words.length > 0 && words.every((word) => TICKER_WORD.test(word));
|
|
108
|
+
}
|
|
109
|
+
|
|
98
110
|
/** A list entry with a space inside is a company's name, never a symbol: "Whirlpool Corporation". */
|
|
99
111
|
export function isCompanyNameInput(input: string): boolean {
|
|
100
112
|
return /\S\s+\S/.test(input.trim());
|
|
@@ -150,9 +162,11 @@ export async function findListingOfCompanyName(
|
|
|
150
162
|
let results = answers.flatMap((answer) => Array.isArray(answer) ? answer : []);
|
|
151
163
|
let listed = rankCompanyLines(name, results, options);
|
|
152
164
|
// A company the answers list only abroad or by receipts (Türk Hava Yolları on Frankfurt and OTC) is searched again
|
|
153
|
-
// under its later words, which can list its home line: THYAO in Istanbul.
|
|
165
|
+
// under its later words, which can list its home line: THYAO in Istanbul. A line of tickers (`V MCO CPRT`) that
|
|
166
|
+
// search found nothing for names no company, abroad or at home, so a shorter line would find nothing either.
|
|
154
167
|
const lead = listed.find((listing) => listing.namesCompany);
|
|
155
|
-
const
|
|
168
|
+
const tickersOnly = results.length === 0 && wordsAreTickers(name);
|
|
169
|
+
const again = !options.oneWord && !tickersOnly && (!lead || (!lead.home && lead.rank[3]! > 1)) ? homeLineQuery(name) : null;
|
|
156
170
|
if (again && !queries.includes(again)) {
|
|
157
171
|
const more = await searchListings(dataProvider, again);
|
|
158
172
|
if (Array.isArray(more) && more.length) {
|