gloomberb 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
@@ -0,0 +1,135 @@
1
+ const TEAM_ACCENT_COLORS = [
2
+ "amber",
3
+ "blue",
4
+ "cyan",
5
+ "green",
6
+ "magenta",
7
+ "orange",
8
+ "red",
9
+ "violet",
10
+ ] as const;
11
+
12
+ export type TeamAccentColor = (typeof TEAM_ACCENT_COLORS)[number];
13
+
14
+ export type TeamRole = "owner" | "admin" | "member";
15
+
16
+ export interface TeamSummary {
17
+ id: string;
18
+ name: string;
19
+ slug: string;
20
+ accentColor: TeamAccentColor;
21
+ shortName: string;
22
+ allowMemberInvites: boolean;
23
+ /** Seats the team can fill; a Team plan deal sets it, otherwise 25. */
24
+ memberLimit?: number;
25
+ channelId: string;
26
+ createdAt: string;
27
+ role: TeamRole;
28
+ memberCount: number;
29
+ }
30
+
31
+ export interface TeamMember {
32
+ id: string;
33
+ role: TeamRole;
34
+ joinedAt: string;
35
+ user: { id: string; username: string | null; displayName: string };
36
+ }
37
+
38
+ export interface TeamInviteLink {
39
+ token: string;
40
+ url: string;
41
+ teamId: string;
42
+ createdBy: string;
43
+ expiresAt: string;
44
+ maxUses: number | null;
45
+ uses: number;
46
+ createdAt: string;
47
+ }
48
+
49
+ /** A Better Auth organization invitation as returned by /auth/organization/* endpoints. */
50
+ export interface TeamUser {
51
+ id: string;
52
+ username: string | null;
53
+ displayName: string;
54
+ }
55
+
56
+ /** An invitation addressed to the signed-in person. */
57
+ export interface TeamReceivedInvitation {
58
+ id: string;
59
+ role: TeamRole;
60
+ expiresAt: string;
61
+ createdAt: string;
62
+ team: {
63
+ id: string;
64
+ name: string;
65
+ slug: string;
66
+ accentColor: TeamAccentColor;
67
+ shortName: string;
68
+ memberCount: number;
69
+ };
70
+ inviter: TeamUser;
71
+ }
72
+
73
+ /** An invitation a team sent; the invitee is null for addresses without an account. */
74
+ export interface TeamSentInvitation {
75
+ id: string;
76
+ status: string;
77
+ role: TeamRole;
78
+ expiresAt: string;
79
+ createdAt: string;
80
+ inviter: TeamUser;
81
+ invitee: TeamUser | null;
82
+ }
83
+
84
+ export interface TeamUpdatedEvent {
85
+ teamId: string;
86
+ change: "settings" | "members" | "channels" | "deleted";
87
+ }
88
+
89
+ export interface TeamUsernameInvitation {
90
+ id: string;
91
+ status: string;
92
+ expiresAt: string;
93
+ invitee: { id: string; username: string | null; displayName: string };
94
+ }
95
+
96
+ interface TeamActor {
97
+ id: string;
98
+ username: string | null;
99
+ displayName: string;
100
+ }
101
+
102
+ interface TeamNotificationTeam {
103
+ id: string;
104
+ name: string;
105
+ accentColor: TeamAccentColor;
106
+ shortName: string;
107
+ }
108
+
109
+ type TeamNotificationData =
110
+ | {
111
+ kind: "team-invite";
112
+ team: TeamNotificationTeam;
113
+ invitationId: string;
114
+ expiresAt: string;
115
+ inviter: TeamActor;
116
+ }
117
+ | { kind: "team-joined"; team: TeamNotificationTeam; member: TeamActor }
118
+ | {
119
+ kind: "layout-updated";
120
+ team: TeamNotificationTeam;
121
+ layoutId: string;
122
+ layoutName: string;
123
+ revision: number;
124
+ author: TeamActor;
125
+ };
126
+
127
+ type TeamNotificationType = TeamNotificationData["kind"];
128
+
129
+ export interface TeamNotification {
130
+ id: string;
131
+ type: TeamNotificationType;
132
+ channelId: string;
133
+ createdAt: string;
134
+ data: TeamNotificationData;
135
+ }
@@ -0,0 +1,57 @@
1
+ import type {
2
+ AnalystResearchData,
3
+ CorporateActionsData,
4
+ HolderData,
5
+ HolderRecord,
6
+ OptionsChain,
7
+ TickerFinancials,
8
+ } from "../../types/financials";
9
+ import type { CloudQuotePayload } from "./quotes";
10
+
11
+ export interface CloudFinancialsPayload extends Omit<TickerFinancials, "quote"> {
12
+ quote?: CloudQuotePayload;
13
+ }
14
+
15
+ export interface CloudOptionsChainPayload extends OptionsChain {
16
+ providerId: "gloomberb-cloud";
17
+ }
18
+
19
+ interface CloudHolderPayload extends HolderRecord {
20
+ providerId: "gloomberb-cloud";
21
+ ownerType: "institution";
22
+ }
23
+
24
+ export interface CloudHoldersPayload extends HolderData {
25
+ providerId: "gloomberb-cloud";
26
+ holders: CloudHolderPayload[];
27
+ }
28
+
29
+ export interface CloudAnalystResearchPayload extends AnalystResearchData {
30
+ providerId: "gloomberb-cloud";
31
+ }
32
+
33
+ export interface CloudCorporateActionsPayload extends CorporateActionsData {
34
+ providerId: "gloomberb-cloud";
35
+ }
36
+
37
+ interface CloudShortInterestPointPayload {
38
+ settlementDate: string;
39
+ shortPercentFloat?: number | null;
40
+ /** The 10-K or 10-Q cover share count known when FINRA published the settlement. Absent on servers older than the field. */
41
+ sharesOutstanding?: number;
42
+ /** YYYY-MM-DD that count was taken. */
43
+ sharesOutstandingAsOf?: string;
44
+ sharesShort: number;
45
+ previousSharesShort: number | null;
46
+ averageDailyVolume: number | null;
47
+ daysToCover: number | null;
48
+ changePercent: number | null;
49
+ revised: boolean;
50
+ }
51
+
52
+ export interface CloudShortInterestPayload {
53
+ source?: "finra" | "gloom";
54
+ symbol: string;
55
+ issueName: string | null;
56
+ points: CloudShortInterestPointPayload[];
57
+ }
@@ -0,0 +1,59 @@
1
+ interface CloudTweetUserPayload {
2
+ id: string;
3
+ userName: string;
4
+ name: string;
5
+ }
6
+
7
+ interface CloudTweetMetricsPayload {
8
+ retweets: number | null;
9
+ replies: number | null;
10
+ likes: number | null;
11
+ quotes: number | null;
12
+ views: number | null;
13
+ bookmarks: number | null;
14
+ }
15
+
16
+ interface CloudTweetMediaPayload {
17
+ type?: string;
18
+ url?: string;
19
+ mediaUrl?: string;
20
+ media_url?: string;
21
+ media_url_https?: string;
22
+ previewImageUrl?: string;
23
+ preview_image_url?: string;
24
+ }
25
+
26
+ export interface CloudTweetPayload {
27
+ id: string;
28
+ url: string;
29
+ text: string;
30
+ createdAt: string;
31
+ lang: string;
32
+ isReply: boolean;
33
+ author: CloudTweetUserPayload;
34
+ metrics: CloudTweetMetricsPayload;
35
+ media?: CloudTweetMediaPayload[];
36
+ photos?: CloudTweetMediaPayload[];
37
+ images?: CloudTweetMediaPayload[];
38
+ }
39
+
40
+ export type CloudTweetQueryType = "Latest" | "Top";
41
+
42
+ export interface CloudTweetSearchResponse {
43
+ ticker?: string;
44
+ cashtag?: string;
45
+ query: string;
46
+ queryType: CloudTweetQueryType;
47
+ since: string;
48
+ until: string;
49
+ limit: number;
50
+ offset?: number;
51
+ /** More tweets sit behind this page. Absent on servers without paging. */
52
+ hasMore?: boolean;
53
+ hours: number;
54
+ includeReplies?: boolean;
55
+ cached: boolean;
56
+ cacheTtlMs: number;
57
+ asOf: string;
58
+ tweets: CloudTweetPayload[];
59
+ }
@@ -0,0 +1,23 @@
1
+ export interface CloudWorldVenuePayload {
2
+ mic: string;
3
+ name: string;
4
+ title: string;
5
+ country: string;
6
+ countryCode: string;
7
+ city: string;
8
+ timezone: string;
9
+ latitude: number;
10
+ longitude: number;
11
+ isOpen: boolean;
12
+ timeAfterOpenSeconds?: number;
13
+ timeToOpenSeconds?: number;
14
+ timeToCloseSeconds?: number;
15
+ }
16
+
17
+ export interface CloudWorldVenueMapPayload {
18
+ providerId: "gloomberb-cloud";
19
+ checkedAt: number;
20
+ refreshAt: number;
21
+ stale?: boolean;
22
+ venues: CloudWorldVenuePayload[];
23
+ }
@@ -13,6 +13,7 @@ import type { DesktopDeepLinkBridge } from "../../types/desktop-deeplink";
13
13
  import type { DesktopWindowBridge } from "../../types/desktop-window";
