@gloom-sh/terminal 0.19.6 → 0.20.0

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.
Files changed (137) hide show
  1. package/LICENSE +0 -4
  2. package/package.json +6 -5
  3. package/patches/electrobun-devkit@2.0.5.patch +148 -0
  4. package/src/api-client/bond-trades.ts +59 -0
  5. package/src/api-client/data.ts +21 -0
  6. package/src/api-client/index.ts +2 -0
  7. package/src/api-client/types/account.ts +86 -0
  8. package/src/api-client/types/assist.ts +32 -0
  9. package/src/api-client/types/auth.ts +63 -0
  10. package/src/api-client/types/billing.ts +54 -0
  11. package/src/api-client/types/chat.ts +180 -0
  12. package/src/api-client/types/congress.ts +107 -0
  13. package/src/api-client/types/credit.ts +110 -0
  14. package/src/api-client/types/econ.ts +158 -0
  15. package/src/api-client/types/equity-diagnostic.ts +73 -0
  16. package/src/api-client/types/filings-and-calls.ts +350 -0
  17. package/src/api-client/types/index.ts +25 -0
  18. package/src/api-client/types/jobs.ts +147 -0
  19. package/src/api-client/types/market.ts +122 -0
  20. package/src/api-client/types/news.ts +91 -0
  21. package/src/api-client/types/notes-and-theses.ts +172 -0
  22. package/src/api-client/types/quotes.ts +28 -0
  23. package/src/api-client/types/scanners.ts +125 -0
  24. package/src/api-client/types/screener.ts +65 -0
  25. package/src/api-client/types/search.ts +107 -0
  26. package/src/api-client/types/sync.ts +14 -0
  27. package/src/api-client/types/team-collections.ts +43 -0
  28. package/src/api-client/types/team-views.ts +32 -0
  29. package/src/api-client/types/teams.ts +135 -0
  30. package/src/api-client/types/ticker-data.ts +57 -0
  31. package/src/api-client/types/tweets.ts +59 -0
  32. package/src/api-client/types/world-venues.ts +23 -0
  33. package/src/app/runtime/desktop-deeplink.ts +41 -6
  34. package/src/app/star-prompt/status-line.tsx +1 -1
  35. package/src/app.tsx +1 -7
  36. package/src/architecture/ui-tokens-allowlist.json +0 -8
  37. package/src/cli/commands/ticker.ts +17 -4
  38. package/src/cli/desktop-pane-shot-browser.ts +69 -3
  39. package/src/cli/pane-functions/catalog.ts +3 -1
  40. package/src/components/chart/composite/use-composite-chart-keyboard.ts +11 -2
  41. package/src/components/data-table/export.ts +4 -1
  42. package/src/components/layout/detached-pane-shell.tsx +10 -37
  43. package/src/components/layout/double-escape-close.ts +90 -0
  44. package/src/components/layout/header.tsx +3 -2
  45. package/src/components/layout/market-summary.ts +6 -3
  46. package/src/components/layout/pane/footer/index.tsx +2 -6
  47. package/src/components/layout/pane/footer/model.ts +6 -12
  48. package/src/components/layout/shell/active-drag.ts +53 -11
  49. package/src/components/layout/shell/drag/magnets.ts +128 -19
  50. package/src/components/layout/shell/pane/actions.ts +6 -2
  51. package/src/components/layout/shell/pane/management-shortcuts.ts +13 -51
  52. package/src/components/layout/status-bar.tsx +4 -78
  53. package/src/components/layout/status-widget-space.ts +5 -5
  54. package/src/components/onboarding/portfolio-step/positions-panel.tsx +1 -1
  55. package/src/components/ui/data-table/index.tsx +5 -1
  56. package/src/components/ui/data-table/render-cell.ts +19 -0
  57. package/src/components/ui/delayed-mark.tsx +59 -7
  58. package/src/components/ui/icon.tsx +1 -8
  59. package/src/components/ui/menu.tsx +6 -1
  60. package/src/i18n/es.ts +3 -3
  61. package/src/i18n/ja.ts +3 -3
  62. package/src/i18n/ko.ts +3 -3
  63. package/src/i18n/zh-cn.ts +3 -3
  64. package/src/i18n/zh-tw.ts +3 -3
  65. package/src/plugins/builtin/chat/content/composer.tsx +21 -27
  66. package/src/plugins/builtin/chat/content/index.tsx +31 -3
  67. package/src/plugins/builtin/chat/content/shortcuts.ts +4 -2
  68. package/src/plugins/builtin/chat/content/snapshot.ts +0 -3
  69. package/src/plugins/builtin/cloud/auth-actions.tsx +51 -23
  70. package/src/plugins/builtin/cloud/trial-offer-status-widget.tsx +3 -3
  71. package/src/plugins/builtin/cloud/upgrade-status-widget.tsx +32 -25
  72. package/src/plugins/builtin/congress-trades/model.ts +2 -1
  73. package/src/plugins/builtin/congress-trades/pane.tsx +3 -0
  74. package/src/plugins/builtin/custom-view/index.tsx +1 -1
  75. package/src/plugins/builtin/custom-view/loader.ts +85 -8
  76. package/src/plugins/builtin/custom-view/view-spec.ts +28 -0
  77. package/src/plugins/builtin/equity-screener/criterion-editor.tsx +13 -4
  78. package/src/plugins/builtin/equity-screener/headless.ts +33 -1
  79. package/src/plugins/builtin/equity-screener/model.ts +58 -15
  80. package/src/plugins/builtin/equity-screener/pane.tsx +36 -6
  81. package/src/plugins/builtin/executives/format.ts +5 -4
  82. package/src/plugins/builtin/executives/pane.tsx +1 -1
  83. package/src/plugins/builtin/help/index.tsx +55 -1
  84. package/src/plugins/builtin/insider/model.ts +30 -2
  85. package/src/plugins/builtin/jobs/model.ts +2 -2
  86. package/src/plugins/builtin/mna/model.ts +2 -2
  87. package/src/plugins/builtin/notes/files.ts +2 -0
  88. package/src/plugins/builtin/notes/owner.tsx +20 -1
  89. package/src/plugins/builtin/notes/quick-notes-pane.tsx +22 -4
  90. package/src/plugins/builtin/notes/store.ts +6 -1
  91. package/src/plugins/builtin/portfolio-list/header.tsx +1 -1
  92. package/src/plugins/builtin/research/corporate-actions-pane.tsx +29 -25
  93. package/src/plugins/builtin/series-inventory.ts +1 -0
  94. package/src/plugins/builtin/shared/earnings-report.ts +7 -2
  95. package/src/plugins/builtin/shared/use-quote-board.ts +85 -46
  96. package/src/plugins/builtin/short-interest/headless.ts +1 -1
  97. package/src/plugins/builtin/short-interest/model.ts +15 -6
  98. package/src/plugins/builtin/short-interest/types.ts +2 -0
  99. package/src/plugins/builtin/thirteenf/overlap-pane.tsx +3 -0
  100. package/src/plugins/builtin/thirteenf/pane.tsx +3 -0
  101. package/src/plugins/builtin/ticker-detail/overview/model.ts +5 -3
  102. package/src/plugins/builtin/ticker-detail/overview-tab.tsx +4 -4
  103. package/src/plugins/builtin/trace-bonds/detail.tsx +198 -0
  104. package/src/plugins/builtin/trace-bonds/headless.ts +62 -4
  105. package/src/plugins/builtin/trace-bonds/history.ts +155 -0
  106. package/src/plugins/builtin/trace-bonds/pane.tsx +64 -5
  107. package/src/plugins/installer.ts +16 -3
  108. package/src/plugins/plugin-names.ts +11 -2
  109. package/src/remote/controller.ts +9 -2
  110. package/src/remote/schema.ts +2 -1
  111. package/src/renderers/cloudflare/http-proxy.ts +67 -8
  112. package/src/renderers/cloudflare/proxy-session.ts +1 -1
  113. package/src/renderers/cloudflare/worker.ts +29 -2
  114. package/src/renderers/dom/desktop/icons.tsx +0 -2
  115. package/src/renderers/dom/styles.css +0 -3
  116. package/src/renderers/electrobun/bun/desktop/install-records.ts +59 -0
  117. package/src/renderers/electrobun/bun/desktop/installer-folder.ts +208 -592
  118. package/src/renderers/electrobun/bun/desktop/macos-objc.ts +14 -0
  119. package/src/renderers/electrobun/bun/desktop/update.ts +1 -1
  120. package/src/renderers/electrobun/bun/index.ts +19 -13
  121. package/src/renderers/electrobun/bun/window/create.ts +23 -3
  122. package/src/renderers/electrobun/bun/window/electrobun-window-host.ts +4 -4
  123. package/src/renderers/electrobun/bun/window/events.ts +4 -4
  124. package/src/renderers/electrobun/bun/window/frame.ts +2 -1
  125. package/src/renderers/electrobun/bun/window/native-min-size.ts +322 -0
  126. package/src/renderers/electrobun/view/backend-rpc.ts +1 -1
  127. package/src/sources/gloomberb-cloud/index.ts +5 -7
  128. package/src/sources/provider-router/batches.ts +18 -3
  129. package/src/sources/provider-router/financials.ts +18 -4
  130. package/src/types/data-provider.ts +14 -0
  131. package/src/types/financials.ts +15 -3
  132. package/src/types/headless.ts +2 -0
  133. package/src/utils/double-escape-close.ts +38 -16
  134. package/src/utils/format.ts +23 -3
  135. package/src/utils/price-earnings.ts +18 -0
  136. package/patches/electrobun@1.18.1.patch +0 -633
  137. package/src/api-client/types.ts +0 -2441
