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
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
diff --git a/api/preload/encryption.ts b/api/preload/encryption.ts
|
|
2
|
-
index
|
|
2
|
+
index 8cf3ab6ce..0f70f2107 100644
|
|
3
3
|
--- a/api/preload/encryption.ts
|
|
4
4
|
+++ b/api/preload/encryption.ts
|
|
5
5
|
@@ -3,27 +3,30 @@
|
|
@@ -48,10 +48,18 @@ index 8cf3ab6..0f70f21 100644
|
|
|
48
48
|
|
|
49
49
|
function toArrayBuffer(bytes: Uint8Array): ArrayBuffer {
|
|
50
50
|
diff --git a/api/sdks/main/core/Updater.ts b/api/sdks/main/core/Updater.ts
|
|
51
|
-
index
|
|
51
|
+
index 4c47ed9d2..fde979421 100644
|
|
52
52
|
--- a/api/sdks/main/core/Updater.ts
|
|
53
53
|
+++ b/api/sdks/main/core/Updater.ts
|
|
54
|
-
@@ -
|
|
54
|
+
@@ -7,6 +7,7 @@ import {
|
|
55
|
+
read,
|
|
56
|
+
fchmodSync,
|
|
57
|
+
fstatSync,
|
|
58
|
+
+ fsync,
|
|
59
|
+
fsyncSync,
|
|
60
|
+
lstatSync,
|
|
61
|
+
mkdirSync,
|
|
62
|
+
@@ -323,6 +324,39 @@ let updateInfo: UpdateInfo = {
|
|
55
63
|
error: "",
|
|
56
64
|
};
|
|
57
65
|
let checkedManifest: UpdateManifestV1 | undefined;
|
|
@@ -91,7 +99,124 @@ index 4c47ed9..3221b5d 100644
|
|
|
91
99
|
let checkInFlight: Promise<UpdateInfo> | undefined;
|
|
92
100
|
let downloadInFlight: Promise<void> | undefined;
|
|
93
101
|
let applyInFlight: Promise<void> | undefined;
|
|
94
|
-
@@ -
|
|
102
|
+
@@ -679,6 +713,56 @@ function atomicWriteJson(path: string, value: unknown): void {
|
|
103
|
+
atomicWriteFile(path, new TextEncoder().encode(`${JSON.stringify(value)}\n`));
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
+/**
|
|
107
|
+
+ * `syncFile` without holding this thread while the disk takes a bundle
|
|
108
|
+
+ * hundreds of megabytes large: the app's windows keep answering.
|
|
109
|
+
+ */
|
|
110
|
+
+async function syncFileOffThread(path: string): Promise<void> {
|
|
111
|
+
+ const fileDescriptor = openSync(path, fsConstants.O_RDWR);
|
|
112
|
+
+ try {
|
|
113
|
+
+ await syncDescriptorOffThread(fileDescriptor);
|
|
114
|
+
+ } finally {
|
|
115
|
+
+ closeSync(fileDescriptor);
|
|
116
|
+
+ }
|
|
117
|
+
+}
|
|
118
|
+
+
|
|
119
|
+
+function syncDescriptorOffThread(fileDescriptor: number): Promise<void> {
|
|
120
|
+
+ return new Promise((resolve, reject) => {
|
|
121
|
+
+ fsync(fileDescriptor, (error) => (error ? reject(error) : resolve()));
|
|
122
|
+
+ });
|
|
123
|
+
+}
|
|
124
|
+
+
|
|
125
|
+
+/**
|
|
126
|
+
+ * Runs one of the update's tools (zig-zstd, bspatch) without holding this
|
|
127
|
+
+ * thread while it unpacks or patches a bundle: the app's windows keep
|
|
128
|
+
+ * answering meanwhile. Fails as execFileSync did, naming the command.
|
|
129
|
+
+ */
|
|
130
|
+
+async function runUpdateTool(
|
|
131
|
+
+ executable: string,
|
|
132
|
+
+ args: readonly string[],
|
|
133
|
+
+ options: { timeoutMs?: number; keepStderr?: boolean } = {},
|
|
134
|
+
+): Promise<void> {
|
|
135
|
+
+ const child = Bun.spawn([executable, ...args], {
|
|
136
|
+
+ stdin: "ignore",
|
|
137
|
+
+ stdout: "ignore",
|
|
138
|
+
+ stderr: options.keepStderr ? "pipe" : "ignore",
|
|
139
|
+
+ windowsHide: true,
|
|
140
|
+
+ ...(options.timeoutMs ? { timeout: options.timeoutMs } : {}),
|
|
141
|
+
+ });
|
|
142
|
+
+ const [code, stderr] = await Promise.all([
|
|
143
|
+
+ child.exited,
|
|
144
|
+
+ options.keepStderr && child.stderr instanceof ReadableStream
|
|
145
|
+
+ ? new Response(child.stderr).text()
|
|
146
|
+
+ : Promise.resolve(""),
|
|
147
|
+
+ ]);
|
|
148
|
+
+ if (code !== 0) {
|
|
149
|
+
+ const detail = stderr.trim().slice(-64 * 1024);
|
|
150
|
+
+ throw new Error(
|
|
151
|
+
+ `Command failed: ${[executable, ...args].join(" ")} (${child.signalCode ?? `exit ${code}`})${detail ? `\n${detail}` : ""}`,
|
|
152
|
+
+ );
|
|
153
|
+
+ }
|
|
154
|
+
+}
|
|
155
|
+
+
|
|
156
|
+
export function syncFile(path: string): void {
|
|
157
|
+
// Cottontail's Windows fsync path requires a read/write handle. Opening an
|
|
158
|
+
// otherwise valid update file read-only can surface EBADF at the durability
|
|
159
|
+
@@ -1164,7 +1248,7 @@ export async function downloadResponseToFile(
|
|
160
|
+
} catch {}
|
|
161
|
+
throw error;
|
|
162
|
+
}
|
|
163
|
+
- fsyncSync(fileDescriptor);
|
|
164
|
+
+ await syncDescriptorOffThread(fileDescriptor);
|
|
165
|
+
closeSync(fileDescriptor);
|
|
166
|
+
fileDescriptor = undefined;
|
|
167
|
+
return bytesDownloaded;
|
|
168
|
+
@@ -1228,24 +1312,21 @@ async function downloadArtifact(
|
|
169
|
+
type DeltaPatchExecutor = (
|
|
170
|
+
executable: string,
|
|
171
|
+
args: readonly string[],
|
|
172
|
+
-) => void;
|
|
173
|
+
+) => void | Promise<void>;
|
|
174
|
+
|
|
175
|
+
-export function applyDeltaPatch(
|
|
176
|
+
+export async function applyDeltaPatch(
|
|
177
|
+
options: {
|
|
178
|
+
bspatchPath: string;
|
|
179
|
+
currentTarPath: string;
|
|
180
|
+
patchPath: string;
|
|
181
|
+
outputPath: string;
|
|
182
|
+
},
|
|
183
|
+
- execute: DeltaPatchExecutor = (executable, args) => {
|
|
184
|
+
- execFileSync(executable, [...args], {
|
|
185
|
+
- stdio: ["ignore", "ignore", "pipe"],
|
|
186
|
+
- maxBuffer: 64 * 1024,
|
|
187
|
+
- windowsHide: true,
|
|
188
|
+
- timeout: 10 * 60_000,
|
|
189
|
+
- });
|
|
190
|
+
- },
|
|
191
|
+
-): void {
|
|
192
|
+
+ execute: DeltaPatchExecutor = (executable, args) =>
|
|
193
|
+
+ runUpdateTool(executable, args, {
|
|
194
|
+
+ keepStderr: true,
|
|
195
|
+
+ timeoutMs: 10 * 60_000,
|
|
196
|
+
+ }),
|
|
197
|
+
+): Promise<void> {
|
|
198
|
+
requireRegularFile(options.bspatchPath, "bspatch executable");
|
|
199
|
+
requireRegularFile(options.currentTarPath, "Current update archive");
|
|
200
|
+
requireRegularFile(options.patchPath, "Downloaded update patch");
|
|
201
|
+
@@ -1253,7 +1334,7 @@ export function applyDeltaPatch(
|
|
202
|
+
throw new Error("Refusing to replace an existing patch output");
|
|
203
|
+
}
|
|
204
|
+
try {
|
|
205
|
+
- execute(options.bspatchPath, [
|
|
206
|
+
+ await execute(options.bspatchPath, [
|
|
207
|
+
options.currentTarPath,
|
|
208
|
+
options.outputPath,
|
|
209
|
+
options.patchPath,
|
|
210
|
+
@@ -1262,7 +1343,7 @@ export function applyDeltaPatch(
|
|
211
|
+
if (lstatSync(options.outputPath).size <= 0) {
|
|
212
|
+
throw new Error("Patched update archive is empty");
|
|
213
|
+
}
|
|
214
|
+
- syncFile(options.outputPath);
|
|
215
|
+
+ await syncFileOffThread(options.outputPath);
|
|
216
|
+
} catch (error) {
|
|
217
|
+
rmSync(options.outputPath, { force: true });
|
|
218
|
+
throw error;
|
|
219
|
+
@@ -1773,8 +1854,8 @@ async function checkForUpdateOperation(): Promise<UpdateInfo> {
|
|
95
220
|
return updateInfo;
|
|
96
221
|
}
|
|
97
222
|
|
|
@@ -102,7 +227,7 @@ index 4c47ed9..3221b5d 100644
|
|
|
102
227
|
try {
|
|
103
228
|
const response = await fetch(updateInfoUrl, {
|
|
104
229
|
signal: AbortSignal.timeout(30_000),
|
|
105
|
-
@@ -1938,7 +
|
|
230
|
+
@@ -1938,7 +2019,7 @@ export async function preparePatchChainForUpdate(
|
|
106
231
|
const bspatchPath =
|
|
107
232
|
dependencies.bspatchPath ??
|
|
108
233
|
join(dirname(process.execPath), currentOS === "win" ? "bspatch.exe" : "bspatch");
|
|
@@ -111,7 +236,7 @@ index 4c47ed9..3221b5d 100644
|
|
|
111
236
|
channel,
|
|
112
237
|
manifest.platform,
|
|
113
238
|
manifest.arch,
|
|
114
|
-
@@ -1952,7 +
|
|
239
|
+
@@ -1952,7 +2033,7 @@ export async function preparePatchChainForUpdate(
|
|
115
240
|
try {
|
|
116
241
|
while (currentHash !== manifest.hash) {
|
|
117
242
|
const patchNumber = patchesApplied + 1;
|
|
@@ -120,7 +245,7 @@ index 4c47ed9..3221b5d 100644
|
|
|
120
245
|
const pathPrefix = join(
|
|
121
246
|
extractionFolder,
|
|
122
247
|
`.${transactionId}.${patchNumber}.${currentHash}`,
|
|
123
|
-
@@ -2136,8 +
|
|
248
|
+
@@ -2136,8 +2217,8 @@ async function downloadUpdateOperation(): Promise<void> {
|
|
124
249
|
join(extractionFolder, `${manifest.hash}.tar`),
|
|
125
250
|
);
|
|
126
251
|
const artifactUrl = buildUpdateArtifactUrl(
|
|
@@ -131,7 +256,40 @@ index 4c47ed9..3221b5d 100644
|
|
|
131
256
|
);
|
|
132
257
|
const artifactRequestUrl = addUpdateArtifactCacheBuster(
|
|
133
258
|
artifactUrl,
|
|
134
|
-
@@ -
|
|
259
|
+
@@ -2175,23 +2256,19 @@ async function downloadUpdateOperation(): Promise<void> {
|
|
260
|
+
emitStatus("decompressing", "Decompressing update bundle...", {
|
|
261
|
+
zstdPath,
|
|
262
|
+
});
|
|
263
|
+
- execFileSync(
|
|
264
|
+
- zstdPath,
|
|
265
|
+
- [
|
|
266
|
+
- "decompress",
|
|
267
|
+
- "-i",
|
|
268
|
+
- compressedPath,
|
|
269
|
+
- "-o",
|
|
270
|
+
- tarPartialPath,
|
|
271
|
+
- "--no-timing",
|
|
272
|
+
- ],
|
|
273
|
+
- { stdio: "ignore", windowsHide: true },
|
|
274
|
+
- );
|
|
275
|
+
+ await runUpdateTool(zstdPath, [
|
|
276
|
+
+ "decompress",
|
|
277
|
+
+ "-i",
|
|
278
|
+
+ compressedPath,
|
|
279
|
+
+ "-o",
|
|
280
|
+
+ tarPartialPath,
|
|
281
|
+
+ "--no-timing",
|
|
282
|
+
+ ]);
|
|
283
|
+
requireRegularFile(tarPartialPath, "Decompressed update archive");
|
|
284
|
+
if (lstatSync(tarPartialPath).size <= 0) {
|
|
285
|
+
throw new Error("Decompressed update archive is empty");
|
|
286
|
+
}
|
|
287
|
+
- syncFile(tarPartialPath);
|
|
288
|
+
+ await syncFileOffThread(tarPartialPath);
|
|
289
|
+
publishFileReplacingRegular(tarPartialPath, retainedTarPath);
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
@@ -2388,6 +2465,14 @@ const Updater = {
|
|
135
293
|
onStatusChangeCallback = callback;
|
|
136
294
|
if (callback) scheduleNativeUpdateResultReconciliation();
|
|
137
295
|
},
|
|
@@ -146,3 +304,105 @@ index 4c47ed9..3221b5d 100644
|
|
|
146
304
|
checkForUpdate,
|
|
147
305
|
downloadUpdate,
|
|
148
306
|
applyUpdate,
|
|
307
|
+
diff --git a/api/sdks/main/core/BrowserView.ts b/api/sdks/main/core/BrowserView.ts
|
|
308
|
+
index ced422137..43e8e905c 100644
|
|
309
|
+
--- a/api/sdks/main/core/BrowserView.ts
|
|
310
|
+
+++ b/api/sdks/main/core/BrowserView.ts
|
|
311
|
+
@@ -33,6 +33,22 @@ const HOST_MESSAGE_SEND_TURN_MS = 8;
|
|
312
|
+
const HOST_MESSAGE_SOCKET_AVAILABLE = process.platform !== "win32";
|
|
313
|
+
const HOST_MESSAGE_RESPONSE_PRIORITY = process.platform === "linux";
|
|
314
|
+
|
|
315
|
+
+/**
|
|
316
|
+
+ * Where set, runs a script in a webview instead of this thread when it
|
|
317
|
+
+ * returns true. On Windows every message to a page goes as a script, and the
|
|
318
|
+
+ * native call waits on the thread that runs the windows until it takes it.
|
|
319
|
+
+ * `webview` is the native pointer, which a webview made after this one is
|
|
320
|
+
+ * removed can reuse; `webviewId` is never reused. `runHere` runs it on this
|
|
321
|
+
+ * thread, for a script the runner took and then could not run.
|
|
322
|
+
+ */
|
|
323
|
+
+type WebviewScriptRunner = (
|
|
324
|
+
+ js: string,
|
|
325
|
+
+ webviewId: number,
|
|
326
|
+
+ webview: number,
|
|
327
|
+
+ runHere: () => void,
|
|
328
|
+
+) => boolean;
|
|
329
|
+
+let webviewScriptRunner: WebviewScriptRunner | null = null;
|
|
330
|
+
+
|
|
331
|
+
function isRpcResponsePacket(message: unknown): boolean {
|
|
332
|
+
return (
|
|
333
|
+
typeof message === "object" &&
|
|
334
|
+
@@ -267,10 +283,22 @@ export class BrowserView<T extends RPCWithTransport = RPCWithTransport> {
|
|
335
|
+
// so we have to chunk it
|
|
336
|
+
// TODO: is this still needed after switching from named pipes
|
|
337
|
+
executeJavascript(js: string) {
|
|
338
|
+
- if (!this.ptr || this.isRemoved) {
|
|
339
|
+
+ const webview = this.ptr;
|
|
340
|
+
+ if (!webview || this.isRemoved) {
|
|
341
|
+
+ return;
|
|
342
|
+
+ }
|
|
343
|
+
+ const runHere = () => ffi.request.evaluateJavascriptWithNoCompletion({ id: this.id, js });
|
|
344
|
+
+ if (
|
|
345
|
+
+ webviewScriptRunner &&
|
|
346
|
+
+ webviewScriptRunner(js, this.id, webview as unknown as number, runHere)
|
|
347
|
+
+ ) {
|
|
348
|
+
return;
|
|
349
|
+
}
|
|
350
|
+
- ffi.request.evaluateJavascriptWithNoCompletion({ id: this.id, js });
|
|
351
|
+
+ runHere();
|
|
352
|
+
+ }
|
|
353
|
+
+
|
|
354
|
+
+ static setScriptRunner(runner: WebviewScriptRunner | null): void {
|
|
355
|
+
+ webviewScriptRunner = runner;
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
loadURL(url: string) {
|
|
359
|
+
diff --git a/api/sdks/main/core/ContextMenu.ts b/api/sdks/main/core/ContextMenu.ts
|
|
360
|
+
index 807fd20e2..9f8bc899e 100644
|
|
361
|
+
--- a/api/sdks/main/core/ContextMenu.ts
|
|
362
|
+
+++ b/api/sdks/main/core/ContextMenu.ts
|
|
363
|
+
@@ -7,6 +7,8 @@ import { ffi, type ApplicationMenuItemConfig } from "../proc/native";
|
|
364
|
+
import electrobunEventEmitter from "../events/eventEmitter";
|
|
365
|
+
import { roleLabelMap } from "./menuRoles";
|
|
366
|
+
|
|
367
|
+
+export { setContextMenuRunner } from "../proc/native";
|
|
368
|
+
+
|
|
369
|
+
type NonDividerMenuItem = {
|
|
370
|
+
type?: "normal";
|
|
371
|
+
label?: string;
|
|
372
|
+
diff --git a/api/sdks/main/proc/native.ts b/api/sdks/main/proc/native.ts
|
|
373
|
+
index 449853c5b..fc1500c52 100644
|
|
374
|
+
--- a/api/sdks/main/proc/native.ts
|
|
375
|
+
+++ b/api/sdks/main/proc/native.ts
|
|
376
|
+
@@ -1279,6 +1279,19 @@ function createFfiRequestProxy(ffiRequest: Record<string, Function>): Record<str
|
|
377
|
+
const core_ = core!;
|
|
378
|
+
const native_ = native!;
|
|
379
|
+
|
|
380
|
+
+/**
|
|
381
|
+
+ * Where set, makes a context menu's native call instead of this thread when
|
|
382
|
+
+ * it returns true. On Windows that call waits on the thread that runs the
|
|
383
|
+
+ * windows, which answers only once the menu closes. `showHere` makes the
|
|
384
|
+
+ * call on this thread, for a menu the runner took and then could not show.
|
|
385
|
+
+ */
|
|
386
|
+
+type ContextMenuRunner = (menuConfig: string, handler: number, showHere: () => void) => boolean;
|
|
387
|
+
+let contextMenuRunner: ContextMenuRunner | null = null;
|
|
388
|
+
+
|
|
389
|
+
+export function setContextMenuRunner(runner: ContextMenuRunner | null): void {
|
|
390
|
+
+ contextMenuRunner = runner;
|
|
391
|
+
+}
|
|
392
|
+
+
|
|
393
|
+
type DarwinNativeWrapperSymbols = {
|
|
394
|
+
wgpuViewSetAlphaBlending: (view: Pointer, enabled: boolean) => void;
|
|
395
|
+
setWGPUPointerHandler: (handler: Pointer | null) => void;
|
|
396
|
+
@@ -2349,8 +2362,11 @@ const _ffiImpl = {
|
|
397
|
+
},
|
|
398
|
+
showContextMenu: (params: { menuConfig: string }): void => {
|
|
399
|
+
const { menuConfig } = params;
|
|
400
|
+
+ const handler = contextMenuHandler.ptr as unknown as number | null;
|
|
401
|
+
+ const showHere = () => core_.symbols.showContextMenu(toCString(menuConfig), contextMenuHandler);
|
|
402
|
+
+ if (contextMenuRunner && handler && contextMenuRunner(menuConfig, handler, showHere)) return;
|
|
403
|
+
|
|
404
|
+
- core_.symbols.showContextMenu(toCString(menuConfig), contextMenuHandler);
|
|
405
|
+
+ showHere();
|
|
406
|
+
},
|
|
407
|
+
moveToTrash: (params: { path: string }): boolean => {
|
|
408
|
+
const { path } = params;
|
|
@@ -6,12 +6,14 @@ interface CryptoDailyCloses {
|
|
|
6
6
|
|
|
7
7
|
export type CryptoAssetKind = "coin" | "stablecoin";
|
|
8
8
|
|
|
9
|
-
/** What a stablecoin holds to: a currency,
|
|
9
|
+
/** What a stablecoin holds to: a currency, a dollar value that accrues yield, or a dollar at a bond's maturity. */
|
|
10
10
|
export interface CryptoPeg {
|
|
11
11
|
/** The currency it is pegged to: USD, EUR. */
|
|
12
12
|
currency: string;
|
|
13
|
-
/**
|
|
13
|
+
/** Its price is not held at par: yield accrues into it (USDY), or it is a bond token priced toward par at maturity (BUSD0). It has no par to be off. */
|
|
14
14
|
accrues: boolean;
|
|
15
|
+
/** What a coin that accrues is: `yield` (USDY) or `bond` (BUSD0), `par` for the rest; absent from servers before it was served, where an accruing coin is a yield one. */
|
|
16
|
+
kind?: "par" | "yield" | "bond";
|
|
15
17
|
/** The target in dollars: 1 for USD, the EUR/USD rate for EUR; null when it accrues or the rate is unavailable. */
|
|
16
18
|
price: number | null;
|
|
17
19
|
/** When a target that moves (an exchange rate) was quoted; null for USD. */
|
|
@@ -71,6 +73,8 @@ export interface CryptoMarketsPayload {
|
|
|
71
73
|
generatedAt: string;
|
|
72
74
|
/** Each asset's change is since 00:00 UTC; a server before it sent the screener's 24-hour move. */
|
|
73
75
|
dayChangeBasis?: "utc-day";
|
|
76
|
+
/** Each asset's market cap is its price times its circulating supply; a server before it sent the source's own figure. */
|
|
77
|
+
marketCapBasis?: "circulating";
|
|
74
78
|
asOf: string | null;
|
|
75
79
|
status: "available" | "partial" | "unavailable";
|
|
76
80
|
source: {
|
|
@@ -167,6 +171,18 @@ export interface DefiTvlProtocol {
|
|
|
167
171
|
change7dPercent: number | null;
|
|
168
172
|
change30d: number | null;
|
|
169
173
|
change30dPercent: number | null;
|
|
174
|
+
/**
|
|
175
|
+
* USD its users paid in fees over the last 24 hours, 7 and 30 days, its
|
|
176
|
+
* versions together, read with its TVL; null where the source has no
|
|
177
|
+
* figure. Absent from servers before them.
|
|
178
|
+
*/
|
|
179
|
+
fees24h?: number | null;
|
|
180
|
+
fees7d?: number | null;
|
|
181
|
+
fees30d?: number | null;
|
|
182
|
+
/** The part of those fees the protocol kept (the source's revenue), USD. */
|
|
183
|
+
revenue24h?: number | null;
|
|
184
|
+
revenue7d?: number | null;
|
|
185
|
+
revenue30d?: number | null;
|
|
170
186
|
}
|
|
171
187
|
|
|
172
188
|
export interface DefiTvlChain {
|
|
@@ -197,6 +213,8 @@ export interface DefiTvlPayload {
|
|
|
197
213
|
protocols: DefiTvlProtocol[];
|
|
198
214
|
/** When the protocols' figures were read: the source's latest, not a daily close. */
|
|
199
215
|
protocolsAsOf: string | null;
|
|
216
|
+
/** When the protocols' fees and revenue were read; null when they could not be, absent from servers before them. */
|
|
217
|
+
incomeAsOf?: string | null;
|
|
200
218
|
/** The largest chains by TVL, largest first. */
|
|
201
219
|
chains: DefiTvlChain[];
|
|
202
220
|
/** Total DeFi TVL in USD per UTC day since `start`, its first day with value locked. */
|
|
@@ -15,7 +15,8 @@ interface FundFact<T> {
|
|
|
15
15
|
* premium or discount to NAV. Servers before them say null.
|
|
16
16
|
*/
|
|
17
17
|
export type FundStructure = "registered" | "trust" | "closed-end" | "bdc";
|
|
18
|
-
|
|
18
|
+
/** `management-fee`: a Hong Kong fund's management fee, which its issuer states apart from the ongoing charges. */
|
|
19
|
+
type ExpenseRatioKind = "net" | "gross" | "sponsor-fee" | "management-fee";
|
|
19
20
|
/**
|
|
20
21
|
* A bond fund as its sponsor classes it: `municipal` when its interest is
|
|
21
22
|
* exempt from federal income tax, `taxable` otherwise.
|
|
@@ -146,7 +147,28 @@ export interface FundFactsPayload {
|
|
|
146
147
|
sharesOutstanding?: FundFact<number> | null;
|
|
147
148
|
/** The 1M change in shares outstanding; null until a month of counts is kept. Servers before it leave it out. */
|
|
148
149
|
flows?: FundFlows | null;
|
|
150
|
+
/**
|
|
151
|
+
* The currency the NAV and closing price are in: a Hong Kong counter's own
|
|
152
|
+
* (HKD for 3046, USD for 9046). Absent for a US fund, whose figures are in
|
|
153
|
+
* US dollars.
|
|
154
|
+
*/
|
|
155
|
+
currency?: string;
|
|
156
|
+
/**
|
|
157
|
+
* A spot bitcoin or ether fund's coins as its issuer states them, and the
|
|
158
|
+
* units in issue per coin on the same day (the Hong Kong spot funds).
|
|
159
|
+
* Absent for any other fund and from servers before it.
|
|
160
|
+
*/
|
|
161
|
+
coinHoldings?: FundCoinHoldings | null;
|
|
149
162
|
/** The newest NAV is older than a few US trading days: every figure is older than it looks. */
|
|
150
163
|
stale: boolean;
|
|
151
164
|
fetchedAt: string | null;
|
|
152
165
|
}
|
|
166
|
+
|
|
167
|
+
export interface FundCoinHoldings {
|
|
168
|
+
asset: "BTC" | "ETH";
|
|
169
|
+
coins: number;
|
|
170
|
+
unitsPerCoin: number;
|
|
171
|
+
asOf: string;
|
|
172
|
+
source: string;
|
|
173
|
+
url?: string;
|
|
174
|
+
}
|
|
@@ -126,6 +126,12 @@ interface CloudRiskReportSummaryPayload {
|
|
|
126
126
|
removedCount: number | null;
|
|
127
127
|
rewordedCount: number | null;
|
|
128
128
|
overview: string | null;
|
|
129
|
+
/**
|
|
130
|
+
* The 10-K lists no risk factors (a smaller reporting company need not):
|
|
131
|
+
* no risks, and `overview` says so. Older servers leave it out and send a
|
|
132
|
+
* risk count of 0.
|
|
133
|
+
*/
|
|
134
|
+
listsNoRiskFactors?: boolean;
|
|
129
135
|
}
|
|
130
136
|
|
|
131
137
|
export interface CloudRiskReportPayload extends CloudRiskReportSummaryPayload {
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import type { PluginActivation } from "../../plugins/marketplace/activation";
|
|
2
|
+
import {
|
|
3
|
+
getPluginSeedProgress,
|
|
4
|
+
samePluginSeedFailure,
|
|
5
|
+
subscribePluginSeed,
|
|
6
|
+
type PluginSeedNotice,
|
|
7
|
+
type PluginSeedProgress,
|
|
8
|
+
type PluginSeedRecord,
|
|
9
|
+
} from "../../plugins/seed-progress";
|
|
10
|
+
import type { AppConfig } from "../../types/config";
|
|
11
|
+
import { logFailure } from "../../utils/log-failure";
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Brings the plugins the launch restores (cli/restore-plugins.ts) into the
|
|
15
|
+
* running app as each lands, the way the Plugins pane does after an install,
|
|
16
|
+
* then records the outcome in the config and says what could not be
|
|
17
|
+
* installed. The main window alone does this: it owns the config and the
|
|
18
|
+
* plugin registrations.
|
|
19
|
+
*/
|
|
20
|
+
export interface PluginSeedConsumer {
|
|
21
|
+
/** Settles once the plugins the app started with have registered. */
|
|
22
|
+
ready: Promise<unknown>;
|
|
23
|
+
/** Brings an installed folder, and the siblings it brought along, into the session. Null when nothing can. */
|
|
24
|
+
activate(install: { directory: string; peers: string[] }): Promise<PluginActivation | null>;
|
|
25
|
+
/** Whether the plugin in this folder already runs in the session. */
|
|
26
|
+
isRunning(directory: string): boolean;
|
|
27
|
+
/** The broker types registered in the session now. */
|
|
28
|
+
brokerTypes(): Iterable<string>;
|
|
29
|
+
/**
|
|
30
|
+
* Syncs the saved broker profiles of these types. The launch's sync ran
|
|
31
|
+
* before their plugin was back, so it had no broker to ask.
|
|
32
|
+
*/
|
|
33
|
+
syncBrokers(types: ReadonlySet<string>): void;
|
|
34
|
+
record(record: PluginSeedRecord): void;
|
|
35
|
+
notify(notice: PluginSeedNotice): void;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** Folders being brought in, across consumers: a remounted app must not register one twice. */
|
|
39
|
+
const activating = new Set<string>();
|
|
40
|
+
|
|
41
|
+
/** `TV, Polls and Substack`. */
|
|
42
|
+
function nameList(names: readonly string[]): string {
|
|
43
|
+
return names.length <= 1 ? names.join("") : `${names.slice(0, -1).join(", ")} and ${names.at(-1)}`;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** Follows the restore until it is over, or until the returned function is called. */
|
|
47
|
+
export function startPluginSeedConsumer(consumer: PluginSeedConsumer): () => void {
|
|
48
|
+
const handled = new Set<string>();
|
|
49
|
+
const unloaded: string[] = [];
|
|
50
|
+
const restart: string[] = [];
|
|
51
|
+
let finished = false;
|
|
52
|
+
let disposed = false;
|
|
53
|
+
// One at a time, in the order they landed: a sibling before what needs it.
|
|
54
|
+
let chain: Promise<void> = consumer.ready.then(() => {}, () => {
|
|
55
|
+
// Intentional ignore: a plugin that failed to register is reported where it registers.
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
const bringIn = async (name: string, directory: string, peers: string[]) => {
|
|
59
|
+
if (disposed || activating.has(directory) || consumer.isRunning(directory)) return;
|
|
60
|
+
activating.add(directory);
|
|
61
|
+
try {
|
|
62
|
+
const before = new Set(consumer.brokerTypes());
|
|
63
|
+
const activated = await consumer.activate({ directory, peers: peers.filter((peer) => !consumer.isRunning(peer)) });
|
|
64
|
+
// Nothing here can load it (no plugin manager): the next launch does.
|
|
65
|
+
if (!activated || (activated.ok && activated.restart)) restart.push(name);
|
|
66
|
+
else if (!activated.ok) unloaded.push(name);
|
|
67
|
+
const added = new Set([...consumer.brokerTypes()].filter((type) => !before.has(type)));
|
|
68
|
+
if (added.size > 0 && !disposed) consumer.syncBrokers(added);
|
|
69
|
+
} finally {
|
|
70
|
+
activating.delete(directory);
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
const finish = (outcome: NonNullable<PluginSeedProgress["outcome"]>) => {
|
|
75
|
+
if (disposed) return;
|
|
76
|
+
consumer.record(outcome.record);
|
|
77
|
+
if (outcome.notice) consumer.notify(outcome.notice);
|
|
78
|
+
if (unloaded.length > 0) consumer.notify({ type: "error", body: `${nameList(unloaded)} installed but did not load. Open Plugins to see why.` });
|
|
79
|
+
else if (restart.length > 0) consumer.notify({ type: "info", body: `Restart Gloom to finish installing ${nameList(restart)}.` });
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
const step = () => {
|
|
83
|
+
const progress = getPluginSeedProgress();
|
|
84
|
+
if (!progress || disposed) return;
|
|
85
|
+
for (const entry of progress.plugins) {
|
|
86
|
+
if (entry.state !== "installed" || !entry.directory || handled.has(entry.id)) continue;
|
|
87
|
+
handled.add(entry.id);
|
|
88
|
+
const { name, directory } = entry;
|
|
89
|
+
chain = chain.then(() => bringIn(name, directory, entry.peers ?? []))
|
|
90
|
+
.catch(logFailure("plugin-seed", "Restored plugin activation failed"));
|
|
91
|
+
}
|
|
92
|
+
const { outcome } = progress;
|
|
93
|
+
if (outcome && !finished) {
|
|
94
|
+
finished = true;
|
|
95
|
+
chain = chain.then(() => finish(outcome)).catch(logFailure("plugin-seed", "Plugin restore record failed"));
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
const unsubscribe = subscribePluginSeed(step);
|
|
100
|
+
step();
|
|
101
|
+
return () => {
|
|
102
|
+
disposed = true;
|
|
103
|
+
unsubscribe();
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* The config with the restore's record: every plugin seeded so far stays
|
|
109
|
+
* seeded, and the failure is this launch's. Null when that changes nothing.
|
|
110
|
+
*/
|
|
111
|
+
export function withPluginSeedRecord(config: AppConfig, record: PluginSeedRecord): AppConfig | null {
|
|
112
|
+
const seededPlugins = [...new Set([...config.seededPlugins ?? [], ...record.seededPlugins ?? []])].sort();
|
|
113
|
+
const sameSeeded = seededPlugins.join() === [...new Set(config.seededPlugins ?? [])].sort().join();
|
|
114
|
+
if (sameSeeded && samePluginSeedFailure(config.pluginSeedFailure, record.pluginSeedFailure)) return null;
|
|
115
|
+
const next: AppConfig = { ...config, seededPlugins };
|
|
116
|
+
if (record.pluginSeedFailure) next.pluginSeedFailure = record.pluginSeedFailure;
|
|
117
|
+
else delete next.pluginSeedFailure;
|
|
118
|
+
return next;
|
|
119
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { logFailure } from "../../utils/log-failure";
|
|
2
|
-
import { useCallback, useEffect, type Dispatch } from "react";
|
|
2
|
+
import { useCallback, useEffect, useRef, type Dispatch } from "react";
|
|
3
3
|
import { loadPersistedBrokerAccountMap } from "../../brokers/account-cache";
|
|
4
4
|
import type { AppSessionSnapshot } from "../../core/state/session-persistence";
|
|
5
5
|
import type { AppTickerRepositoryPort } from "../../core/app-service-ports";
|
|
@@ -8,7 +8,11 @@ import { instrumentFromTicker, type InstrumentRef } from "../../market-data/requ
|
|
|
8
8
|
import { useSavedLayoutWarmup } from "./layout-warmup";
|
|
9
9
|
import { chatController } from "../../plugins/builtin/chat/controller";
|
|
10
10
|
import { PLUGIN_MARKETPLACE_PANE_ID } from "../../plugins/marketplace/ids";
|
|
11
|
-
import {
|
|
11
|
+
import { activateInstall } from "../../plugins/marketplace/activation";
|
|
12
|
+
import { getMarketplaceHost, getPluginManager } from "../../plugins/marketplace/store";
|
|
13
|
+
import { listExternalPlugins } from "../../plugins/external-runtime";
|
|
14
|
+
import { scheduleConfigSave } from "../../state/config-save-scheduler";
|
|
15
|
+
import { startPluginSeedConsumer, withPluginSeedRecord } from "./plugin-seed";
|
|
12
16
|
import type { LoadedExternalPlugin } from "../../plugins/loader";
|
|
13
17
|
import type { PluginRegistry } from "../../plugins/registry";
|
|
14
18
|
import type {
|
|
@@ -65,6 +69,8 @@ function restoredUsageFunctions(
|
|
|
65
69
|
interface UseAppStartupRuntimeOptions {
|
|
66
70
|
appActive: boolean;
|
|
67
71
|
autoImportBrokerPositions: InitializeAppStateArgs["autoImportBrokerPositions"];
|
|
72
|
+
/** Syncs one saved broker profile, as its Sync action does. */
|
|
73
|
+
importBrokerPositions: (instanceId: string) => Promise<unknown>;
|
|
68
74
|
dataProvider: DataProvider;
|
|
69
75
|
dispatch: Dispatch<AppAction>;
|
|
70
76
|
externalPlugins: readonly LoadedExternalPlugin[];
|
|
@@ -88,6 +94,7 @@ interface UseAppStartupRuntimeOptions {
|
|
|
88
94
|
export function useAppStartupRuntime({
|
|
89
95
|
appActive,
|
|
90
96
|
autoImportBrokerPositions,
|
|
97
|
+
importBrokerPositions,
|
|
91
98
|
dataProvider,
|
|
92
99
|
dispatch,
|
|
93
100
|
externalPlugins,
|
|
@@ -208,15 +215,44 @@ export function useAppStartupRuntime({
|
|
|
208
215
|
// identity, so this runs when initialization flips and not again.
|
|
209
216
|
}, [externalPlugins, isDetachedWindow, pluginRegistry, state.initialized]);
|
|
210
217
|
|
|
211
|
-
// Official plugins
|
|
212
|
-
//
|
|
218
|
+
// Official plugins that moved out of Gloom install after the first frame
|
|
219
|
+
// (cli/restore-plugins.ts). Each is brought into the session as it lands,
|
|
220
|
+
// the outcome is recorded, and what could not be installed (no git,
|
|
221
|
+
// offline) is said once, since it is otherwise simply missing. The import
|
|
222
|
+
// is read through a ref: a new one must not restart the restore's consumer,
|
|
223
|
+
// which would say its outcome again.
|
|
224
|
+
const importBrokerPositionsRef = useRef(importBrokerPositions);
|
|
225
|
+
importBrokerPositionsRef.current = importBrokerPositions;
|
|
213
226
|
useEffect(() => {
|
|
214
227
|
if (!state.initialized || isDetachedWindow) return;
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
228
|
+
return startPluginSeedConsumer({
|
|
229
|
+
ready: pluginsReady ?? Promise.resolve(),
|
|
230
|
+
activate: async (install) => {
|
|
231
|
+
const host = getMarketplaceHost();
|
|
232
|
+
const manager = getPluginManager();
|
|
233
|
+
return host && manager ? activateInstall(install, host, manager) : null;
|
|
234
|
+
},
|
|
235
|
+
isRunning: (directory) => listExternalPlugins().some((entry) => entry.directory === directory && !entry.error),
|
|
236
|
+
brokerTypes: () => pluginRegistry.brokers.keys(),
|
|
237
|
+
syncBrokers: (types) => {
|
|
238
|
+
for (const instance of getState().config.brokerInstances) {
|
|
239
|
+
if (instance.enabled === false || !types.has(instance.brokerType)) continue;
|
|
240
|
+
// A failure is on the profile's row, with Sync to retry.
|
|
241
|
+
void importBrokerPositionsRef.current(instance.id).catch(logFailure("app.runtime.startup", "Restored broker positions import failed"));
|
|
242
|
+
}
|
|
243
|
+
},
|
|
244
|
+
record: (record) => {
|
|
245
|
+
const config = withPluginSeedRecord(getState().config, record);
|
|
246
|
+
if (!config) return;
|
|
247
|
+
dispatch({ type: "SET_CONFIG", config });
|
|
248
|
+
scheduleConfigSave(config);
|
|
249
|
+
},
|
|
250
|
+
notify: (notice) => {
|
|
251
|
+
appLog.warn("official plugin restore", { notice: notice.body });
|
|
252
|
+
pluginRegistry.notify({ ...notice, duration: PLUGIN_SEED_NOTICE_MS });
|
|
253
|
+
},
|
|
254
|
+
});
|
|
255
|
+
}, [dispatch, getState, isDetachedWindow, pluginRegistry, pluginsReady, state.initialized]);
|
|
220
256
|
|
|
221
257
|
// What people keep on screen: the functions open in the workspace restored
|
|
222
258
|
// at launch, counted once per session. The layout is taken as restored,
|