gloomberb 0.20.0 → 0.20.1
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 +1 -1
- package/patches/electrobun-devkit@2.0.5.patch +268 -8
- package/src/api-client/crypto-markets.ts +20 -2
- package/src/api-client/fund-facts.ts +23 -1
- package/src/api-client/types/filings-and-calls.ts +6 -0
- package/src/app/runtime/plugin-seed.ts +119 -0
- package/src/app/runtime/startup.ts +45 -9
- package/src/app.tsx +1 -0
- package/src/cli/board-coins.ts +38 -5
- package/src/cli/commands/crypto-hints.ts +8 -1
- package/src/cli/commands/market.ts +29 -26
- package/src/cli/commands/overview.ts +13 -6
- package/src/cli/commands/ticker.ts +61 -14
- package/src/cli/company-name-hint.ts +19 -0
- package/src/cli/entry.ts +10 -4
- package/src/cli/glossary.ts +25 -0
- package/src/cli/helpers.ts +4 -2
- package/src/cli/not-a-ticker.ts +26 -1
- package/src/cli/pane-functions/freshness.ts +45 -29
- package/src/cli/pane-functions/market-session.ts +14 -5
- package/src/cli/restore-plugins.ts +164 -51
- package/src/components/chart-table/header.tsx +10 -1
- package/src/components/chart-table/layout.ts +14 -5
- package/src/components/command-bar/panel/index.tsx +13 -0
- package/src/components/command-bar/panel/layout.ts +7 -0
- package/src/components/command-bar/panel/runtime.ts +1 -0
- package/src/components/command-bar/panel/types.ts +2 -0
- package/src/i18n/es.ts +3 -0
- package/src/i18n/ja.ts +3 -0
- package/src/i18n/ko.ts +3 -0
- package/src/i18n/zh-cn.ts +3 -0
- package/src/i18n/zh-tw.ts +3 -0
- package/src/market-data/fund-facts.ts +7 -1
- package/src/market-data/market/change-basis.ts +20 -0
- package/src/market-data/market/format.ts +62 -2
- package/src/market-data/market/futures-week.ts +3 -1
- package/src/plugins/builtin/chart-composer/headless.ts +57 -17
- package/src/plugins/builtin/chart-composer/session-range.ts +82 -3
- package/src/plugins/builtin/correlation/compute.ts +8 -2
- package/src/plugins/builtin/correlation/headless.ts +10 -9
- package/src/plugins/builtin/correlation/history.ts +30 -0
- package/src/plugins/builtin/correlation/matrix/model.ts +10 -10
- package/src/plugins/builtin/correlation/relationship/model.ts +3 -6
- package/src/plugins/builtin/correlation/relationship/pane.tsx +1 -2
- package/src/plugins/builtin/crypto-board/client.ts +6 -1
- package/src/plugins/builtin/crypto-board/defi-view.tsx +12 -1
- package/src/plugins/builtin/crypto-board/defi.ts +44 -7
- package/src/plugins/builtin/crypto-board/headless.ts +83 -12
- package/src/plugins/builtin/crypto-board/model.ts +30 -6
- package/src/plugins/builtin/crypto-board/pane.tsx +13 -2
- package/src/plugins/builtin/perps/headless.ts +8 -2
- package/src/plugins/builtin/risk-factors/index.tsx +2 -28
- package/src/plugins/builtin/risk-factors/lock-note.ts +58 -0
- package/src/plugins/builtin/risk-factors/pane.tsx +10 -3
- package/src/plugins/builtin/scanner/hilo-model.ts +4 -3
- package/src/plugins/builtin/sec/fund-facts.ts +45 -11
- package/src/plugins/builtin/sec/headless.ts +30 -1
- package/src/plugins/builtin/sec/index.tsx +26 -5
- package/src/plugins/builtin/shared/pro-lock-note.ts +5 -1
- package/src/plugins/builtin/ticker-detail/overview/model.ts +14 -6
- package/src/plugins/builtin/time-sales/headless.ts +23 -7
- package/src/plugins/builtin/time-sales/index.tsx +2 -2
- package/src/plugins/extracted-plugins.ts +49 -24
- package/src/plugins/installer.ts +220 -31
- package/src/plugins/running-installs.ts +34 -0
- package/src/plugins/seed-progress.ts +72 -0
- package/src/renderers/electrobun/bun/desktop/backend.ts +14 -0
- package/src/renderers/electrobun/bun/desktop/host-requests.ts +14 -7
- package/src/renderers/electrobun/bun/desktop/initialization.ts +24 -14
- package/src/renderers/electrobun/bun/index.ts +5 -0
- package/src/renderers/electrobun/bun/window/context-menu-thread.ts +84 -0
- package/src/renderers/electrobun/bun/window/native-call-thread.ts +224 -0
- package/src/renderers/electrobun/bun/window/native-timing.ts +10 -0
- package/src/renderers/electrobun/bun/window/script-for-webview.ts +15 -0
- package/src/renderers/electrobun/bun/window/webview-script-thread.ts +82 -0
- package/src/renderers/electrobun/shared/protocol.ts +13 -2
- package/src/renderers/electrobun/view/backend-rpc.ts +7 -0
- package/src/renderers/electrobun/view/cli-pane-shot-frame.tsx +1 -1
- package/src/renderers/electrobun/view/main.tsx +4 -3
- package/src/renderers/opentui/start.tsx +3 -0
- package/src/telemetry/stall-reports.ts +21 -4
- package/src/utils/main-thread-stall.ts +21 -5
- package/src/utils/perf-marks.ts +88 -9
- package/src/utils/reported-money.ts +9 -2
- package/src/utils/sec.ts +34 -3
- package/src/plugins/seed-notice.ts +0 -20
|
@@ -14,6 +14,7 @@ import type { TickerRecord } from "../../../types/ticker";
|
|
|
14
14
|
import type { ReleaseInfo, UpdateCheckResult, UpdateProgress } from "../../../updater";
|
|
15
15
|
import type { CapabilityManifest } from "../../../capabilities";
|
|
16
16
|
import type { PluginOperationResult, PluginPin } from "../../../plugins/marketplace/store";
|
|
17
|
+
import type { PluginSeedProgress } from "../../../plugins/seed-progress";
|
|
17
18
|
import type { RemoteControlRequest, RemoteControlResponse } from "../../../remote/types";
|
|
18
19
|
import type { HttpProxyRequestEnvelope, HttpProxyResponseEnvelope } from "../../../utils/http-proxy-response";
|
|
19
20
|
import type { StallEvent } from "../../../utils/main-thread-stall";
|
|
@@ -41,8 +42,12 @@ export interface ElectrobunBackendInit {
|
|
|
41
42
|
windows?: DesktopWindowInfo[];
|
|
42
43
|
/** The main window's: the tabs the other windows hold, for cloud sync. */
|
|
43
44
|
otherWindowTabs?: OtherWindowTab[];
|
|
44
|
-
/**
|
|
45
|
-
|
|
45
|
+
/**
|
|
46
|
+
* The main window's: the plugins the launch is restoring in the background,
|
|
47
|
+
* to bring into its session as they land and to say what could not be
|
|
48
|
+
* installed. Later changes arrive as `plugins.seedProgress`.
|
|
49
|
+
*/
|
|
50
|
+
pluginSeed?: PluginSeedProgress;
|
|
46
51
|
/** What the view needs to send crash reports and usage counts the same way the Bun process would. */
|
|
47
52
|
telemetry: ElectrobunTelemetryInit;
|
|
48
53
|
/** The copy on disk of the ids the view keeps in its own storage (view/view-ids.ts). */
|
|
@@ -377,6 +382,11 @@ interface PluginsUpdatedMessage {
|
|
|
377
382
|
directories: string[];
|
|
378
383
|
}
|
|
379
384
|
|
|
385
|
+
/** The launch's restore of plugins that moved into their own repositories, after a change. */
|
|
386
|
+
interface PluginSeedProgressMessage {
|
|
387
|
+
seed: PluginSeedProgress;
|
|
388
|
+
}
|
|
389
|
+
|
|
380
390
|
export interface RemoteControlRequestMessage {
|
|
381
391
|
request: RemoteControlRequest;
|
|
382
392
|
}
|
|
@@ -414,6 +424,7 @@ export interface ElectrobunDesktopRpcSchema {
|
|
|
414
424
|
"desktop.focusPane": DesktopFocusPaneMessage;
|
|
415
425
|
"desktop.windowVisibility": DesktopWindowVisibilityMessage;
|
|
416
426
|
"plugins.updated": PluginsUpdatedMessage;
|
|
427
|
+
"plugins.seedProgress": PluginSeedProgressMessage;
|
|
417
428
|
"update.progress": UpdateProgressMessage;
|
|
418
429
|
"capability.event": CapabilityEventMessage;
|
|
419
430
|
"http.stream.chunk": HttpStreamChunkMessage;
|
|
@@ -18,6 +18,7 @@ import { RpcTimeoutError } from "../../../utils/rpc-timeout-error";
|
|
|
18
18
|
import { nameRpcTimeout, RPC_MAX_REQUEST_TIME_MS } from "./rpc-timeout";
|
|
19
19
|
import type { RemoteControlRequest, RemoteControlResponse } from "../../../remote/types";
|
|
20
20
|
import type { StallEvent } from "../../../utils/main-thread-stall";
|
|
21
|
+
import { publishPluginSeedProgress } from "../../../plugins/seed-progress";
|
|
21
22
|
|
|
22
23
|
type BackendMessages = ElectrobunDesktopRpcSchema["webview"]["messages"];
|
|
23
24
|
type BackendMessageName = keyof BackendMessages;
|
|
@@ -108,6 +109,12 @@ const rpc = Electroview.defineRPC<ElectrobunDesktopRpcSchema>({
|
|
|
108
109
|
const directories = message.directories.filter((directory): directory is string => typeof directory === "string");
|
|
109
110
|
emit("plugins.updated", { directories });
|
|
110
111
|
},
|
|
112
|
+
// Kept, not handed to a listener: it can arrive before the app is up,
|
|
113
|
+
// and the app reads the latest whenever it looks.
|
|
114
|
+
"plugins.seedProgress": (message) => {
|
|
115
|
+
if (typeof message?.seed?.seq !== "number" || !Array.isArray(message.seed.plugins)) return;
|
|
116
|
+
publishPluginSeedProgress(message.seed);
|
|
117
|
+
},
|
|
111
118
|
"capability.event": (message) => {
|
|
112
119
|
emit("capability.event", {
|
|
113
120
|
subscriptionId: message.subscriptionId,
|
|
@@ -135,7 +135,7 @@ function useShotStatusLine(enabled: boolean, hasAsOf: () => boolean): ShotStatus
|
|
|
135
135
|
/**
|
|
136
136
|
* Static captures retain warnings, what a filter leaves out (`capture`) and
|
|
137
137
|
* optional source status without action shortcuts. With `statusLine` the footer also carries the capture's dated
|
|
138
|
-
* status line (`Fri 9 Oct close · 15 min delayed · markets closed
|
|
138
|
+
* status line (`Fri 9 Oct close · 15 min delayed · markets closed · regular session opens Mon 13:30 UTC, 09:30 ET`),
|
|
139
139
|
* inside the requested size: the body gives up the footer row for it. The
|
|
140
140
|
* pane's own text that says the same goes, so the date is said once: its `as
|
|
141
141
|
* of` (a footer segment or a query bar's) when the line dates the pane's data,
|
|
@@ -49,7 +49,7 @@ import { getMarketplaceHost, setPluginManager, type PluginManager } from "../../
|
|
|
49
49
|
import { remoteNotesFilesIO, setNotesFilesIO } from "../../../plugins/builtin/notes/files";
|
|
50
50
|
import { NOTES_FILES_CAPABILITY_ID } from "../../../capabilities";
|
|
51
51
|
import { loadOfficialPluginIds } from "../../../plugins/marketplace/feed";
|
|
52
|
-
import {
|
|
52
|
+
import { publishPluginSeedProgress } from "../../../plugins/seed-progress";
|
|
53
53
|
import { crashReportsEnabled, installCrashReporter, reportCrash } from "../../../telemetry/crash-reports";
|
|
54
54
|
import { browserDoNotTrack, installWindowCrashListeners } from "../../../telemetry/crash-reports-dom";
|
|
55
55
|
import { forwardAttendedStalls } from "../../../telemetry/stall-reports-dom";
|
|
@@ -183,8 +183,9 @@ async function boot() {
|
|
|
183
183
|
: init.desktopSnapshot;
|
|
184
184
|
const config = desktopSnapshot?.config ?? init.config;
|
|
185
185
|
applyLanguageFromConfig(config);
|
|
186
|
-
//
|
|
187
|
-
|
|
186
|
+
// The plugins the launch is restoring, which the app brings in as they
|
|
187
|
+
// land, as the terminal does; later changes come as messages.
|
|
188
|
+
if (init.pluginSeed) publishPluginSeedProgress(init.pluginSeed);
|
|
188
189
|
const desktopWindowBridge = createDesktopWindowBridge(init.windowKind, init.paneId);
|
|
189
190
|
// Menus and the command bar offer the other windows from here.
|
|
190
191
|
setDesktopWindows(desktopWindowBridge.windows ?? null);
|
|
@@ -12,6 +12,7 @@ import { startNodePluginAutoUpdates } from "../../plugins/auto-update-node";
|
|
|
12
12
|
import { activateUpdatedPlugins } from "../../plugins/marketplace/activation";
|
|
13
13
|
import { getMarketplaceHost, setPluginManager } from "../../plugins/marketplace/store";
|
|
14
14
|
import { createNodePluginManager } from "../../plugins/manager-node";
|
|
15
|
+
import { stopInstallCommands } from "../../plugins/running-installs";
|
|
15
16
|
import { setCurrentPluginTarget } from "../../plugins/current-target";
|
|
16
17
|
import { getLoadablePlugins } from "../../plugins/catalog";
|
|
17
18
|
import { OpenTuiInputHostProvider } from "./input-host";
|
|
@@ -104,6 +105,8 @@ export async function startOpenTuiApp({ externalPlugins, cliLaunchRequest }: Sta
|
|
|
104
105
|
let exitTimer: ReturnType<typeof setTimeout> | null = null;
|
|
105
106
|
const finishProcessExit = () => {
|
|
106
107
|
if (exitTimer) return;
|
|
108
|
+
// Plugin installs still running in the background end with the app.
|
|
109
|
+
stopInstallCommands();
|
|
107
110
|
exitTimer = setTimeout(() => {
|
|
108
111
|
void Promise.allSettled([
|
|
109
112
|
flushPendingPersistence(),
|
|
@@ -7,7 +7,8 @@ import { reportCrash } from "./crash-reports";
|
|
|
7
7
|
* Freezes, made visible outside the app's own Debug Log.
|
|
8
8
|
*
|
|
9
9
|
* The stall monitor (utils/main-thread-stall.ts) notices when a process could
|
|
10
|
-
* not answer the user for a while and names the
|
|
10
|
+
* not answer the user for a while and names the measured section that held
|
|
11
|
+
* it (or the last one before it), and
|
|
11
12
|
* hands the stall to its sink. The terminal app and the desktop app's Bun
|
|
12
13
|
* process record their own stalls here; the desktop window sends the stalls
|
|
13
14
|
* it had in front of the user (stall-reports-dom.ts) to the Bun process,
|
|
@@ -24,7 +25,9 @@ import { reportCrash } from "./crash-reports";
|
|
|
24
25
|
*
|
|
25
26
|
* A report also says when in the process's life the stall came (still
|
|
26
27
|
* starting or up, and an uptime bucket), how long before it the named section
|
|
27
|
-
* ended (or that it ended inside it,
|
|
28
|
+
* ended (or that it ended inside it), what share of the stall that section
|
|
29
|
+
* itself ran (all of it: it froze the thread; little: it ran after a wait
|
|
30
|
+
* nothing measured), and,
|
|
28
31
|
* for the desktop app's own process, whether the app was in front and had a
|
|
29
32
|
* window on screen: a hidden app's slowed timers read like a freeze. A stall
|
|
30
33
|
* after a SQLite statement names the statement (a fixed name), its tries and
|
|
@@ -62,6 +65,11 @@ export interface StallReport {
|
|
|
62
65
|
uptime: UptimeBucket | "unknown";
|
|
63
66
|
/** How long before the stall began the section ended; "in" when it ended inside it. */
|
|
64
67
|
gap: GapBucket;
|
|
68
|
+
/**
|
|
69
|
+
* The share of the stall the section itself ran, in percent, by tens: 100
|
|
70
|
+
* when it froze the thread, near 0 when it only ran after an unmeasured wait.
|
|
71
|
+
*/
|
|
72
|
+
heldPercent?: number;
|
|
65
73
|
/** The desktop app's own process: whether the app was in front (null: not known yet). */
|
|
66
74
|
active?: boolean | null;
|
|
67
75
|
/** The desktop app's own process: whether a window was open and not minimized. */
|
|
@@ -184,13 +192,14 @@ function gapBucket(event: StallEvent): GapBucket {
|
|
|
184
192
|
/** A stall another process sent over, kept only when it has the right shape. */
|
|
185
193
|
export function parseStallEvent(value: unknown): StallEvent | null {
|
|
186
194
|
if (!value || typeof value !== "object") return null;
|
|
187
|
-
const { blockedMs, lastMeasured, lastMeasuredEndedMsAgo, sqlite, uptimeMs, phase } = value as Record<string, unknown>;
|
|
195
|
+
const { blockedMs, lastMeasured, lastMeasuredEndedMsAgo, lastMeasuredMs, sqlite, uptimeMs, phase } = value as Record<string, unknown>;
|
|
188
196
|
if (typeof blockedMs !== "number" || !Number.isFinite(blockedMs) || blockedMs <= 0) return null;
|
|
189
197
|
const detail = sqlite && typeof sqlite === "object" ? sqlite as Record<string, unknown> : null;
|
|
190
198
|
return {
|
|
191
199
|
blockedMs,
|
|
192
200
|
...(typeof lastMeasured === "string" && lastMeasured.length <= 200 ? { lastMeasured } : {}),
|
|
193
201
|
...(typeof lastMeasuredEndedMsAgo === "number" && Number.isFinite(lastMeasuredEndedMsAgo) ? { lastMeasuredEndedMsAgo } : {}),
|
|
202
|
+
...(typeof lastMeasuredMs === "number" && Number.isFinite(lastMeasuredMs) && lastMeasuredMs >= 0 ? { lastMeasuredMs } : {}),
|
|
194
203
|
...(detail && typeof detail.operation === "string" && detail.operation.length <= 80
|
|
195
204
|
&& typeof detail.attempts === "number" && Number.isFinite(detail.attempts)
|
|
196
205
|
? { sqlite: { operation: detail.operation, attempts: detail.attempts, lockWait: detail.lockWait === true } }
|
|
@@ -219,6 +228,7 @@ interface StallContext {
|
|
|
219
228
|
phase: StallReport["phase"];
|
|
220
229
|
uptime: StallReport["uptime"];
|
|
221
230
|
gap: GapBucket;
|
|
231
|
+
heldPercent?: number;
|
|
222
232
|
attention: StallAttention | null;
|
|
223
233
|
cpuPercent?: number;
|
|
224
234
|
otherCpuPercent?: number;
|
|
@@ -227,10 +237,14 @@ interface StallContext {
|
|
|
227
237
|
function stallContext(event: StallEvent, attention: StallAttention | null): StallContext {
|
|
228
238
|
const cpuPercent = tens(event.threadCpu, 100);
|
|
229
239
|
const otherCpuPercent = tens(event.otherCpu, MAX_OTHER_CPU_PERCENT);
|
|
240
|
+
const heldPercent = event.lastMeasured && event.lastMeasuredMs !== undefined
|
|
241
|
+
? tens(Math.min(1, event.lastMeasuredMs / event.blockedMs), 100)
|
|
242
|
+
: undefined;
|
|
230
243
|
return {
|
|
231
244
|
phase: event.phase ?? "unknown",
|
|
232
245
|
uptime: uptimeBucket(event.uptimeMs),
|
|
233
246
|
gap: gapBucket(event),
|
|
247
|
+
...(heldPercent === undefined ? {} : { heldPercent }),
|
|
234
248
|
attention,
|
|
235
249
|
...(cpuPercent === undefined ? {} : { cpuPercent }),
|
|
236
250
|
...(otherCpuPercent === undefined ? {} : { otherCpuPercent }),
|
|
@@ -241,7 +255,7 @@ function stallContext(event: StallEvent, attention: StallAttention | null): Stal
|
|
|
241
255
|
function formatStallLogLine(process: StallProcess, event: StallEvent, context: StallContext, at: number): string {
|
|
242
256
|
const time = new Date(at).toISOString().replace(/\.\d{3}Z$/, "Z");
|
|
243
257
|
const last = event.lastMeasured
|
|
244
|
-
? `last measured: ${event.lastMeasured}${event.lastMeasuredEndedMsAgo === undefined ? "" : `, ended ${Math.round(event.lastMeasuredEndedMsAgo)} ms before`}`
|
|
258
|
+
? `last measured: ${event.lastMeasured}${event.lastMeasuredMs === undefined ? "" : `, ran ${Math.round(event.lastMeasuredMs)} ms`}${event.lastMeasuredEndedMsAgo === undefined ? "" : `, ended ${Math.round(event.lastMeasuredEndedMsAgo)} ms before`}`
|
|
245
259
|
: "nothing measured before it";
|
|
246
260
|
const sqlite = event.sqlite
|
|
247
261
|
? ` (${event.sqlite.operation}, ${event.sqlite.attempts} ${event.sqlite.attempts === 1 ? "try" : "tries"}${event.sqlite.lockWait ? ", waited on a lock" : ""})`
|
|
@@ -250,6 +264,7 @@ function formatStallLogLine(process: StallProcess, event: StallEvent, context: S
|
|
|
250
264
|
`phase=${context.phase}`,
|
|
251
265
|
`up=${context.uptime}`,
|
|
252
266
|
`gap=${context.gap}`,
|
|
267
|
+
...(context.heldPercent === undefined ? [] : [`held=${context.heldPercent}`]),
|
|
253
268
|
...(context.attention ? [`fg=${flag(context.attention.active)}`, `vis=${flag(context.attention.visible)}`] : []),
|
|
254
269
|
...(context.cpuPercent === undefined ? [] : [`cpu=${context.cpuPercent}`]),
|
|
255
270
|
...(context.otherCpuPercent === undefined ? [] : [`oth=${context.otherCpuPercent}`]),
|
|
@@ -281,6 +296,7 @@ export function formatStallReportDetails(report: StallReport): string {
|
|
|
281
296
|
`phase=${report.phase}`,
|
|
282
297
|
`up=${report.uptime}`,
|
|
283
298
|
`gap=${report.gap}`,
|
|
299
|
+
...(report.heldPercent === undefined ? [] : [`held=${report.heldPercent}`]),
|
|
284
300
|
...(report.active === undefined ? [] : [`fg=${flag(report.active)}`]),
|
|
285
301
|
...(report.visible === undefined ? [] : [`vis=${flag(report.visible)}`]),
|
|
286
302
|
...(report.cpuPercent === undefined ? [] : [`cpu=${report.cpuPercent}`]),
|
|
@@ -383,6 +399,7 @@ export function recordStall(process: StallProcess, event: StallEvent): void {
|
|
|
383
399
|
phase: context.phase,
|
|
384
400
|
uptime: context.uptime,
|
|
385
401
|
gap: context.gap,
|
|
402
|
+
...(context.heldPercent === undefined ? {} : { heldPercent: context.heldPercent }),
|
|
386
403
|
...(context.attention ? { active: context.attention.active, visible: context.attention.visible } : {}),
|
|
387
404
|
...(context.cpuPercent === undefined ? {} : { cpuPercent: context.cpuPercent }),
|
|
388
405
|
...(context.otherCpuPercent === undefined ? {} : { otherCpuPercent: context.otherCpuPercent }),
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { lastPerfSample, recordPerfSample, withoutLastStep } from "./perf-marks";
|
|
1
|
+
import { lastPerfSample, recordPerfSample, takeHeldPerfSample, takePersonWaitMs, withoutLastStep } from "./perf-marks";
|
|
2
2
|
|
|
3
3
|
/** How often the monitor checks in. Short enough to date a stall precisely. */
|
|
4
4
|
const SAMPLE_INTERVAL_MS = 250;
|
|
@@ -34,10 +34,19 @@ export interface StallClockReading {
|
|
|
34
34
|
export interface StallEvent {
|
|
35
35
|
/** How long the thread could not run while the computer was awake. */
|
|
36
36
|
blockedMs: number;
|
|
37
|
-
/**
|
|
37
|
+
/**
|
|
38
|
+
* The measured section that held the thread longest during the stall
|
|
39
|
+
* (perf-marks); the last one before it when none ended inside it.
|
|
40
|
+
*/
|
|
38
41
|
lastMeasured?: string;
|
|
39
42
|
/** How long before the stall was noticed that section ended. */
|
|
40
43
|
lastMeasuredEndedMsAgo?: number;
|
|
44
|
+
/**
|
|
45
|
+
* How long that section itself ran, when it ended inside the stall: near
|
|
46
|
+
* the stall's length it froze the thread, far below it ran in what queued
|
|
47
|
+
* up behind an unmeasured wait.
|
|
48
|
+
*/
|
|
49
|
+
lastMeasuredMs?: number;
|
|
41
50
|
/** When that section was a SQLite statement that held the thread. */
|
|
42
51
|
sqlite?: StallSqliteDetail;
|
|
43
52
|
/** How long the process had been running when the stall was noticed. */
|
|
@@ -147,7 +156,8 @@ function defaultNow(): number {
|
|
|
147
156
|
* Names the freezes. A timer that should fire every quarter second is a
|
|
148
157
|
* witness to everything that blocks the main thread, measured or not: when it
|
|
149
158
|
* comes back late, the app was unresponsive for exactly that long. The report
|
|
150
|
-
* carries the
|
|
159
|
+
* carries the measured section that held the thread longest in that time (or
|
|
160
|
+
* the last one before it), how long it ran and how long before the stall it ended,
|
|
151
161
|
* which is usually enough to tell "the cache read did it" from "the render
|
|
152
162
|
* did it" in a report that only says the app hung for a few seconds, and how
|
|
153
163
|
* long the process had been up, so a slow start reads apart from a hang
|
|
@@ -184,12 +194,17 @@ export function startMainThreadStallMonitor(
|
|
|
184
194
|
const before = previousClocks;
|
|
185
195
|
previous = current;
|
|
186
196
|
previousClocks = currentClocks;
|
|
197
|
+
// Taken on every tick, so a stall weighs only the steps that ended inside it.
|
|
198
|
+
const held = takeHeldPerfSample();
|
|
199
|
+
const personWaitMs = takePersonWaitMs();
|
|
187
200
|
const awakeMs = delta(currentClocks?.awakeMs, before?.awakeMs);
|
|
188
201
|
// Asleep, the computer runs nothing; only the awake part of the gap was a freeze.
|
|
189
202
|
const asleepMs = awakeMs == null ? 0 : Math.max(0, elapsedMs - awakeMs);
|
|
190
|
-
|
|
203
|
+
// A menu held open on the thread waited for the person, not the computer:
|
|
204
|
+
// only the rest of the gap was a freeze.
|
|
205
|
+
const blockedMs = elapsedMs - asleepMs - intervalMs - personWaitMs;
|
|
191
206
|
if (blockedMs < thresholdMs) return;
|
|
192
|
-
const sample = lastPerfSample();
|
|
207
|
+
const sample = held ?? lastPerfSample();
|
|
193
208
|
const sqlite = sample?.name === "sqlite.blocked" ? sqliteDetail(sample.metadata) : undefined;
|
|
194
209
|
const threadCpuMs = delta(currentClocks?.threadCpuMs, before?.threadCpuMs);
|
|
195
210
|
const processCpuMs = delta(currentClocks?.processCpuMs, before?.processCpuMs);
|
|
@@ -197,6 +212,7 @@ export function startMainThreadStallMonitor(
|
|
|
197
212
|
...(sample
|
|
198
213
|
? { lastMeasured: sample.name, lastMeasuredEndedMsAgo: Math.round(current - sample.endedAt) }
|
|
199
214
|
: {}),
|
|
215
|
+
...(held ? { lastMeasuredMs: Math.round(held.durationMs) } : {}),
|
|
200
216
|
...(sqlite ? { sqlite } : {}),
|
|
201
217
|
uptimeMs: Math.round(current),
|
|
202
218
|
phase: startupComplete ? "steady" : "startup",
|
package/src/utils/perf-marks.ts
CHANGED
|
@@ -29,6 +29,15 @@ let lastSampleDurationMs = 0;
|
|
|
29
29
|
let lastSampleMetadata: Record<string, unknown> | undefined;
|
|
30
30
|
/** Inside `withoutLastStep`: samples are logged, and none becomes the last step. */
|
|
31
31
|
let quietDepth = 0;
|
|
32
|
+
// The step that held the thread longest since the stall monitor last looked.
|
|
33
|
+
let heldName: string | null = null;
|
|
34
|
+
let heldEndedAt = 0;
|
|
35
|
+
let heldDurationMs = 0;
|
|
36
|
+
let heldMetadata: Record<string, unknown> | undefined;
|
|
37
|
+
// Time the thread spent waiting on a person (a menu held open on it): all
|
|
38
|
+
// told, and since the stall monitor last looked.
|
|
39
|
+
let personWaitTotalMs = 0;
|
|
40
|
+
let personWaitUntakenMs = 0;
|
|
32
41
|
|
|
33
42
|
/**
|
|
34
43
|
* The most recent measured section, when it ended and what it was measured
|
|
@@ -51,18 +60,78 @@ function lastStepAccountsForSection(startedAt: number, durationMs: number): bool
|
|
|
51
60
|
return lastSampleName != null && lastSampleEndedAt >= startedAt && lastSampleDurationMs * 2 >= durationMs;
|
|
52
61
|
}
|
|
53
62
|
|
|
63
|
+
/**
|
|
64
|
+
* Keeps the step that held the thread longest since the stall monitor last
|
|
65
|
+
* looked (`takeHeldPerfSample`). After a freeze the thread first runs what
|
|
66
|
+
* queued up behind it, so the last step before the monitor's late timer is
|
|
67
|
+
* rarely what froze it. A step inside a section that took at least half of
|
|
68
|
+
* it stands for the section, as it does for the last step.
|
|
69
|
+
*/
|
|
70
|
+
function noteHeldStep(
|
|
71
|
+
name: string,
|
|
72
|
+
startedAt: number,
|
|
73
|
+
endedAt: number,
|
|
74
|
+
durationMs: number,
|
|
75
|
+
metadata: Record<string, unknown> | undefined,
|
|
76
|
+
): void {
|
|
77
|
+
if (heldName != null) {
|
|
78
|
+
const inside = heldEndedAt >= startedAt;
|
|
79
|
+
if (inside ? heldDurationMs * 2 >= durationMs : heldDurationMs >= durationMs) return;
|
|
80
|
+
}
|
|
81
|
+
heldName = name;
|
|
82
|
+
heldEndedAt = endedAt;
|
|
83
|
+
heldDurationMs = durationMs;
|
|
84
|
+
heldMetadata = metadata;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* The step that held the thread longest since the last call, and forgets it:
|
|
89
|
+
* the stall monitor asks on every tick, so a stall only weighs the steps that
|
|
90
|
+
* ended inside it. Only steps that ran on the thread throughout count, not an
|
|
91
|
+
* awaited one's time, and not the time a step waited on a person.
|
|
92
|
+
*/
|
|
93
|
+
export function takeHeldPerfSample(): { name: string; endedAt: number; durationMs: number; metadata?: Record<string, unknown> } | null {
|
|
94
|
+
if (heldName == null) return null;
|
|
95
|
+
const held = { name: heldName, endedAt: heldEndedAt, durationMs: heldDurationMs, ...(heldMetadata ? { metadata: heldMetadata } : {}) };
|
|
96
|
+
heldName = null;
|
|
97
|
+
heldMetadata = undefined;
|
|
98
|
+
return held;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function notePersonWait(ms: number): void {
|
|
102
|
+
if (!(ms > 0)) return;
|
|
103
|
+
personWaitTotalMs += ms;
|
|
104
|
+
personWaitUntakenMs += ms;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* How long the thread waited on a person (`waitedOnPerson`) since the last
|
|
109
|
+
* call, and forgets it: the stall monitor takes it out of a stall, which
|
|
110
|
+
* leaves only the freeze around it.
|
|
111
|
+
*/
|
|
112
|
+
export function takePersonWaitMs(): number {
|
|
113
|
+
const ms = personWaitUntakenMs;
|
|
114
|
+
personWaitUntakenMs = 0;
|
|
115
|
+
return ms;
|
|
116
|
+
}
|
|
117
|
+
|
|
54
118
|
function logSlowPerfSample(
|
|
55
119
|
name: string,
|
|
56
120
|
durationMs: number,
|
|
57
121
|
metadata?: Record<string, unknown>,
|
|
58
122
|
lastStep = true,
|
|
59
123
|
startedAt?: number,
|
|
124
|
+
heldMs: number | null = null,
|
|
60
125
|
): void {
|
|
61
|
-
if (lastStep && quietDepth === 0
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
126
|
+
if (lastStep && quietDepth === 0) {
|
|
127
|
+
const endedAt = now();
|
|
128
|
+
if (startedAt === undefined || !lastStepAccountsForSection(startedAt, durationMs)) {
|
|
129
|
+
lastSampleName = name;
|
|
130
|
+
lastSampleEndedAt = endedAt;
|
|
131
|
+
lastSampleDurationMs = durationMs;
|
|
132
|
+
lastSampleMetadata = metadata;
|
|
133
|
+
}
|
|
134
|
+
if (heldMs != null && heldMs > 0) noteHeldStep(name, startedAt ?? endedAt - durationMs, endedAt, heldMs, metadata);
|
|
66
135
|
}
|
|
67
136
|
const payload = {
|
|
68
137
|
durationMs: Math.round(durationMs * 10) / 10,
|
|
@@ -101,30 +170,40 @@ export function isPerfTraceEnabled(): boolean {
|
|
|
101
170
|
* A sample measured elsewhere (a React Profiler callback, for instance).
|
|
102
171
|
* `lastStep: false` logs it without making it the step a later stall names:
|
|
103
172
|
* the stall monitor's own samples, which measure no work.
|
|
173
|
+
* `waitedOnPerson`: the time went to a person's choice (a menu held open),
|
|
174
|
+
* which the stall monitor does not count as a freeze.
|
|
104
175
|
*/
|
|
105
176
|
export function recordPerfSample(
|
|
106
177
|
name: string,
|
|
107
178
|
durationMs: number,
|
|
108
179
|
metadata?: Record<string, unknown>,
|
|
109
|
-
options?: { lastStep?: boolean },
|
|
180
|
+
options?: { lastStep?: boolean; waitedOnPerson?: boolean },
|
|
110
181
|
): void {
|
|
111
|
-
|
|
182
|
+
if (options?.waitedOnPerson) notePersonWait(durationMs);
|
|
183
|
+
logSlowPerfSample(name, durationMs, metadata, options?.lastStep !== false, undefined, options?.waitedOnPerson ? null : durationMs);
|
|
112
184
|
}
|
|
113
185
|
|
|
114
186
|
/**
|
|
115
187
|
* Measures `fn`. A step measured inside it that took most of its time stays
|
|
116
|
-
* the step a stall names (`lastStepAccountsForSection`).
|
|
188
|
+
* the step a stall names (`lastStepAccountsForSection`). `waitedOnPerson` as
|
|
189
|
+
* for `recordPerfSample`.
|
|
117
190
|
*/
|
|
118
191
|
export function measurePerf<T>(
|
|
119
192
|
name: string,
|
|
120
193
|
fn: () => T,
|
|
121
194
|
metadata?: Record<string, unknown>,
|
|
195
|
+
options?: { waitedOnPerson?: boolean },
|
|
122
196
|
): T {
|
|
123
197
|
const start = now();
|
|
198
|
+
const personWaitBefore = personWaitTotalMs;
|
|
124
199
|
try {
|
|
125
200
|
return fn();
|
|
126
201
|
} finally {
|
|
127
|
-
|
|
202
|
+
const durationMs = now() - start;
|
|
203
|
+
// A person's wait inside it is not the thread's work.
|
|
204
|
+
const ownMs = Math.max(0, durationMs - (personWaitTotalMs - personWaitBefore));
|
|
205
|
+
if (options?.waitedOnPerson) notePersonWait(ownMs);
|
|
206
|
+
logSlowPerfSample(name, durationMs, metadata, true, start, options?.waitedOnPerson ? null : ownMs);
|
|
128
207
|
}
|
|
129
208
|
}
|
|
130
209
|
|
|
@@ -17,16 +17,23 @@ export function formatPerShareNumber(value: number | undefined): string {
|
|
|
17
17
|
return formatNumber(value === 0 ? 0 : value, perShareDecimals(value)).replace(/(\.\d{2}.*?)0+$/, "$1");
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
+
/**
|
|
21
|
+
* What a report says once, beside or under amounts whose currency no source
|
|
22
|
+
* names (formatReportedMoney leaves them bare): never a guess at one.
|
|
23
|
+
*/
|
|
24
|
+
export const REPORTING_CURRENCY_NOT_SOURCED = "reporting currency not sourced";
|
|
25
|
+
|
|
20
26
|
/**
|
|
21
27
|
* Keep reported monetary amounts in their own units, independently of a
|
|
22
28
|
* quote. A per-share amount reads with its sign ($6.54), or with `code` its
|
|
23
|
-
* code (6.54 USD) as every other amount does.
|
|
29
|
+
* code (6.54 USD) as every other amount does. With no currency the amount is
|
|
30
|
+
* bare, and the report says REPORTING_CURRENCY_NOT_SOURCED once for it.
|
|
24
31
|
*/
|
|
25
32
|
export function formatReportedMoney(value: number | undefined, currency?: string, perShare = false, code = false): string {
|
|
26
33
|
if (value == null || !Number.isFinite(value)) return "—";
|
|
27
34
|
const amount = perShare ? formatPerShareNumber(value) : formatCompact(value);
|
|
28
35
|
const unit = currency?.trim();
|
|
29
|
-
if (!unit) return
|
|
36
|
+
if (!unit) return amount;
|
|
30
37
|
// Intl uppercases currency codes: GBp must not become GBP without scaling.
|
|
31
38
|
if (perShare && !usesScientificNotation(value) && /^[a-z]{3}$/i.test(unit) && resolveCurrencyUnit(unit).divisor === 1) {
|
|
32
39
|
return (code ? formatCurrencyCode : formatCurrency)(value === 0 ? 0 : value, unit, perShareDecimals(value));
|
package/src/utils/sec.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { TickerRecord } from "../types/ticker";
|
|
2
2
|
import { tickerHasListingSuffix } from "../sources/listing-symbols";
|
|
3
|
-
import { canonicalExchange, exchangeLabel, parsePublicTickerKey, resolveExchangeTimeZone, US_LISTING_EXCHANGES } from "./exchanges";
|
|
3
|
+
import { canonicalExchange, exchangeLabel, parsePublicTickerKey, publicTickerKey, resolveExchangeTimeZone, US_LISTING_EXCHANGES } from "./exchanges";
|
|
4
4
|
import { shortListingTitle } from "../tickers/company-name";
|
|
5
5
|
|
|
6
6
|
/** Canonical US equity venues: the listing exchanges plus other lit and OTC venues. */
|
|
@@ -69,6 +69,17 @@ export function mayBeUsEquityOrFundTicker(ticker: TickerRecord | null | undefine
|
|
|
69
69
|
return mayBeUsListingOfType(ticker, (type) => isEquityType(type) || isFundType(type));
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
+
/**
|
|
73
|
+
* Whether the fund view (ETF) can open on the ticker: `mayBeUsEquityOrFundTicker`,
|
|
74
|
+
* or an equity or fund known to be listed abroad (3046.HK), which the view
|
|
75
|
+
* gives its issuer's figures where Gloom reads them, and its issuer's page
|
|
76
|
+
* otherwise. Before this `ETF 3046.HK` opened nothing.
|
|
77
|
+
*/
|
|
78
|
+
export function mayBeFundViewTicker(ticker: TickerRecord | null | undefined): boolean {
|
|
79
|
+
if (mayBeUsEquityOrFundTicker(ticker)) return true;
|
|
80
|
+
return isTickerOfType(ticker, (type) => isEquityType(type) || isFundType(type)) && isKnownNonUsListing(ticker);
|
|
81
|
+
}
|
|
82
|
+
|
|
72
83
|
function isTickerOfType(ticker: TickerRecord | null | undefined, acceptsType: (type?: string) => boolean): boolean {
|
|
73
84
|
if (!ticker) return false;
|
|
74
85
|
const primaryContract = ticker.metadata.broker_contracts?.[0];
|
|
@@ -141,8 +152,28 @@ export function listingAbroadVenue(key: string): string | null {
|
|
|
141
152
|
return venue && zone && zone !== "UTC" && !US_TIME_ZONES.has(zone) ? venue : null;
|
|
142
153
|
}
|
|
143
154
|
|
|
144
|
-
/** What `ticker` and ETF say of a fund listed abroad: the facts Gloom collects are the US-listed funds'. */
|
|
145
|
-
export const US_FUND_FACTS_ONLY = "Fund facts (fee, NAV, premium) cover US-listed funds only.";
|
|
155
|
+
/** What `ticker` and ETF say of a fund listed abroad: the facts Gloom collects are the US-listed funds' and Hong Kong's spot coin funds'. */
|
|
156
|
+
export const US_FUND_FACTS_ONLY = "Fund facts (fee, NAV, premium) cover US-listed funds and Hong Kong's spot bitcoin and ether ETFs only.";
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Whether a fund on this venue abroad can have facts: Hong Kong, whose spot
|
|
160
|
+
* bitcoin and ether ETFs Gloom reads from their issuers. The server says which
|
|
161
|
+
* of its funds are covered.
|
|
162
|
+
*/
|
|
163
|
+
export function hasFundFactsAbroad(exchange?: string | null): boolean {
|
|
164
|
+
return canonicalExchange(exchange ?? undefined) === "HKEX";
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* What fund facts are asked for by, for a fund on a venue abroad: a bare
|
|
169
|
+
* code with its venue's key (3046 on HKEX as 3046:XHKG), so the server reads
|
|
170
|
+
* it as that listing and not as a US ticker; a key or suffix that already
|
|
171
|
+
* names its venue (3046:HKEX, 3046.HK) as it is.
|
|
172
|
+
*/
|
|
173
|
+
export function fundFactsAbroadKey(symbol: string, exchange?: string | null): string {
|
|
174
|
+
if (parsePublicTickerKey(symbol).exchange || tickerHasListingSuffix(symbol)) return symbol;
|
|
175
|
+
return publicTickerKey(symbol, exchange ?? undefined);
|
|
176
|
+
}
|
|
146
177
|
|
|
147
178
|
/**
|
|
148
179
|
* The symbol data that covers US listings only reads a listing by: AAPL for
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import type { PluginSeedNotice } from "./extracted-plugins";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* What the launch's plugin seed could not install, said once the app is up.
|
|
5
|
-
* The seed runs before the app renders (in the terminal's process, or the
|
|
6
|
-
* desktop's Bun process, which hands it to its main window), so it leaves the
|
|
7
|
-
* notice here and the app takes it.
|
|
8
|
-
*/
|
|
9
|
-
let pending: PluginSeedNotice | null = null;
|
|
10
|
-
|
|
11
|
-
export function setPluginSeedNotice(notice: PluginSeedNotice | null): void {
|
|
12
|
-
pending = notice;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
/** The notice, once: a second call returns null. */
|
|
16
|
-
export function takePluginSeedNotice(): PluginSeedNotice | null {
|
|
17
|
-
const notice = pending;
|
|
18
|
-
pending = null;
|
|
19
|
-
return notice;
|
|
20
|
-
}
|