@@ -443,7 +443,15 @@ function mergeDefinedObject<T extends object>(preferred: T | null | undefined, f
443
443
  return Object.fromEntries(mergedEntries) as T;
444
444
  }
445
445
 
446
- function setOrDelete<K extends "dividendRate" | "forwardEps">(target: Fundamentals, key: K, value: Fundamentals[K]): void {
446
+ /** Forward P/E, its consensus EPS and the year it is for: one observation, never pieced together from two. */
447
+ const FORWARD_FIELDS = ["forwardPE", "forwardEps", "forwardEpsCurrency", "forwardEpsPeriodEnd", "forwardEpsObservedAt"] as const;
448
+
449
+ /** A block that read next year's consensus says what it found, even none: its forward fields stand whole. */
450
+ function readsConsensus(fundamentals: Fundamentals | undefined): boolean {
451
+ return fundamentals?.forwardEpsPeriodEnd !== undefined;
452
+ }
453
+
454
+ function setOrDelete<K extends "dividendRate" | (typeof FORWARD_FIELDS)[number]>(target: Fundamentals, key: K, value: Fundamentals[K]): void {
447
455
  if (value === undefined) delete target[key];
448
456
  else target[key] = value;
449
457
  }
@@ -483,10 +491,14 @@ function mergeFundamentals(primary: Fundamentals | undefined, fallback: Fundamen
483
491
  merged.dividendYieldSource = dividend.dividendYieldSource;
484
492
  setOrDelete(merged, "dividendRate", dividend.dividendRate);
485
493
  }
486
- const forward = primary?.forwardPE != null ? primary : fallback;
494
+ const forward = primary?.forwardPE != null || readsConsensus(primary) ? primary : fallback;
487
495
  // Forward EPS reprices the forward multiple, so it pairs with that multiple's
488
- // observation; a withdrawn one never comes back from an older fallback.
489
- if (merged && forward) setOrDelete(merged, "forwardEps", forward.forwardEps);
496
+ // observation; a withdrawn one never comes back from an older fallback, and
497
+ // a consensus that is a loss or none never takes an older multiple.
498
+ if (merged && forward) {
499
+ if (readsConsensus(forward)) for (const key of FORWARD_FIELDS) setOrDelete(merged, key, forward[key]);
500
+ else setOrDelete(merged, "forwardEps", forward.forwardEps);
501
+ }
490
502
  if (merged && primary && !primary.financialCurrency && [
491
503
  primary.revenue, primary.netIncome, primary.operatingCashFlow, primary.freeCashFlow, primary.eps,
492
504
  ].some((value) => value != null)) {
@@ -576,6 +588,8 @@ export function mergeRefreshedFinancials(cached: TickerFinancials, fresh: Ticker
576
588
  if (!currencyConflict && typeof statistics[field] === "number" && Number.isFinite(statistics[field])) update[field] = statistics[field];
577
589
  }
578
590
  if (!currencyConflict && statistics.enterpriseValueCheck) update.enterpriseValueCheck = statistics.enterpriseValueCheck;
591
+ // Fresh statistics that read next year's consensus replace the forward figures whole, a loss or none included.
592
+ if (readsConsensus(statistics)) for (const key of FORWARD_FIELDS) if (statistics[key] !== undefined) update[key] = statistics[key] as never;
579
593
  let fundamentals = mergeFundamentals(update, merged.fundamentals);
580
594
  // The source serving a multiple or yield without its per-share base has
581
595
  // withdrawn that base, so an older one must not keep repricing the figure.
@@ -223,6 +223,13 @@ export interface QuoteBatchResult {
223
223
  target: QuoteSubscriptionTarget;
224
224
  quote: Quote | null;
225
225
  error?: unknown;
226
+ /**
227
+ * Set only with `deferFollowUps`: the batch left this target without a
228
+ * current quote, and `getQuote` with this cache mode is the read that
229
+ * settles it. `quote` meanwhile is the dated price the batch had, flagged
230
+ * stale, or none.
231
+ */
232
+ followUp?: "default" | "refresh";
226
233
  }
227
234
 
228
235
  export interface QuoteBatchOptions {
@@ -241,6 +248,13 @@ export interface QuoteBatchOptions {
241
248
  * each form's own copy from whenever it was last asked for.
242
249
  */
243
250
  revalidate?: boolean;
251
+ /**
252
+ * Answer from the cache and the batch read alone: a target they leave
253
+ * without a current quote comes back with `followUp` instead of being
254
+ * asked for on its own. A board paints the batch as soon as it answers and
255
+ * asks for those itself, so a slow one holds only its own row.
256
+ */
257
+ deferFollowUps?: boolean;
244
258
  /** The caller stopped waiting; a transport that can abandon the request does. */
245
259
  signal?: AbortSignal;
246
260
  /** The caller prints what each move is from (MarketDataRequestContext.datesChangeBasis). */
@@ -350,13 +350,25 @@ export interface Fundamentals extends DepositaryReceiptFacts {
350
350
  marketCap?: number;
351
351
  marketCapCurrency?: string;
352
352
  trailingPE?: number;
353
+ /** The price over next fiscal year's consensus EPS; absent when that EPS is not positive or there is none. */
353
354
  forwardPE?: number;
354
355
  /**
355
- * Forward EPS behind `forwardPE`, per share in the listing's major currency
356
- * unit. Served only when its basis matches the multiple, so the multiple can
357
- * be repriced from a live quote; absent otherwise.
356
+ * Next fiscal year's consensus EPS behind `forwardPE`, per share in the
357
+ * unit of the multiple's price, so the multiple can be repriced from a live
358
+ * quote. Served negative without a multiple (N/M); absent otherwise.
358
359
  */
359
360
  forwardEps?: number;
361
+ /** The currency `forwardEps` is in. */
362
+ forwardEpsCurrency?: string;
363
+ /**
364
+ * The end of the fiscal year the consensus is for (`2027-12-31` is FY27).
365
+ * Null when the source was asked and had no consensus for next year, or
366
+ * only one from before the listing's last split; absent from a block
367
+ * served before Gloom Cloud read consensus.
368
+ */
369
+ forwardEpsPeriodEnd?: string | null;
370
+ /** When the consensus was read. */
371
+ forwardEpsObservedAt?: string;
360
372
  pegRatio?: number;
361
373
  enterpriseValue?: number;
362
374
  enterpriseToRevenue?: number;
@@ -93,6 +93,8 @@ export interface HeadlessPaneOptionDef {
93
93
  list?: boolean;
94
94
  /** The option in use as typed after the function, such as `--expiration 2028-01-21`; the catalog shows it as an example. */
95
95
  example?: string;
96
+ /** Other uses the catalog shows after `example`: a form of the value the first does not show. */
97
+ examples?: readonly string[];
96
98
  /** The example runs without the function's optional argument, as an option that works only then does (`fn INS --side sell`). */
97
99
  exampleWithoutArgument?: boolean;
98
100
  /**
@@ -23,10 +23,11 @@ export function resetDoubleEscapeClose(state: DoubleEscapeCloseState) {
23
23
  }
24
24
 
25
25
  /**
26
- * Key handling for a double-Esc close: `take` runs before the pane and closes on the
27
- * second Esc of a pair, `arm` runs after it and only when nothing used the Esc.
28
- * So an Esc that backs out of a detail or closes a menu never counts as the
29
- * first half of a close.
26
+ * Key handling for a double-Esc close: `take` closes on the second Esc of a
27
+ * pair, before the pane sees it, and `arm` makes an Esc the first half. Every
28
+ * Esc arms, whatever the pane does with it (back out of a detail, clear a
29
+ * selection, leave a chart), except an Esc that leaves a draft or closes a
30
+ * menu: see `countEscapeTowardClose` and `keepEscapeFromClosing`.
30
31
  */
31
32
  export function takeDoubleEscapeClose(
32
33
  state: DoubleEscapeCloseState,
@@ -42,24 +43,45 @@ export function takeDoubleEscapeClose(
42
43
  return matched;
43
44
  }
44
45
 
45
- const escapeArmOffers = new WeakMap<object, () => void>();
46
+ interface EscapeOffer {
47
+ count(): void;
48
+ keep(): void;
49
+ kept: boolean;
50
+ }
51
+
52
+ const escapeOffers = new WeakMap<object, EscapeOffer>();
46
53
 
47
54
  /**
48
- * Leaving an empty text field is the one Esc a pane uses that still counts as
49
- * the first half of a close, so Esc Esc from an idle composer closes the pane.
50
- * The shell offers every Esc in its `before` phase, focused field or not; a
51
- * pane handler that runs later takes the offer with `countEscapeTowardClose`
52
- * and consumes the Esc as usual. Anything the Esc backs out of (a draft, a
53
- * reply, a menu) keeps it from counting.
55
+ * The shell offers every Esc to the pane before any handler runs, so a
56
+ * handler in any phase can say what its Esc did to the close.
54
57
  */
55
- export function offerEscapeTowardClose(event: object, arm: () => void) {
56
- escapeArmOffers.set(event, arm);
58
+ export function offerEscapeTowardClose(event: object, offer: { count(): void; keep(): void }) {
59
+ escapeOffers.set(event, { ...offer, kept: false });
57
60
  }
58
61
 
62
+ /**
63
+ * In a text field, or while a pane is editing, an Esc counts only when the
64
+ * pane says it left nothing typed behind: Esc Esc from an empty composer
65
+ * closes the pane, from a draft it never does.
66
+ */
59
67
  export function countEscapeTowardClose(event: object) {
60
- const arm = escapeArmOffers.get(event);
61
- escapeArmOffers.delete(event);
62
- arm?.();
68
+ const offer = escapeOffers.get(event);
69
+ if (offer && !offer.kept) offer.count();
70
+ }
71
+
72
+ /**
73
+ * An Esc that closes a menu or popover of the pane's own, or backs out of a
74
+ * draft, is not the first half of a close.
75
+ */
76
+ export function keepEscapeFromClosing(event: object) {
77
+ const offer = escapeOffers.get(event);
78
+ if (!offer) return;
79
+ offer.kept = true;
80
+ offer.keep();
81
+ }
82
+
83
+ export function isEscapeKeptFromClosing(event: object): boolean {
84
+ return escapeOffers.get(event)?.kept === true;
63
85
  }
64
86
 
65
87
  export function armDoubleEscapeClose(
@@ -132,11 +132,31 @@ export function formatPercentRaw(value: number | undefined): string {
132
132
  return `${signedFixed(value, 2)}%`;
133
133
  }
134
134
 
135
+ let figureColumnCells = 0;
136
+
137
+ /**
138
+ * Formats one cell of a right-aligned table column. Inside it `formatCompact`
139
+ * keeps its decimals unless the caller passes `fixedDecimals: false`, so a
140
+ * column of compact figures lines up: 12.00M over 10.73M, 10.0k over 12.5k.
141
+ * The table kit draws, reports and exports every right-aligned cell through
142
+ * this, so a pane's cell keeps the short 12M wherever else it says it (a
143
+ * figure, a sentence, a label).
144
+ */
145
+ export function inFigureColumn<T>(format: () => T): T {
146
+ figureColumnCells += 1;
147
+ try {
148
+ return format();
149
+ } finally {
150
+ figureColumnCells -= 1;
151
+ }
152
+ }
153
+
135
154
  /**
136
- * Format large numbers compactly (e.g., 1.5T, 234B, 12.3M, 5k). Table columns
137
- * pass `fixedDecimals` so 1.70T lines up with 1.33T.
155
+ * Format large numbers compactly (e.g., 1.5T, 234B, 12.3M, 5k). In a table
156
+ * column (`inFigureColumn`), or with `fixedDecimals`, the decimals stay so
157
+ * 1.70T lines up with 1.33T.
138
158
  */
139
- export function formatCompact(value: number | undefined, { fixedDecimals = false }: { fixedDecimals?: boolean } = {}): string {
159
+ export function formatCompact(value: number | undefined, { fixedDecimals = figureColumnCells > 0 }: { fixedDecimals?: boolean } = {}): string {
140
160
  if (value == null || !Number.isFinite(value)) return MISSING_VALUE;
141
161
  const { fixed, suffix } = compactParts(Math.abs(value));
142
162
  // Strip unnecessary trailing zeros after decimal point
@@ -39,6 +39,24 @@ export function formatPriceEarnings(value: PriceEarnings | null | undefined, pre
39
39
  return value <= 0 ? "N/M" : formatNumber(value, precision);
40
40
  }
41
41
 
42
+ /**
43
+ * The fiscal year a forward consensus is for, as a label names it: `FY27`
44
+ * for a year that ends in 2027, whichever month. Null for a block that does
45
+ * not say.
46
+ */
47
+ export function forwardFiscalYear(periodEnd: string | null | undefined): string | null {
48
+ return typeof periodEnd === "string" && /^\d{4}-\d{2}-\d{2}$/.test(periodEnd) ? `FY${periodEnd.slice(2, 4)}` : null;
49
+ }
50
+
51
+ /**
52
+ * Whether a forward P/E line is shown even with no figure: the block read
53
+ * next year's consensus for a company (one with a trailing EPS) and found
54
+ * none, or one from before the last split, which reads as a dash.
55
+ */
56
+ export function forwardPEAsked(fundamentals: Pick<Fundamentals, "forwardEpsPeriodEnd" | "eps"> | undefined): boolean {
57
+ return fundamentals?.forwardEpsPeriodEnd !== undefined && fundamentals.eps != null;
58
+ }
59
+
42
60
  type PriceEarningsField = "trailingPE" | "forwardPE" | "pegRatio";
43
61
 
44
62
  /**