@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,20 +1,60 @@
|
|
|
1
1
|
import { logFailure } from "../utils/log-failure";
|
|
2
2
|
import type { TickerRecord, TickerMetadata } from "../types/ticker";
|
|
3
|
-
import type { TickerStore } from "./ticker-store";
|
|
3
|
+
import type { ResolvedTickerRow, TickerStore } from "./ticker-store";
|
|
4
4
|
import { hydrateTickerMetadata } from "../tickers/metadata";
|
|
5
|
-
import { runTickerWrite } from "./ticker-writes";
|
|
5
|
+
import { hasPendingTickerWrite, runTickerWrite } from "./ticker-writes";
|
|
6
|
+
import { serializeJson } from "./sqlite/json";
|
|
7
|
+
import { applyProfileEdits, diffProfile, type ProfileJson } from "./profile-merge";
|
|
6
8
|
|
|
7
9
|
function parseTickerMetadata(json: string): TickerMetadata {
|
|
8
10
|
return hydrateTickerMetadata(JSON.parse(json) as Record<string, unknown>);
|
|
9
11
|
}
|
|
10
12
|
|
|
13
|
+
/**
|
|
14
|
+
* Ticker rows are shared like config.json: a `gloom watchlist add` or
|
|
15
|
+
* `portfolio position set` run beside the app writes the row the app holds a
|
|
16
|
+
* copy of, and another copy of the app (the desktop app beside the terminal
|
|
17
|
+
* one) can delete a row in its cleanup. Each row's copy is kept as it was read
|
|
18
|
+
* or last saved here. A save over a row another program changed since keeps
|
|
19
|
+
* that program's change and adds this one's (see `profile-merge.ts`); a save
|
|
20
|
+
* over a row another program deleted since leaves it deleted, as a removal
|
|
21
|
+
* always lands. Which of those it is gets decided in the write's own
|
|
22
|
+
* transaction, when it lands (`TickerStore.saveResolved`).
|
|
23
|
+
*/
|
|
11
24
|
export class TickerRepository {
|
|
25
|
+
/**
|
|
26
|
+
* Each row as this program's copy of it was read or last saved, by symbol:
|
|
27
|
+
* what the next save of it is compared with. Only a write that landed moves
|
|
28
|
+
* it, never one still queued or dropped for a later write of the same row.
|
|
29
|
+
*/
|
|
30
|
+
private readonly copies = new Map<string, string>();
|
|
31
|
+
/**
|
|
32
|
+
* Rows this program holds a copy of that a read of every row found gone:
|
|
33
|
+
* another program deleted them. Their copies stay, so a save of the app's
|
|
34
|
+
* copy still leaves them deleted, until the app has dropped them from what
|
|
35
|
+
* it shows (`takeRowsDeletedElsewhere`) and lets them go.
|
|
36
|
+
*/
|
|
37
|
+
private readonly goneElsewhere = new Set<string>();
|
|
38
|
+
|
|
12
39
|
constructor(private readonly tickers: TickerStore) {}
|
|
13
40
|
|
|
41
|
+
/** Changes when another program commits to the database (see `TickerStore.changesElsewhere`). */
|
|
42
|
+
changesElsewhere(): number | null {
|
|
43
|
+
return this.tickers.changesElsewhere();
|
|
44
|
+
}
|
|
45
|
+
|
|
14
46
|
async loadAllTickers(): Promise<TickerRecord[]> {
|
|
15
|
-
|
|
47
|
+
const rows = this.tickers.getAll();
|
|
48
|
+
// A row this program holds a copy of that is gone was deleted elsewhere, whoever wrote it last.
|
|
49
|
+
const present = new Set(rows.map((row) => row.symbol));
|
|
50
|
+
for (const symbol of this.copies.keys()) {
|
|
51
|
+
if (!present.has(symbol) && !this.writing(symbol)) this.goneElsewhere.add(symbol);
|
|
52
|
+
}
|
|
53
|
+
return rows.flatMap((row) => {
|
|
16
54
|
try {
|
|
17
|
-
|
|
55
|
+
const record = { metadata: parseTickerMetadata(row.metadata) };
|
|
56
|
+
this.noteRead(row.symbol, row.metadata);
|
|
57
|
+
return [record];
|
|
18
58
|
} catch (error) {
|
|
19
59
|
logFailure("data.ticker-repository", "Reading stored ticker metadata failed")(error);
|
|
20
60
|
return [];
|
|
@@ -24,9 +64,14 @@ export class TickerRepository {
|
|
|
24
64
|
|
|
25
65
|
async loadTicker(symbol: string): Promise<TickerRecord | null> {
|
|
26
66
|
const json = this.tickers.get(symbol);
|
|
27
|
-
if (!json)
|
|
67
|
+
if (!json) {
|
|
68
|
+
this.noteRead(symbol, null);
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
28
71
|
try {
|
|
29
|
-
|
|
72
|
+
const record = { metadata: parseTickerMetadata(json) };
|
|
73
|
+
this.noteRead(symbol, json);
|
|
74
|
+
return record;
|
|
30
75
|
} catch (error) {
|
|
31
76
|
logFailure("data.ticker-repository", "Reading stored ticker metadata failed")(error);
|
|
32
77
|
return null;
|
|
@@ -35,26 +80,105 @@ export class TickerRepository {
|
|
|
35
80
|
|
|
36
81
|
saveTicker(ticker: TickerRecord): Promise<void> {
|
|
37
82
|
return runTickerWrite(this, ticker.metadata.ticker, () => {
|
|
38
|
-
this.tickers.
|
|
83
|
+
this.tickers.saveResolved([this.rowToSave(ticker.metadata)]);
|
|
39
84
|
});
|
|
40
85
|
}
|
|
41
86
|
|
|
42
87
|
/** Saves several tickers in one write. */
|
|
43
88
|
saveTickers(tickers: readonly TickerRecord[]): Promise<void> {
|
|
44
89
|
return runTickerWrite(this, tickers.map((ticker) => ticker.metadata.ticker), () => {
|
|
45
|
-
this.tickers.
|
|
90
|
+
this.tickers.saveResolved(tickers.map((ticker) => this.rowToSave(ticker.metadata)));
|
|
46
91
|
});
|
|
47
92
|
}
|
|
48
93
|
|
|
49
94
|
createTicker(metadata: TickerMetadata): Promise<TickerRecord> {
|
|
50
95
|
const ticker: TickerRecord = { metadata };
|
|
51
96
|
return runTickerWrite(this, metadata.ticker, () => {
|
|
52
|
-
this.tickers.
|
|
97
|
+
this.tickers.saveResolved([this.rowToSave(metadata)]);
|
|
53
98
|
return ticker;
|
|
54
99
|
});
|
|
55
100
|
}
|
|
56
101
|
|
|
57
102
|
deleteTicker(symbol: string): Promise<void> {
|
|
58
|
-
return runTickerWrite(this, symbol, () =>
|
|
103
|
+
return runTickerWrite(this, symbol, () => {
|
|
104
|
+
this.tickers.delete(symbol);
|
|
105
|
+
this.copies.delete(symbol);
|
|
106
|
+
this.goneElsewhere.delete(symbol);
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* The rows another program deleted that this program held, as reads of
|
|
112
|
+
* every row found them gone since the last call, for the app to drop from
|
|
113
|
+
* what it shows; their copies go with them, so a ticker added again after
|
|
114
|
+
* is a new row. A row with a save of it on its way is kept for a later
|
|
115
|
+
* call: that save is still compared with its copy.
|
|
116
|
+
*/
|
|
117
|
+
takeRowsDeletedElsewhere(): string[] {
|
|
118
|
+
const taken = [...this.goneElsewhere].filter((symbol) => !this.writing(symbol));
|
|
119
|
+
for (const symbol of taken) {
|
|
120
|
+
this.goneElsewhere.delete(symbol);
|
|
121
|
+
this.copies.delete(symbol);
|
|
122
|
+
}
|
|
123
|
+
return taken;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/** Whether a save of `symbol` is on its way, or waits behind another program's lock. */
|
|
127
|
+
private writing(symbol: string): boolean {
|
|
128
|
+
return hasPendingTickerWrite(this, symbol) || this.tickers.isQueued(symbol);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* A row read is what this program's copy of it is built on from now (null:
|
|
133
|
+
* there is none, so the next save writes a new row), but not while a save
|
|
134
|
+
* of the row is on its way or waits behind another program's lock: that
|
|
135
|
+
* save was built on the copy before, and is compared with that one, and
|
|
136
|
+
* what the read sees of the row is that save's own.
|
|
137
|
+
*/
|
|
138
|
+
private noteRead(symbol: string, metadata: string | null): void {
|
|
139
|
+
if (this.writing(symbol)) return;
|
|
140
|
+
this.goneElsewhere.delete(symbol);
|
|
141
|
+
if (metadata === null) this.copies.delete(symbol);
|
|
142
|
+
else this.copies.set(symbol, metadata);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* `metadata`, this program's copy, as a row the store resolves when the
|
|
147
|
+
* write lands, against the copy it was built on (`copies`, as it stands
|
|
148
|
+
* then):
|
|
149
|
+
* - no copy: a row this program has not read, written as it is;
|
|
150
|
+
* - the stored row is gone: another program deleted it since, and it stays
|
|
151
|
+
* deleted until the app has dropped it (`takeRowsDeletedElsewhere`) or
|
|
152
|
+
* reads that one row anew (`loadTicker`);
|
|
153
|
+
* - the stored row is the copy, or this very row: written as it is;
|
|
154
|
+
* - otherwise another program changed it, and that change is folded in.
|
|
155
|
+
* Once written, the copy is what this program built, so a later save of a
|
|
156
|
+
* copy that never read the change folds it in again.
|
|
157
|
+
*/
|
|
158
|
+
private rowToSave(metadata: TickerMetadata): ResolvedTickerRow {
|
|
159
|
+
const symbol = metadata.ticker;
|
|
160
|
+
const mine = serializeJson(metadata);
|
|
161
|
+
return {
|
|
162
|
+
symbol,
|
|
163
|
+
preview: metadata,
|
|
164
|
+
resolve: (stored) => {
|
|
165
|
+
const base = this.copies.get(symbol);
|
|
166
|
+
if (base === undefined) return metadata;
|
|
167
|
+
if (stored === null) return null;
|
|
168
|
+
if (stored === base || stored === mine) return metadata;
|
|
169
|
+
try {
|
|
170
|
+
const edits = diffProfile(JSON.parse(base) as ProfileJson, JSON.parse(stored) as ProfileJson);
|
|
171
|
+
return applyProfileEdits(JSON.parse(mine) as ProfileJson, edits);
|
|
172
|
+
} catch (error) {
|
|
173
|
+
logFailure("data.ticker-repository", "Reading a ticker row another program changed failed")(error);
|
|
174
|
+
return metadata;
|
|
175
|
+
}
|
|
176
|
+
},
|
|
177
|
+
landed: (written) => {
|
|
178
|
+
if (written === null) return;
|
|
179
|
+
this.copies.set(symbol, mine);
|
|
180
|
+
this.goneElsewhere.delete(symbol);
|
|
181
|
+
},
|
|
182
|
+
};
|
|
59
183
|
}
|
|
60
184
|
}
|
package/src/data/ticker-store.ts
CHANGED
|
@@ -12,6 +12,21 @@ interface PendingTicker {
|
|
|
12
12
|
metadata: string | null;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
+
/**
|
|
16
|
+
* A row to save that was built on an earlier copy of it, so what it writes is
|
|
17
|
+
* only known once the write lands: `resolve` gets the row as stored at that
|
|
18
|
+
* moment (null when there is none) and returns what to write, or null to
|
|
19
|
+
* leave the row as it is. It can run more than once (a write the lock held up
|
|
20
|
+
* runs again), so it has no effects of its own; `landed` hears what was
|
|
21
|
+
* written, null for nothing. `preview` is what reads see while it waits.
|
|
22
|
+
*/
|
|
23
|
+
export interface ResolvedTickerRow {
|
|
24
|
+
symbol: string;
|
|
25
|
+
preview: unknown;
|
|
26
|
+
resolve: (stored: string | null) => unknown;
|
|
27
|
+
landed?: (written: string | null) => void;
|
|
28
|
+
}
|
|
29
|
+
|
|
15
30
|
export class TickerStore {
|
|
16
31
|
/** Writes queued behind another program's lock, by symbol, read back until they land. */
|
|
17
32
|
private readonly pending = new Map<string, PendingTicker>();
|
|
@@ -38,6 +53,27 @@ export class TickerStore {
|
|
|
38
53
|
return [...bySymbol.values()].sort((a, b) => (a.symbol < b.symbol ? -1 : a.symbol > b.symbol ? 1 : 0));
|
|
39
54
|
}
|
|
40
55
|
|
|
56
|
+
/**
|
|
57
|
+
* A number that changes when another program (a `gloom` command) commits
|
|
58
|
+
* to the database, and only then: SQLite's `data_version`. Null when the
|
|
59
|
+
* database cannot be read just now.
|
|
60
|
+
*/
|
|
61
|
+
changesElsewhere(): number | null {
|
|
62
|
+
try {
|
|
63
|
+
return this.access.run("read data version", () => (
|
|
64
|
+
this.db.query<{ data_version: number }, []>("PRAGMA data_version").get()?.data_version ?? null
|
|
65
|
+
));
|
|
66
|
+
} catch {
|
|
67
|
+
// Intentional ignore: an unreadable database is asked again on the next look.
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/** Whether a write of `symbol` waits behind another program's lock: reads see it, the database does not yet. */
|
|
73
|
+
isQueued(symbol: string): boolean {
|
|
74
|
+
return this.pending.has(symbol);
|
|
75
|
+
}
|
|
76
|
+
|
|
41
77
|
get(symbol: string): string | null {
|
|
42
78
|
const pending = this.pending.get(symbol);
|
|
43
79
|
if (pending) return pending.metadata;
|
|
@@ -75,6 +111,37 @@ export class TickerStore {
|
|
|
75
111
|
);
|
|
76
112
|
}
|
|
77
113
|
|
|
114
|
+
/**
|
|
115
|
+
* Saves rows whose content depends on the row stored when the write lands
|
|
116
|
+
* (`ResolvedTickerRow`): each is read, resolved and written in one
|
|
117
|
+
* immediate transaction, so another program's commit can never fall between
|
|
118
|
+
* the read and the write, whether the write lands now or later, behind
|
|
119
|
+
* another program's lock.
|
|
120
|
+
*/
|
|
121
|
+
saveResolved(rows: readonly ResolvedTickerRow[]): void {
|
|
122
|
+
if (rows.length === 0) return;
|
|
123
|
+
this.write(
|
|
124
|
+
rows.length === 1 ? "save ticker" : "save tickers",
|
|
125
|
+
rows.map((row) => [row.symbol, { metadata: serializeJson(row.preview) }]),
|
|
126
|
+
() => {
|
|
127
|
+
const read = this.db.query<{ metadata: string }, [string]>("SELECT metadata FROM tickers WHERE symbol = ?");
|
|
128
|
+
const insert = this.db.query(
|
|
129
|
+
`INSERT OR REPLACE INTO tickers (symbol, metadata, updated_at)
|
|
130
|
+
VALUES (?, ?, ?)`,
|
|
131
|
+
);
|
|
132
|
+
const now = Date.now();
|
|
133
|
+
const written = this.db.transaction(() => rows.map((row) => {
|
|
134
|
+
const next = row.resolve(read.get(row.symbol)?.metadata ?? null);
|
|
135
|
+
if (next == null) return null;
|
|
136
|
+
const metadata = serializeJson(next);
|
|
137
|
+
insert.run(row.symbol, metadata, now);
|
|
138
|
+
return metadata;
|
|
139
|
+
})).immediate();
|
|
140
|
+
rows.forEach((row, index) => row.landed?.(written[index] ?? null));
|
|
141
|
+
},
|
|
142
|
+
);
|
|
143
|
+
}
|
|
144
|
+
|
|
78
145
|
delete(symbol: string): void {
|
|
79
146
|
this.write("delete ticker", [[symbol, { metadata: null }]], () => {
|
|
80
147
|
this.db.query("DELETE FROM tickers WHERE symbol = ?").run(symbol);
|
|
@@ -71,6 +71,11 @@ export function hasPendingTickerWrites(repository: object): boolean {
|
|
|
71
71
|
return (repositories.get(repository)?.pending.size ?? 0) > 0;
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
+
/** Whether a write of `symbol` is requested and not yet done. */
|
|
75
|
+
export function hasPendingTickerWrite(repository: object, symbol: string): boolean {
|
|
76
|
+
return repositories.get(repository)?.tails.has(tickerKey(symbol)) ?? false;
|
|
77
|
+
}
|
|
78
|
+
|
|
74
79
|
/** Let save-await callers publish their edits before cleanup reads the current rows. */
|
|
75
80
|
export async function settleTickerWrites(repository: object): Promise<void> {
|
|
76
81
|
const writes = writesFor(repository);
|
package/src/i18n/es.ts
CHANGED
|
@@ -1615,6 +1615,12 @@ export const es: Record<string, string> = {
|
|
|
1615
1615
|
"TICKERS": "TICKERS",
|
|
1616
1616
|
"Which tickers do you follow?": "¿Qué tickers sigues?",
|
|
1617
1617
|
"Pick up to 3 for your watchlist.": "Elige hasta 3 para tu lista de seguimiento.",
|
|
1618
|
+
// "Where did you hear about Gloom?", once, after an account signs up
|
|
1619
|
+
"Where did you hear about Gloom?": "¿Dónde conociste Gloom?",
|
|
1620
|
+
"AI assistant": "Asistente de IA",
|
|
1621
|
+
"Friend or colleague": "Un amigo o colega",
|
|
1622
|
+
"Article or newsletter": "Un artículo o newsletter",
|
|
1623
|
+
"Where?": "¿Dónde?",
|
|
1618
1624
|
"Skip": "Omitir",
|
|
1619
1625
|
"Equities": "Renta variable",
|
|
1620
1626
|
"Futures & commodities": "Futuros y materias primas",
|
|
@@ -1825,4 +1831,25 @@ export const es: Record<string, string> = {
|
|
|
1825
1831
|
"pre": "pre",
|
|
1826
1832
|
"post": "post",
|
|
1827
1833
|
"closed": "cerrado",
|
|
1834
|
+
// ── Pro: the first weeks' row and the paid cancel ──────────
|
|
1835
|
+
"Try Pro on your tickers": "Prueba Pro con tus tickers",
|
|
1836
|
+
"Try Pro": "Prueba Pro",
|
|
1837
|
+
"Stop suggesting Pro functions": "Dejar de sugerir funciones Pro",
|
|
1838
|
+
"Open {command}": "Abrir {command}",
|
|
1839
|
+
"Options flow": "Flujo de opciones",
|
|
1840
|
+
"X mentions": "Menciones en X",
|
|
1841
|
+
"Hiring": "Contratación",
|
|
1842
|
+
"8-K events": "Eventos 8-K",
|
|
1843
|
+
"Risk factors": "Factores de riesgo",
|
|
1844
|
+
"Cancel Pro": "Cancelar Pro",
|
|
1845
|
+
"Cancel Pro?": "¿Cancelar Pro?",
|
|
1846
|
+
"Keep Pro": "Mantener Pro",
|
|
1847
|
+
"Pro until {date}": "Pro hasta el {date}",
|
|
1848
|
+
"Cancelling...": "Cancelando...",
|
|
1849
|
+
"Cancel Subscription": "Cancelar suscripción",
|
|
1850
|
+
"Keep My Subscription": "Mantener mi suscripción",
|
|
1851
|
+
"Continue Cancellation": "Continuar con la cancelación",
|
|
1852
|
+
"Pro stays on until {date}.": "Pro sigue activo hasta el {date}.",
|
|
1853
|
+
"Pro stays on until {date}. Cancelling now stops the renewal after that date.": "Pro sigue activo hasta el {date}. Si cancelas ahora, no se renovará después de esa fecha.",
|
|
1854
|
+
"Cancelled. Pro stays on until {date}.": "Cancelado. Pro sigue activo hasta el {date}.",
|
|
1828
1855
|
};
|
package/src/i18n/ja.ts
CHANGED
|
@@ -1612,6 +1612,12 @@ export const ja: Record<string, string> = {
|
|
|
1612
1612
|
"TICKERS": "銘柄",
|
|
1613
1613
|
"Which tickers do you follow?": "どの銘柄をフォローしていますか?",
|
|
1614
1614
|
"Pick up to 3 for your watchlist.": "ウォッチリストに入れる銘柄を最大3つ選べます。",
|
|
1615
|
+
// "Where did you hear about Gloom?", once, after an account signs up
|
|
1616
|
+
"Where did you hear about Gloom?": "Gloom をどこで知りましたか?",
|
|
1617
|
+
"AI assistant": "AI アシスタント",
|
|
1618
|
+
"Friend or colleague": "友人・同僚",
|
|
1619
|
+
"Article or newsletter": "記事・ニュースレター",
|
|
1620
|
+
"Where?": "どこで?",
|
|
1615
1621
|
"Skip": "スキップ",
|
|
1616
1622
|
"Equities": "株式",
|
|
1617
1623
|
"Futures & commodities": "先物・コモディティ",
|
|
@@ -1822,4 +1828,25 @@ export const ja: Record<string, string> = {
|
|
|
1822
1828
|
"pre": "開始前",
|
|
1823
1829
|
"post": "時間外",
|
|
1824
1830
|
"closed": "休場",
|
|
1831
|
+
// ── Pro: the first weeks' row and the paid cancel ──────────
|
|
1832
|
+
"Try Pro on your tickers": "あなたの銘柄で Pro を試す",
|
|
1833
|
+
"Try Pro": "Pro を試す",
|
|
1834
|
+
"Stop suggesting Pro functions": "Pro 機能の提案を表示しない",
|
|
1835
|
+
"Open {command}": "{command} を開く",
|
|
1836
|
+
"Options flow": "オプションフロー",
|
|
1837
|
+
"X mentions": "X での言及",
|
|
1838
|
+
"Hiring": "採用",
|
|
1839
|
+
"8-K events": "8-K イベント",
|
|
1840
|
+
"Risk factors": "リスク要因",
|
|
1841
|
+
"Cancel Pro": "Pro を解約",
|
|
1842
|
+
"Cancel Pro?": "Pro を解約しますか?",
|
|
1843
|
+
"Keep Pro": "Pro を続ける",
|
|
1844
|
+
"Pro until {date}": "Pro({date} まで)",
|
|
1845
|
+
"Cancelling...": "解約中...",
|
|
1846
|
+
"Cancel Subscription": "サブスクリプションを解約",
|
|
1847
|
+
"Keep My Subscription": "サブスクリプションを続ける",
|
|
1848
|
+
"Continue Cancellation": "解約を続ける",
|
|
1849
|
+
"Pro stays on until {date}.": "Pro は {date} までご利用いただけます。",
|
|
1850
|
+
"Pro stays on until {date}. Cancelling now stops the renewal after that date.": "Pro は {date} までご利用いただけます。今解約すると、その日以降は更新されません。",
|
|
1851
|
+
"Cancelled. Pro stays on until {date}.": "解約しました。Pro は {date} までご利用いただけます。",
|
|
1825
1852
|
};
|
package/src/i18n/ko.ts
CHANGED
|
@@ -1610,6 +1610,12 @@ export const ko: Record<string, string> = {
|
|
|
1610
1610
|
"TICKERS": "종목",
|
|
1611
1611
|
"Which tickers do you follow?": "어떤 종목을 팔로우하시나요?",
|
|
1612
1612
|
"Pick up to 3 for your watchlist.": "관심 목록에 넣을 종목을 최대 3개까지 고르세요.",
|
|
1613
|
+
// "Where did you hear about Gloom?", once, after an account signs up
|
|
1614
|
+
"Where did you hear about Gloom?": "Gloom을 어디서 알게 되셨나요?",
|
|
1615
|
+
"AI assistant": "AI 어시스턴트",
|
|
1616
|
+
"Friend or colleague": "친구 또는 동료",
|
|
1617
|
+
"Article or newsletter": "기사 또는 뉴스레터",
|
|
1618
|
+
"Where?": "어디서?",
|
|
1613
1619
|
"Skip": "건너뛰기",
|
|
1614
1620
|
"Equities": "주식",
|
|
1615
1621
|
"Futures & commodities": "선물 및 원자재",
|
|
@@ -1820,4 +1826,25 @@ export const ko: Record<string, string> = {
|
|
|
1820
1826
|
"pre": "장전",
|
|
1821
1827
|
"post": "장후",
|
|
1822
1828
|
"closed": "휴장",
|
|
1829
|
+
// ── Pro: the first weeks' row and the paid cancel ──────────
|
|
1830
|
+
"Try Pro on your tickers": "내 종목으로 Pro 써보기",
|
|
1831
|
+
"Try Pro": "Pro 써보기",
|
|
1832
|
+
"Stop suggesting Pro functions": "Pro 기능 추천 그만 보기",
|
|
1833
|
+
"Open {command}": "{command} 열기",
|
|
1834
|
+
"Options flow": "옵션 플로우",
|
|
1835
|
+
"X mentions": "X 언급",
|
|
1836
|
+
"Hiring": "채용",
|
|
1837
|
+
"8-K events": "8-K 이벤트",
|
|
1838
|
+
"Risk factors": "위험 요인",
|
|
1839
|
+
"Cancel Pro": "Pro 해지",
|
|
1840
|
+
"Cancel Pro?": "Pro를 해지할까요?",
|
|
1841
|
+
"Keep Pro": "Pro 유지",
|
|
1842
|
+
"Pro until {date}": "Pro ({date}까지)",
|
|
1843
|
+
"Cancelling...": "해지 중...",
|
|
1844
|
+
"Cancel Subscription": "구독 해지",
|
|
1845
|
+
"Keep My Subscription": "구독 유지",
|
|
1846
|
+
"Continue Cancellation": "계속 해지",
|
|
1847
|
+
"Pro stays on until {date}.": "Pro는 {date}까지 유지됩니다.",
|
|
1848
|
+
"Pro stays on until {date}. Cancelling now stops the renewal after that date.": "Pro는 {date}까지 유지됩니다. 지금 해지하면 그 날짜 이후 갱신되지 않습니다.",
|
|
1849
|
+
"Cancelled. Pro stays on until {date}.": "해지되었습니다. Pro는 {date}까지 유지됩니다.",
|
|
1823
1850
|
};
|
package/src/i18n/zh-cn.ts
CHANGED
|
@@ -1612,6 +1612,12 @@ export const zhCN: Record<string, string> = {
|
|
|
1612
1612
|
"TICKERS": "标的",
|
|
1613
1613
|
"Which tickers do you follow?": "你关注哪些标的?",
|
|
1614
1614
|
"Pick up to 3 for your watchlist.": "最多选 3 个加入自选列表。",
|
|
1615
|
+
// "Where did you hear about Gloom?", once, after an account signs up
|
|
1616
|
+
"Where did you hear about Gloom?": "你是从哪里知道 Gloom 的?",
|
|
1617
|
+
"AI assistant": "AI 助手",
|
|
1618
|
+
"Friend or colleague": "朋友或同事",
|
|
1619
|
+
"Article or newsletter": "文章或新闻通讯",
|
|
1620
|
+
"Where?": "在哪里?",
|
|
1615
1621
|
"Skip": "跳过",
|
|
1616
1622
|
"Equities": "股票",
|
|
1617
1623
|
"Futures & commodities": "期货与大宗商品",
|
|
@@ -1822,4 +1828,25 @@ export const zhCN: Record<string, string> = {
|
|
|
1822
1828
|
"pre": "盘前",
|
|
1823
1829
|
"post": "盘后",
|
|
1824
1830
|
"closed": "休市",
|
|
1831
|
+
// ── Pro: the first weeks' row and the paid cancel ──────────
|
|
1832
|
+
"Try Pro on your tickers": "在你的标的上试试 Pro",
|
|
1833
|
+
"Try Pro": "试试 Pro",
|
|
1834
|
+
"Stop suggesting Pro functions": "不再推荐 Pro 功能",
|
|
1835
|
+
"Open {command}": "打开 {command}",
|
|
1836
|
+
"Options flow": "期权流",
|
|
1837
|
+
"X mentions": "X 提及",
|
|
1838
|
+
"Hiring": "招聘",
|
|
1839
|
+
"8-K events": "8-K 事件",
|
|
1840
|
+
"Risk factors": "风险因素",
|
|
1841
|
+
"Cancel Pro": "取消 Pro",
|
|
1842
|
+
"Cancel Pro?": "取消 Pro?",
|
|
1843
|
+
"Keep Pro": "保留 Pro",
|
|
1844
|
+
"Pro until {date}": "Pro 至 {date}",
|
|
1845
|
+
"Cancelling...": "正在取消...",
|
|
1846
|
+
"Cancel Subscription": "取消订阅",
|
|
1847
|
+
"Keep My Subscription": "保留我的订阅",
|
|
1848
|
+
"Continue Cancellation": "继续取消",
|
|
1849
|
+
"Pro stays on until {date}.": "Pro 将保留至 {date}。",
|
|
1850
|
+
"Pro stays on until {date}. Cancelling now stops the renewal after that date.": "Pro 将保留至 {date}。现在取消会在该日期后停止续订。",
|
|
1851
|
+
"Cancelled. Pro stays on until {date}.": "已取消。Pro 将保留至 {date}。",
|
|
1825
1852
|
};
|
package/src/i18n/zh-tw.ts
CHANGED
|
@@ -1612,6 +1612,12 @@ export const zhTW: Record<string, string> = {
|
|
|
1612
1612
|
"TICKERS": "標的",
|
|
1613
1613
|
"Which tickers do you follow?": "你關注哪些標的?",
|
|
1614
1614
|
"Pick up to 3 for your watchlist.": "最多選 3 個加入自選清單。",
|
|
1615
|
+
// "Where did you hear about Gloom?", once, after an account signs up
|
|
1616
|
+
"Where did you hear about Gloom?": "你是從哪裡知道 Gloom 的?",
|
|
1617
|
+
"AI assistant": "AI 助理",
|
|
1618
|
+
"Friend or colleague": "朋友或同事",
|
|
1619
|
+
"Article or newsletter": "文章或電子報",
|
|
1620
|
+
"Where?": "在哪裡?",
|
|
1615
1621
|
"Skip": "略過",
|
|
1616
1622
|
"Equities": "股票",
|
|
1617
1623
|
"Futures & commodities": "期貨與大宗商品",
|
|
@@ -1822,4 +1828,25 @@ export const zhTW: Record<string, string> = {
|
|
|
1822
1828
|
"pre": "盤前",
|
|
1823
1829
|
"post": "盤後",
|
|
1824
1830
|
"closed": "休市",
|
|
1831
|
+
// ── Pro: the first weeks' row and the paid cancel ──────────
|
|
1832
|
+
"Try Pro on your tickers": "在你的標的上試試 Pro",
|
|
1833
|
+
"Try Pro": "試試 Pro",
|
|
1834
|
+
"Stop suggesting Pro functions": "不再推薦 Pro 功能",
|
|
1835
|
+
"Open {command}": "開啟 {command}",
|
|
1836
|
+
"Options flow": "選擇權流向",
|
|
1837
|
+
"X mentions": "X 提及",
|
|
1838
|
+
"Hiring": "招聘",
|
|
1839
|
+
"8-K events": "8-K 事件",
|
|
1840
|
+
"Risk factors": "風險因素",
|
|
1841
|
+
"Cancel Pro": "取消 Pro",
|
|
1842
|
+
"Cancel Pro?": "取消 Pro?",
|
|
1843
|
+
"Keep Pro": "保留 Pro",
|
|
1844
|
+
"Pro until {date}": "Pro 至 {date}",
|
|
1845
|
+
"Cancelling...": "正在取消...",
|
|
1846
|
+
"Cancel Subscription": "取消訂閱",
|
|
1847
|
+
"Keep My Subscription": "保留我的訂閱",
|
|
1848
|
+
"Continue Cancellation": "繼續取消",
|
|
1849
|
+
"Pro stays on until {date}.": "Pro 將保留至 {date}。",
|
|
1850
|
+
"Pro stays on until {date}. Cancelling now stops the renewal after that date.": "Pro 將保留至 {date}。現在取消會在該日期後停止續訂。",
|
|
1851
|
+
"Cancelled. Pro stays on until {date}.": "已取消。Pro 將保留至 {date}。",
|
|
1825
1852
|
};
|
|
@@ -197,8 +197,8 @@ function DiscoverStatus({ controller }: { controller: LayoutGalleryController })
|
|
|
197
197
|
<EmptyState title="Log in to browse community layouts." />
|
|
198
198
|
{/* The sidebar is narrow, so the pair wraps instead of running under the divider. */}
|
|
199
199
|
<Box flexDirection="row" flexWrap="wrap" gap={1} marginTop={1}>
|
|
200
|
-
<Button label={t("
|
|
201
|
-
<Button label={t("
|
|
200
|
+
<Button label={t("Sign up free")} variant="primary" compact onPress={controller.requestSignUp} />
|
|
201
|
+
<Button label={t("Log in")} variant="secondary" compact onPress={controller.requestSignIn} />
|
|
202
202
|
</Box>
|
|
203
203
|
</SidebarState>
|
|
204
204
|
);
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import type { IssuerListings } from "../types/issuer-listings";
|
|
2
|
+
import { canonicalExchange, parsePublicTickerKey } from "../utils/exchanges";
|
|
3
|
+
import { hongKongListingCode, listingSuffixCandidate } from "../sources/listing-symbols";
|
|
4
|
+
import { pricesTimingNote, type PairPriceInput } from "./depositary-pair";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* A company listed twice in China: its A shares in Shanghai or Shenzhen, in
|
|
8
|
+
* yuan, and its H shares in Hong Kong, in Hong Kong dollars (China Shenhua's
|
|
9
|
+
* 601088:SSE and 1088:HKEX, CATL's 300750:SZSE and 3750:HKEX). The two are
|
|
10
|
+
* one class of the company's shares, so the H price against the A price at
|
|
11
|
+
* spot is the A/H premium a Hong Kong desk quotes: on 17 Nov 2026 CATL's H
|
|
12
|
+
* shares closed at HK$366.80 against CN¥238.50 for its A shares, HK$280.80 at
|
|
13
|
+
* 1.1772 Hong Kong dollars a yuan, the H shares about 31% over the A.
|
|
14
|
+
*/
|
|
15
|
+
export interface AhPair {
|
|
16
|
+
/** The H share line, `1088:HKEX`. */
|
|
17
|
+
h: string;
|
|
18
|
+
/** The A share line, `601088:SSE`. */
|
|
19
|
+
a: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const A_SHARE_VENUES = new Set(["SSE", "SZSE"]);
|
|
23
|
+
|
|
24
|
+
/** A listing of the company universe as a key: `1088:HKEX`, `601088:SSE`. */
|
|
25
|
+
function listingKey(line: { symbol: string; exchange: string }): string {
|
|
26
|
+
const { symbol, exchange } = parsePublicTickerKey(line.symbol);
|
|
27
|
+
const venue = canonicalExchange(exchange ?? line.exchange);
|
|
28
|
+
return `${hongKongListingCode(symbol, venue)}:${venue}`;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* The A and H lines of the company Gloom Cloud's company universe holds them
|
|
33
|
+
* for: exactly one line in Hong Kong and one in Shanghai or Shenzhen. Null for
|
|
34
|
+
* any other company, and for one with more lines there than one of each.
|
|
35
|
+
*/
|
|
36
|
+
export function ahPairOf(issuer: Pick<IssuerListings, "listings"> | null | undefined): AhPair | null {
|
|
37
|
+
const lines = issuer?.listings ?? [];
|
|
38
|
+
const h = lines.filter((line) => canonicalExchange(line.exchange) === "HKEX");
|
|
39
|
+
const a = lines.filter((line) => A_SHARE_VENUES.has(canonicalExchange(line.exchange)));
|
|
40
|
+
return h.length === 1 && a.length === 1 ? { h: listingKey(h[0]!), a: listingKey(a[0]!) } : null;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* A listing as the pair writes its lines: `1088:HKEX` for 1088 on HKEX,
|
|
45
|
+
* `1088.HK` or `1088:HKEX`, the venue read from the key, a vendor's suffix or
|
|
46
|
+
* `exchange`.
|
|
47
|
+
*/
|
|
48
|
+
export function ahListingKey(symbol: string, exchange?: string | null): string {
|
|
49
|
+
const parsed = parsePublicTickerKey(symbol);
|
|
50
|
+
const suffixed = parsed.exchange ? null : listingSuffixCandidate(parsed.symbol);
|
|
51
|
+
return listingKey({ symbol: suffixed?.symbol ?? parsed.symbol, exchange: canonicalExchange(parsed.exchange ?? suffixed?.exchange ?? exchange ?? "") });
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** Which line of the pair a listing is (`ahListingKey`); null for neither. */
|
|
55
|
+
export function ahPairSide(pair: AhPair, symbol: string, exchange?: string | null): "h" | "a" | null {
|
|
56
|
+
const key = ahListingKey(symbol, exchange);
|
|
57
|
+
return key === pair.h ? "h" : key === pair.a ? "a" : null;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** Hong Kong dollars a yuan, from each currency's dollar value as exchange rates are served, and when it was read. */
|
|
61
|
+
export interface AhSpot {
|
|
62
|
+
rate: number;
|
|
63
|
+
observedAt: number | null;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* The rate from each currency's US dollar value (dollars a unit), as exchange
|
|
68
|
+
* rates are served and observed (`asOf`), dated by the older of the two reads.
|
|
69
|
+
* Null without both.
|
|
70
|
+
*/
|
|
71
|
+
export function ahSpotFromUsdValues(
|
|
72
|
+
cny: { rate: number | null | undefined; asOf?: number | null } | null | undefined,
|
|
73
|
+
hkd: { rate: number | null | undefined; asOf?: number | null } | null | undefined,
|
|
74
|
+
): AhSpot | null {
|
|
75
|
+
const yuan = cny?.rate;
|
|
76
|
+
const dollar = hkd?.rate;
|
|
77
|
+
if (yuan == null || dollar == null || !(yuan > 0) || !(dollar > 0) || !Number.isFinite(yuan / dollar)) return null;
|
|
78
|
+
const times = [cny?.asOf, hkd?.asOf].filter((time): time is number => time != null && Number.isFinite(time));
|
|
79
|
+
return { rate: yuan / dollar, observedAt: times.length === 2 ? Math.min(...times) : null };
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export interface AhComparison {
|
|
83
|
+
h: PairPriceInput;
|
|
84
|
+
a: PairPriceInput;
|
|
85
|
+
spot: AhSpot | null;
|
|
86
|
+
/** The A price in Hong Kong dollars at spot. */
|
|
87
|
+
aInHkd: number | null;
|
|
88
|
+
/** The H price over the A price at spot, in percent: H / (A × spot) - 1. */
|
|
89
|
+
premiumPercent: number | null;
|
|
90
|
+
/** Said when the two prices were not set together; null when they were. */
|
|
91
|
+
timingNote: string | null;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/** The comparison, or null without both prices, each in its own currency (HKD and CNY). */
|
|
95
|
+
export function compareAhPair(h: PairPriceInput | null, a: PairPriceInput | null, spot: AhSpot | null, now = Date.now()): AhComparison | null {
|
|
96
|
+
if (!h || !a || h.currency !== "HKD" || a.currency !== "CNY") return null;
|
|
97
|
+
const aInHkd = spot ? a.price * spot.rate : null;
|
|
98
|
+
const premiumPercent = aInHkd != null && aInHkd > 0 ? (h.price / aInHkd - 1) * 100 : null;
|
|
99
|
+
return { h, a, spot, aInHkd, premiumPercent, timingNote: pricesTimingNote(a, h, now) };
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/** `CNY/HKD`: Hong Kong dollars a yuan, as `fx` names the pair. */
|
|
103
|
+
export const AH_SPOT_LABEL = "CNY/HKD";
|
|
@@ -156,7 +156,11 @@ export function pairTimeText(time: number, now = Date.now()): string {
|
|
|
156
156
|
return `${formatUtcDayTime({ time, dateOnly: false }, now)} UTC`;
|
|
157
157
|
}
|
|
158
158
|
|
|
159
|
-
|
|
159
|
+
/**
|
|
160
|
+
* Said when two prices compared were not set together (one market closed, or
|
|
161
|
+
* both closed half an hour or more apart); null when they were.
|
|
162
|
+
*/
|
|
163
|
+
export function pricesTimingNote(receipt: PairPriceInput, home: PairPriceInput, now: number): string | null {
|
|
160
164
|
if (receipt.open && home.open) return null;
|
|
161
165
|
if (receipt.observedAt == null || home.observedAt == null) return null;
|
|
162
166
|
const gap = Math.abs(receipt.observedAt - home.observedAt);
|
|
@@ -181,7 +185,7 @@ export function compareDepositaryPair(
|
|
|
181
185
|
const impliedFx = (home.price * ratio) / receipt.price;
|
|
182
186
|
if (!Number.isFinite(impliedFx) || impliedFx <= 0) return null;
|
|
183
187
|
const premiumPercent = spot ? (spot.rate / impliedFx - 1) * 100 : null;
|
|
184
|
-
return { ratio, receipt, home, impliedFx, spot, premiumPercent, timingNote:
|
|
188
|
+
return { ratio, receipt, home, impliedFx, spot, premiumPercent, timingNote: pricesTimingNote(receipt, home, now) };
|
|
185
189
|
}
|
|
186
190
|
|
|
187
191
|
/** `1,651.28`, `28.4942`, `0.890625`: a dollar rate to its useful digits. */
|