14
14
  import { requestAccountManagementTab } from "../../plugins/builtin/account-management/navigation";
15
15
  import { openTeamPane } from "../../team/pane-request";
16
+ import { hasOnlyDmUsernameArgs, parseDmUsernames } from "../../plugins/builtin/chat/channels";
16
17
  import { chatController } from "../../plugins/builtin/chat/controller";
17
18
  import { getShare, type ShareRecord } from "../../shares/api";
18
19
  import { openShareLink, registerShareOpener } from "../../shares/open";
@@ -310,6 +311,23 @@ function notifySuccess(pluginRegistry: PluginRegistry, body: string): void {
310
311
  pluginRegistry.notify({ body, type: "success" });
311
312
  }
312
313
 
314
+ /**
315
+ * A link that changes something (creates an alert, adds a layout, starts a
316
+ * conversation) waits for a click on a toast that says what it asks: any web
317
+ * page can open a gloomberb:// link, and a browser told to always allow them
318
+ * asks nothing more. Links that only show something, a shared pane among
319
+ * them, run at once.
320
+ */
321
+ function askBeforeRunning(pluginRegistry: PluginRegistry, body: string, label: string, run: () => void): void {
322
+ pluginRegistry.notify({
323
+ title: "Gloom link",
324
+ body,
325
+ type: "info",
326
+ persistent: true,
327
+ action: { label, onClick: run },
328
+ });
329
+ }
330
+
313
331
  function requirePane(pluginRegistry: PluginRegistry, paneId: string, unavailableMessage: string): boolean {
314
332
  if (pluginRegistry.panes.has(paneId)) return true;
315
333
  notifyError(pluginRegistry, unavailableMessage);
@@ -585,24 +603,41 @@ export function handleDesktopDeepLink(rawUrl: string, options: DesktopDeepLinkHa
585
603
  case "open-collection":
586
604
  handleOpenCollection(action, options);
587
605
  return;
588
- case "create-alert":
589
- handleCreateAlert(action, options.pluginRegistry);
606
+ case "create-alert": {
607
+ const { symbol, condition, price } = action.values;
608
+ askBeforeRunning(options.pluginRegistry, `Create an alert for ${symbol} ${condition} ${price}?`, "Create alert", () => {
609
+ handleCreateAlert(action, options.pluginRegistry);
610
+ });
590
611
  return;
612
+ }
591
613
  case "open-chat-channel":
592
614
  handleOpenChatChannel(action, options.pluginRegistry);
593
615
  return;
594
- case "open-chat-dm":
595
- handleOpenChatDm(action, options.pluginRegistry);
616
+ case "open-chat-dm": {
617
+ // The toast names only what reads as usernames, never the link's own words.
618
+ const names = parseDmUsernames(action.participants);
619
+ if (names.length === 0 || !hasOnlyDmUsernameArgs(action.participants)) {
620
+ notifyError(options.pluginRegistry, "DM links need usernames.");
621
+ return;
622
+ }
623
+ askBeforeRunning(options.pluginRegistry, `Open a conversation with ${names.map((name) => `@${name}`).join(", ")}?`, "Open", () => {
624
+ handleOpenChatDm(action, options.pluginRegistry);
625
+ });
596
626
  return;
627
+ }
597
628
  case "open-news":
598
629
  handleOpenNews(action, options.pluginRegistry);
599
630
  return;
600
631
  case "open-share":
632
+ // Opening a shared pane only adds a view of what the person just
633
+ // clicked, so it runs at once.
601
634
  void openShareInApp(action.id, options.pluginRegistry, { retry: () => handleDesktopDeepLink(rawUrl, options) });
602
635
  return;
603
636
  case "open-layout":
604
- void handleOpenLayout(action, options).catch((error) => {
605
- notifyError(options.pluginRegistry, error instanceof Error ? error.message : "Could not open shared layout.");
637
+ askBeforeRunning(options.pluginRegistry, "Add the shared layout this link points to?", "Add layout", () => {
638
+ void handleOpenLayout(action, options).catch((error) => {
639
+ notifyError(options.pluginRegistry, error instanceof Error ? error.message : "Could not open shared layout.");
640
+ });
606
641
  });
607
642
  return;
608
643
  }
@@ -156,7 +156,7 @@ function StarPromptLine({ delayMs = STAR_PROMPT_DELAY_MS, visibleMs = STAR_PROMP
156
156
 
157
157
  const showing = phase === "showing" && fits;
158
158
  useEffect(() => (showing ? bindStarPromptKeys({ open, dismiss }) : undefined), [dismiss, open, showing]);
159
- // The version chip gives way to the line.
159
+ // The connection note gives way to the line.
160
160
  useStatusWidgetClaim("star-prompt", showing && copy ? copy.columns : 0);
161
161
 
162
162
  if (!showing || !copy) return null;
package/src/app.tsx CHANGED
@@ -534,13 +534,7 @@ function AppInner({
534
534
  desktopDockPreview={desktopDockPreview}
535
535
  commandBarNativeOccluder={commandBarNativeOccluder}
536
536
  />
537
- <StatusBar
538
- onOpenChangelog={(version) => {
539
- void pluginRegistry.createPaneFromTemplateAsync("changelog-pane", {
540
- values: { version },
541
- }).catch(() => {});
542
- }}
543
- />
537
+ <StatusBar />
544
538
  </TransientLayoutProvider>
545
539
  {!onboardingActive ? <CompanyPickerHost pluginRegistry={pluginRegistry} /> : null}
546
540
  {initialized && !onboardingActive && !signInGateActive ? <AttentionCountsNotice notify={notifyRequest} /> : null}
@@ -21,14 +21,6 @@
21
21
  "why": "Registry plugin (gloomberb-crypto-fear-greed): the gauge's figure, as above."
22
22
  }
23
23
  ],
24
- "CHAT": [
25
- {
26
- "measure": "inset",
27
- "value": 7.2,
28
- "component": "PaneSidebarRow",
29
- "why": "Chat has its own owner: its channel rows start 7px in (reported, not changed)."
30
- }
31
- ],
32
24
  "FXMD_REST_HEALTH": [
33
25
  {
34
26
  "measure": "inset",
@@ -7,7 +7,7 @@ import {
7
7
  } from "../../utils/fundamentals";
8
8
  import { latestFinancialPeriod } from "../../utils/latest-financial-period";
9
9
  import { burnsCash, cashRunway, SHORT_RUNWAY_HISTORY, formatRunwayMonths, offeringNote, offeringsAfter, runwayMethod, type CashRunway, type OfferingFiling, type RunwayEstimate } from "../../utils/cash-runway";
10
- import { exportedFundamentals, formatPriceEarnings, NOT_MEANINGFUL, priceEarningsOnEarnings } from "../../utils/price-earnings";
10
+ import { exportedFundamentals, formatPriceEarnings, forwardFiscalYear, NOT_MEANINGFUL, priceEarningsOnEarnings } from "../../utils/price-earnings";
11
11
  import { describeFundamentalMarketCap, marketCapBasisNote, selectMarketCapitalization, viewMarketCapitalization, withheldMarketCap } from "../../utils/market-capitalization";
12
12
  import {
13
13
  formatCompact,
@@ -16,6 +16,7 @@ import {
16
16
  formatNumber,
17
17
  formatPercent,
18
18
  formatPercentRaw,
19
+ MISSING_VALUE,
19
20
  } from "../../utils/format";
20
21
  import { formatMarketCostWithCurrency, formatMarketPriceWithCurrency, formatMarketQuantity, quoteFormatOptions, withCurrencyMinorDigits, type MarketFormatOptions } from "../../market-data/market/format";
21
22
  import {
@@ -761,7 +762,11 @@ function fundamentalsMetrics(
761
762
  { label: "Enterprise Value", ...enterpriseValueFigure(enterpriseValue, fundamentals) },
762
763
  // A multiple over a loss is N/M, even beside a positive one the source served from an older period.
763
764
  { label: "P/E (TTM)", ...multipleFigure(priceEarningsOnEarnings(fundamentals?.trailingPE, fundamentals?.eps)) },
764
- { label: "Forward P/E", ...multipleFigure(priceEarningsOnEarnings(fundamentals?.forwardPE, fundamentals?.forwardEps)) },
765
+ // Next fiscal year's consensus, named by its year: `Forward P/E FY27`.
766
+ {
767
+ label: forwardLabel(fundamentals),
768
+ ...multipleFigure(priceEarningsOnEarnings(fundamentals?.forwardPE, fundamentals?.forwardEps)),
769
+ },
765
770
  { label: "PEG", ...multipleFigure(fundamentals?.pegRatio) },
766
771
  // EPS (TTM) is the last four filed quarters' (filed-trailing-eps), so its twelve months can end before those of
767
772
  // the flows below, Gloom Cloud's trailing block; Gloom Cloud's EPS standing in is noted (trailingEpsSourceNote).
@@ -828,8 +833,16 @@ function floatAndShortInterestMetrics(
828
833
  const STOCK_ONLY_METRICS = new Set(["Enterprise Value", "P/E (TTM)", "Forward P/E", "PEG", "EPS (TTM)", "Revenue (TTM)", "Net Income (TTM)",
829
834
  "Operating Cash Flow (TTM)", "Free Cash Flow (TTM)", "Operating Margin", "Profit Margin", "Revenue Growth", "Last Quarter Growth"]);
830
835
 
836
+ function forwardLabel(fundamentals: TickerFinancials["fundamentals"]): string {
837
+ const year = forwardFiscalYear(fundamentals?.forwardEpsPeriodEnd);
838
+ return year ? `Forward P/E ${year}` : "Forward P/E";
839
+ }
840
+
841
+ /** A line's name without the fiscal year a forward figure names: `Forward P/E FY27` is Forward P/E. */
842
+ const metricName = (label: string) => label.replace(/ FY\d{2}$/, "");
843
+
831
844
  function withoutStockRows<T extends { label: string }>(metrics: T[], fund: boolean): T[] {
832
- return fund ? metrics.filter((metric) => !STOCK_ONLY_METRICS.has(metric.label)) : metrics;
845
+ return fund ? metrics.filter((metric) => !STOCK_ONLY_METRICS.has(metricName(metric.label))) : metrics;
833
846
  }
834
847
 
835
848
  function metricLines(metrics: readonly FundamentalsMetric[]): Array<[string, string]> {
@@ -989,7 +1002,7 @@ function fundamentalsReportMetrics(snapshot: FundamentalsReportData, view: "fund
989
1002
  return [...metrics, ...floatAndShortInterestMetrics(quote, fundamentals, financials.profile)]
990
1003
  .filter((metric) => metric.text !== "—");
991
1004
  }
992
- const valued = metrics.filter(({ label, text }) => (VALUATION_METRICS.has(label) || isYieldMetric(label)) && text !== "—");
1005
+ const valued = metrics.filter(({ label, text }) => (VALUATION_METRICS.has(metricName(label)) || isYieldMetric(label)) && text !== MISSING_VALUE);
993
1006
  // The share count follows the market cap it is the basis of.
994
1007
  const isShares = (label: string) => label === "Shares Outstanding" || label === "Shares Outstanding As Of";
995
1008
  const shares = valued.filter((metric) => isShares(metric.label));
@@ -15,6 +15,12 @@ import { logFailure } from "../utils/log-failure";
15
15
  * where other accounts could read it. Bun cannot hand a browser those pipes
16
16
  * on Windows yet, so there the browser listens on a local port for its
17
17
  * DevTools, as before, and is still told the page over the protocol.
18
+ *
19
+ * Chrome keeps its sandbox, which holds a page that goes wrong inside its
20
+ * renderer. It runs without one only where Chrome cannot have it: as root
21
+ * on Linux, which Chrome refuses, or on a Linux machine whose kernel does not
22
+ * let it build one (some containers), where Chrome says so as it fails to
23
+ * start and the capture starts it again without.
18
24
  */
19
25
 
20
26
  /** A DevTools command sent to the capture's page, and its result. */
@@ -142,7 +148,6 @@ const CHROME_ARGS = [
142
148
  // Software WebGL for GPU-drawn panes (the 3D volatility surface).
143
149
  "--use-angle=swiftshader",
144
150
  "--enable-unsafe-swiftshader",
145
- "--no-sandbox",
146
151
  "--disable-dev-shm-usage",
147
152
  "--disable-background-networking",
148
153
  "--disable-default-apps",
@@ -154,15 +159,44 @@ const CHROME_ARGS = [
154
159
  "--allow-file-access-from-files",
155
160
  ];
156
161
 
162
+ const NO_SANDBOX = "--no-sandbox";
163
+ /** What Chrome prints when it cannot start with its sandbox: run as root, or no kernel support for one. */
164
+ const SANDBOX_REFUSED = /No usable sandbox|Running as root without --no-sandbox/;
165
+ /** How much of Chrome's stderr a failed start keeps to tell why. */
166
+ const STDERR_KEPT_BYTES = 16_384;
167
+
168
+ /** Whether Chrome starts without its sandbox from the outset: as root on Linux, where it refuses one. */
169
+ export function startsWithoutSandbox(platform: NodeJS.Platform, uid: number | undefined): boolean {
170
+ return platform === "linux" && uid === 0;
171
+ }
172
+
173
+ /** Whether a Chrome that failed to start said it was for want of its sandbox. */
174
+ export function chromeSandboxRefused(stderr: string): boolean {
175
+ return SANDBOX_REFUSED.test(stderr);
176
+ }
177
+
157
178
  interface LaunchedChrome {
158
179
  connection: CdpConnection;
159
180
  stop(): Promise<void>;
181
+ /** The start of what the browser wrote to stderr, once it has exited. */
182
+ stderr(): Promise<string>;
160
183
  }
161
184
 
162
185
  /** Chrome with DevTools on fds 3 (to the browser) and 4 (from it): messages are JSON, each ended by a NUL. */
163
186
  function launchOverPipe(chrome: string, args: string[]): LaunchedChrome {
164
187
  const child = spawn(chrome, [...args, "--remote-debugging-pipe", "about:blank"], {
165
- stdio: ["ignore", "ignore", "ignore", "pipe", "pipe"],
188
+ stdio: ["ignore", "ignore", "pipe", "pipe", "pipe"],
189
+ });
190
+ // Read to the end, so a chatty browser never blocks on a full pipe; only the start is kept.
191
+ let stderrText = "";
192
+ const fromStderr = child.stderr!;
193
+ fromStderr.setEncoding("utf8");
194
+ fromStderr.on("data", (chunk: string) => {
195
+ if (stderrText.length < STDERR_KEPT_BYTES) stderrText += chunk.slice(0, STDERR_KEPT_BYTES - stderrText.length);
196
+ });
197
+ const stderrDone = new Promise<void>((resolve) => {
198
+ fromStderr.once("close", () => resolve());
199
+ fromStderr.once("error", () => resolve());
166
200
  });
167
201
  const toChrome = child.stdio[3] as Writable;
168
202
  const fromChrome = child.stdio[4] as Readable;
@@ -197,6 +231,11 @@ function launchOverPipe(chrome: string, args: string[]): LaunchedChrome {
197
231
  await exited;
198
232
  clearTimeout(timer);
199
233
  },
234
+ stderr: async () => {
235
+ await exited;
236
+ await Promise.race([stderrDone, new Promise((resolve) => setTimeout(resolve, 1_000))]);
237
+ return stderrText;
238
+ },
200
239
  };
201
240
  }
202
241
 
@@ -228,6 +267,8 @@ async function launchOverPort(chrome: string, args: string[], userDataDir: strin
228
267
  socket.close();
229
268
  await stop();
230
269
  },
270
+ // Windows gives Chrome its sandbox without kernel support to miss.
271
+ stderr: async () => "",
231
272
  };
232
273
  } catch (error) {
233
274
  await stop();
@@ -258,6 +299,8 @@ async function messageText(data: unknown): Promise<string> {
258
299
  return String(data);
259
300
  }
260
301
 
302
+ class ChromeSandboxRefusedError extends Error {}
303
+
261
304
  /**
262
305
  * Starts the capture browser with one blank page of `widthPx` by `heightPx`,
263
306
  * its profile in `userDataDir`. Nothing is loaded until `open`.
@@ -268,13 +311,36 @@ export async function launchShotBrowser(
268
311
  ): Promise<ShotBrowser> {
269
312
  await mkdir(options.userDataDir, { recursive: true });
270
313
  const args = [...CHROME_ARGS, `--user-data-dir=${options.userDataDir}`, `--window-size=${options.widthPx},${options.heightPx}`];
314
+ if (startsWithoutSandbox(process.platform, process.getuid?.())) return startShotBrowser(chrome, [...args, NO_SANDBOX], options);
315
+ try {
316
+ return await startShotBrowser(chrome, args, options);
317
+ } catch (error) {
318
+ if (!(error instanceof ChromeSandboxRefusedError)) throw error;
319
+ logFailure("cli.screenshot", "Chrome has no sandbox on this machine; capturing without it")(error);
320
+ return startShotBrowser(chrome, [...args, NO_SANDBOX], options);
321
+ }
322
+ }
323
+
324
+ async function startShotBrowser(
325
+ chrome: string,
326
+ args: string[],
327
+ options: { userDataDir: string },
328
+ ): Promise<ShotBrowser> {
271
329
  const launched = process.platform === "win32"
272
330
  ? await launchOverPort(chrome, args, options.userDataDir)
273
331
  : launchOverPipe(chrome, args);
274
332
  const { connection } = launched;
275
333
  try {
276
334
  // The first answer waits for the browser to start.
277
- await connection.send("Browser.getVersion", undefined, undefined, CHROME_START_TIMEOUT_MS);
335
+ try {
336
+ await connection.send("Browser.getVersion", undefined, undefined, CHROME_START_TIMEOUT_MS);
337
+ } catch (error) {
338
+ await launched.stop();
339
+ if (!args.includes(NO_SANDBOX) && chromeSandboxRefused(await launched.stderr())) {
340
+ throw new ChromeSandboxRefusedError("Chrome could not start with its sandbox.", { cause: error });
341
+ }
342
+ throw error;
343
+ }
278
344
  const { targetId } = await connection.send("Target.createTarget", { url: "about:blank" }) as { targetId: string };
279
345
  const { sessionId } = await connection.send("Target.attachToTarget", { targetId, flatten: true }) as { sessionId: string };
280
346
  const page: CdpPage = { send: (method, params) => connection.send(method, params, sessionId) };
@@ -735,7 +735,9 @@ function renderCatalogEntry(entry: PaneCatalogEntry): string {
735
735
  lines.push(...wrapCommandLine(`gloom fn ${invocation}`, width));
736
736
  for (const example of entry.argExamples ?? []) lines.push(...wrapCommandLine(`gloom fn ${entry.token} ${example}`, width));
737
737
  for (const option of capability.options) {
738
- if (option.example) lines.push(...wrapCommandLine(`gloom fn ${option.exampleWithoutArgument ? entry.token : invocation} ${option.example}`, width));
738
+ for (const example of [option.example, ...(option.examples ?? [])]) {
739
+ if (example) lines.push(...wrapCommandLine(`gloom fn ${option.exampleWithoutArgument ? entry.token : invocation} ${example}`, width));
740
+ }
739
741
  }
740
742
  }
741
743
  const shotInvocation = entry.shotArgument ? `${entry.token} ${entry.shotArgument}` : invocation;
@@ -10,6 +10,7 @@ import type { PaneHint } from "../../layout/pane/footer/model";
10
10
  import type { ContextMenuItem } from "../../../types/context-menu";
11
11
  import type { ResolvedSeries } from "../../../time-series/types";
12
12
  import { isPlainKey } from "../../../utils/keyboard";
13
+ import { keepEscapeFromClosing } from "../../../utils/double-escape-close";
13
14
  import { nextDrawingId, nextLevelId } from "./drawing-store";
14
15
  import { CHART_TOOL_MENU, KEYBOARD_TOOL_HINTS, ARMED_TOOL_BY_INTERACTION } from "./tool-catalog";
15
16
  import {
@@ -460,14 +461,21 @@ export function useCompositeChartKeyboard({
460
461
  };
461
462
  if (timePick && scene && isPlainKey(event, "return", "enter", "escape")) {
462
463
  consume();
463
- if (event.name === "escape") timePick.onCancel();
464
+ // A pick, like a placement below, is unfinished input: ending it is no half of a close.
465
+ if (event.name === "escape") {
466
+ keepEscapeFromClosing(event);
467
+ timePick.onCancel();
468
+ }
464
469
  else chartActionsRef.current.pick();
465
470
  return;
466
471
  }
467
472
  // Esc ends a price pick even with nothing drawn yet; Enter needs a price at the cursor.
468
473
  if (pricePick && (scene || isPlainKey(event, "escape")) && isPlainKey(event, "return", "enter", "escape")) {
469
474
  consume();
470
- if (event.name === "escape") pricePick.onCancel();
475
+ if (event.name === "escape") {
476
+ keepEscapeFromClosing(event);
477
+ pricePick.onCancel();
478
+ }
471
479
  else chartActionsRef.current.pickPrice();
472
480
  return;
473
481
  }
@@ -512,6 +520,7 @@ export function useCompositeChartKeyboard({
512
520
  }
513
521
  if (keyboardPlacement && (isPlainKey(event, "escape") || isPlainKey(event, "backspace"))) {
514
522
  consume();
523
+ keepEscapeFromClosing(event);
515
524
  setKeyboardPlacement(null);
516
525
  return;
517
526
  }
@@ -1,5 +1,6 @@
1
1
  import type { DataTableCell, DataTableColumn, DataTableProps } from "../ui";
2
2
  import { serializeCsv } from "../../utils/csv";
3
+ import { figureColumnCells } from "../ui/data-table/render-cell";
3
4
  import {
4
5
  BLANK_DISPLAY as BLANK,
5
6
  DISPLAY_PLACEHOLDER as PLACEHOLDER,
@@ -56,9 +57,11 @@ export function createDataTableCsv<
56
57
  renderSectionHeader,
57
58
  getExportMetadata,
58
59
  }: Pick<DataTableProps<T, C>, "columns" | "items" | "renderCell" | "renderSectionHeader" | "getExportMetadata">): string {
60
+ // A pane that exports a table it does not draw (all its columns) reads the figures as the table draws them.
61
+ const cell = figureColumnCells(renderCell);
59
62
  const cells = items.flatMap((item, index) => {
60
63
  if (renderSectionHeader?.(item, index)) return [];
61
- return [columns.map((column) => renderCell(item, column, index, { selected: false }))];
64
+ return [columns.map((column) => cell(item, column, index, { selected: false }))];
62
65
  });
63
66
  // A column drawn only as graphics (a bar, a sparkline) has no value to export.
64
67
  const exported = columns.flatMap((column, index) => (