@gloom-sh/terminal 0.19.6 → 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/LICENSE +0 -4
- package/package.json +6 -5
- package/patches/electrobun-devkit@2.0.5.patch +408 -0
- package/src/api-client/bond-trades.ts +59 -0
- package/src/api-client/crypto-markets.ts +20 -2
- package/src/api-client/data.ts +21 -0
- package/src/api-client/fund-facts.ts +23 -1
- package/src/api-client/index.ts +2 -0
- package/src/api-client/types/account.ts +86 -0
- package/src/api-client/types/assist.ts +32 -0
- package/src/api-client/types/auth.ts +63 -0
- package/src/api-client/types/billing.ts +54 -0
- package/src/api-client/types/chat.ts +180 -0
- package/src/api-client/types/congress.ts +107 -0
- package/src/api-client/types/credit.ts +110 -0
- package/src/api-client/types/econ.ts +158 -0
- package/src/api-client/types/equity-diagnostic.ts +73 -0
- package/src/api-client/types/filings-and-calls.ts +356 -0
- package/src/api-client/types/index.ts +25 -0
- package/src/api-client/types/jobs.ts +147 -0
- package/src/api-client/types/market.ts +122 -0
- package/src/api-client/types/news.ts +91 -0
- package/src/api-client/types/notes-and-theses.ts +172 -0
- package/src/api-client/types/quotes.ts +28 -0
- package/src/api-client/types/scanners.ts +125 -0
- package/src/api-client/types/screener.ts +65 -0
- package/src/api-client/types/search.ts +107 -0
- package/src/api-client/types/sync.ts +14 -0
- package/src/api-client/types/team-collections.ts +43 -0
- package/src/api-client/types/team-views.ts +32 -0
- package/src/api-client/types/teams.ts +135 -0
- package/src/api-client/types/ticker-data.ts +57 -0
- package/src/api-client/types/tweets.ts +59 -0
- package/src/api-client/types/world-venues.ts +23 -0
- package/src/app/runtime/desktop-deeplink.ts +41 -6
- package/src/app/runtime/plugin-seed.ts +119 -0
- package/src/app/runtime/startup.ts +45 -9
- package/src/app/star-prompt/status-line.tsx +1 -1
- package/src/app.tsx +2 -7
- package/src/architecture/ui-tokens-allowlist.json +0 -8
- 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 +78 -18
- package/src/cli/company-name-hint.ts +19 -0
- package/src/cli/desktop-pane-shot-browser.ts +69 -3
- 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/catalog.ts +3 -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/composite/use-composite-chart-keyboard.ts +11 -2
- 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/components/data-table/export.ts +4 -1
- package/src/components/layout/detached-pane-shell.tsx +10 -37
- package/src/components/layout/double-escape-close.ts +90 -0
- package/src/components/layout/header.tsx +3 -2
- package/src/components/layout/market-summary.ts +6 -3
- package/src/components/layout/pane/footer/index.tsx +2 -6
- package/src/components/layout/pane/footer/model.ts +6 -12
- package/src/components/layout/shell/active-drag.ts +53 -11
- package/src/components/layout/shell/drag/magnets.ts +128 -19
- package/src/components/layout/shell/pane/actions.ts +6 -2
- package/src/components/layout/shell/pane/management-shortcuts.ts +13 -51
- package/src/components/layout/status-bar.tsx +4 -78
- package/src/components/layout/status-widget-space.ts +5 -5
- package/src/components/onboarding/portfolio-step/positions-panel.tsx +1 -1
- package/src/components/ui/data-table/index.tsx +5 -1
- package/src/components/ui/data-table/render-cell.ts +19 -0
- package/src/components/ui/delayed-mark.tsx +59 -7
- package/src/components/ui/icon.tsx +1 -8
- package/src/components/ui/menu.tsx +6 -1
- package/src/i18n/es.ts +6 -3
- package/src/i18n/ja.ts +6 -3
- package/src/i18n/ko.ts +6 -3
- package/src/i18n/zh-cn.ts +6 -3
- package/src/i18n/zh-tw.ts +6 -3
- 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/chat/content/composer.tsx +21 -27
- package/src/plugins/builtin/chat/content/index.tsx +31 -3
- package/src/plugins/builtin/chat/content/shortcuts.ts +4 -2
- package/src/plugins/builtin/chat/content/snapshot.ts +0 -3
- package/src/plugins/builtin/cloud/auth-actions.tsx +51 -23
- package/src/plugins/builtin/cloud/trial-offer-status-widget.tsx +3 -3
- package/src/plugins/builtin/cloud/upgrade-status-widget.tsx +32 -25
- package/src/plugins/builtin/congress-trades/model.ts +2 -1
- package/src/plugins/builtin/congress-trades/pane.tsx +3 -0
- 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/custom-view/index.tsx +1 -1
- package/src/plugins/builtin/custom-view/loader.ts +85 -8
- package/src/plugins/builtin/custom-view/view-spec.ts +28 -0
- package/src/plugins/builtin/equity-screener/criterion-editor.tsx +13 -4
- package/src/plugins/builtin/equity-screener/headless.ts +33 -1
- package/src/plugins/builtin/equity-screener/model.ts +58 -15
- package/src/plugins/builtin/equity-screener/pane.tsx +36 -6
- package/src/plugins/builtin/executives/format.ts +5 -4
- package/src/plugins/builtin/executives/pane.tsx +1 -1
- package/src/plugins/builtin/help/index.tsx +55 -1
- package/src/plugins/builtin/insider/model.ts +30 -2
- package/src/plugins/builtin/jobs/model.ts +2 -2
- package/src/plugins/builtin/mna/model.ts +2 -2
- package/src/plugins/builtin/notes/files.ts +2 -0
- package/src/plugins/builtin/notes/owner.tsx +20 -1
- package/src/plugins/builtin/notes/quick-notes-pane.tsx +22 -4
- package/src/plugins/builtin/notes/store.ts +6 -1
- package/src/plugins/builtin/perps/headless.ts +8 -2
- package/src/plugins/builtin/portfolio-list/header.tsx +1 -1
- package/src/plugins/builtin/research/corporate-actions-pane.tsx +29 -25
- 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/series-inventory.ts +1 -0
- package/src/plugins/builtin/shared/earnings-report.ts +7 -2
- package/src/plugins/builtin/shared/pro-lock-note.ts +5 -1
- package/src/plugins/builtin/shared/use-quote-board.ts +85 -46
- package/src/plugins/builtin/short-interest/headless.ts +1 -1
- package/src/plugins/builtin/short-interest/model.ts +15 -6
- package/src/plugins/builtin/short-interest/types.ts +2 -0
- package/src/plugins/builtin/thirteenf/overlap-pane.tsx +3 -0
- package/src/plugins/builtin/thirteenf/pane.tsx +3 -0
- package/src/plugins/builtin/ticker-detail/overview/model.ts +19 -9
- package/src/plugins/builtin/ticker-detail/overview-tab.tsx +4 -4
- package/src/plugins/builtin/time-sales/headless.ts +23 -7
- package/src/plugins/builtin/time-sales/index.tsx +2 -2
- package/src/plugins/builtin/trace-bonds/detail.tsx +198 -0
- package/src/plugins/builtin/trace-bonds/headless.ts +62 -4
- package/src/plugins/builtin/trace-bonds/history.ts +155 -0
- package/src/plugins/builtin/trace-bonds/pane.tsx +64 -5
- package/src/plugins/extracted-plugins.ts +49 -24
- package/src/plugins/installer.ts +234 -32
- package/src/plugins/plugin-names.ts +11 -2
- package/src/plugins/running-installs.ts +34 -0
- package/src/plugins/seed-progress.ts +72 -0
- package/src/remote/controller.ts +9 -2
- package/src/remote/schema.ts +2 -1
- package/src/renderers/cloudflare/http-proxy.ts +67 -8
- package/src/renderers/cloudflare/proxy-session.ts +1 -1
- package/src/renderers/cloudflare/worker.ts +29 -2
- package/src/renderers/dom/desktop/icons.tsx +0 -2
- package/src/renderers/dom/styles.css +0 -3
- 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/desktop/install-records.ts +59 -0
- package/src/renderers/electrobun/bun/desktop/installer-folder.ts +208 -592
- package/src/renderers/electrobun/bun/desktop/macos-objc.ts +14 -0
- package/src/renderers/electrobun/bun/desktop/update.ts +1 -1
- package/src/renderers/electrobun/bun/index.ts +24 -13
- package/src/renderers/electrobun/bun/window/context-menu-thread.ts +84 -0
- package/src/renderers/electrobun/bun/window/create.ts +23 -3
- package/src/renderers/electrobun/bun/window/electrobun-window-host.ts +4 -4
- package/src/renderers/electrobun/bun/window/events.ts +4 -4
- package/src/renderers/electrobun/bun/window/frame.ts +2 -1
- package/src/renderers/electrobun/bun/window/native-call-thread.ts +224 -0
- package/src/renderers/electrobun/bun/window/native-min-size.ts +322 -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 +8 -1
- 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/sources/gloomberb-cloud/index.ts +5 -7
- package/src/sources/provider-router/batches.ts +18 -3
- package/src/sources/provider-router/financials.ts +18 -4
- package/src/telemetry/stall-reports.ts +21 -4
- package/src/types/data-provider.ts +14 -0
- package/src/types/financials.ts +15 -3
- package/src/types/headless.ts +2 -0
- package/src/utils/double-escape-close.ts +38 -16
- package/src/utils/format.ts +23 -3
- package/src/utils/main-thread-stall.ts +21 -5
- package/src/utils/perf-marks.ts +88 -9
- package/src/utils/price-earnings.ts +18 -0
- package/src/utils/reported-money.ts +9 -2
- package/src/utils/sec.ts +34 -3
- package/patches/electrobun@1.18.1.patch +0 -633
- package/src/api-client/types.ts +0 -2441
- package/src/plugins/seed-notice.ts +0 -20
package/src/plugins/installer.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { logFailure } from "../utils/log-failure";
|
|
2
2
|
import { basename, join, resolve } from "path";
|
|
3
|
-
import { existsSync, lstatSync, mkdirSync, readdirSync, rmSync, symlinkSync } from "fs";
|
|
3
|
+
import { existsSync, lstatSync, mkdirSync, readdirSync, renameSync, rmSync, symlinkSync } from "fs";
|
|
4
4
|
import { execFile as execFileCallback, execFileSync, spawn } from "child_process";
|
|
5
5
|
import { promisify } from "util";
|
|
6
6
|
import { findAbsorbedPlugin, type AbsorbedPlugin } from "./absorbed";
|
|
7
7
|
import type { PluginPin } from "./marketplace/store";
|
|
8
|
-
import { bunCommand, recordDependencyInstall } from "./dependencies";
|
|
8
|
+
import { bunCommand, missingPluginDependencies, recordDependencyInstall } from "./dependencies";
|
|
9
9
|
import { linkHostPackages, missingPeerPlugins } from "./host-link";
|
|
10
10
|
import { importSiblingsFromTheirFolders } from "./peer-imports";
|
|
11
11
|
import {
|
|
@@ -19,6 +19,7 @@ import {
|
|
|
19
19
|
import { pluginDirectoryNames } from "./plugin-names";
|
|
20
20
|
import { gitInstallAdvice } from "./extracted-plugins";
|
|
21
21
|
import { pluginFromModule } from "./plugin-export";
|
|
22
|
+
import { INSTALL_TIMED_OUT, trackInstallCommand } from "./running-installs";
|
|
22
23
|
import type { GloomPlugin } from "../types/plugin";
|
|
23
24
|
import { cliStyles } from "../utils/cli-output";
|
|
24
25
|
import { compareSemver, requiredGloomberb } from "../utils/semver";
|
|
@@ -45,6 +46,18 @@ function ensurePluginsDir() {
|
|
|
45
46
|
|
|
46
47
|
const GITHUB_SEGMENT_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._-]*(?![\s\S])/;
|
|
47
48
|
const COMMIT_PATTERN = /^[0-9a-f]{7,40}$/i;
|
|
49
|
+
/**
|
|
50
|
+
* A tag or branch name as git spells one: never starting with a dash, which
|
|
51
|
+
* git would read as an option, and without `..`, `//`, `@{`, a trailing slash
|
|
52
|
+
* or dot, or `.lock` at the end.
|
|
53
|
+
*/
|
|
54
|
+
const PIN_REF_PATTERN = /^(?!.*\.\.)(?!.*\/\/)(?!.*@\{)(?!.*\.lock$)(?!.*[./]$)[A-Za-z0-9][A-Za-z0-9._/@+-]*$/;
|
|
55
|
+
|
|
56
|
+
/** The registry pin's tag or branch, refused unless it is plainly one. */
|
|
57
|
+
export function validatePinRef(ref: string): string {
|
|
58
|
+
if (ref.length > 200 || !PIN_REF_PATTERN.test(ref)) throw new Error(`Invalid ref in registry pin: ${JSON.stringify(ref)}.`);
|
|
59
|
+
return ref;
|
|
60
|
+
}
|
|
48
61
|
|
|
49
62
|
export function validatePluginDirectoryName(name: string): string {
|
|
50
63
|
if (!GITHUB_SEGMENT_PATTERN.test(name)) {
|
|
@@ -91,6 +104,19 @@ export interface PluginInstallOptions {
|
|
|
91
104
|
*/
|
|
92
105
|
quiet?: boolean;
|
|
93
106
|
pin?: PluginPin;
|
|
107
|
+
/**
|
|
108
|
+
* How long each git command, and the dependency install, may run before it
|
|
109
|
+
* is stopped and the install fails with the code `INSTALL_TIMED_OUT`. No
|
|
110
|
+
* limit when absent.
|
|
111
|
+
*/
|
|
112
|
+
timeouts?: { gitMs: number; dependenciesMs: number };
|
|
113
|
+
/**
|
|
114
|
+
* Fail, leaving nothing installed, when the plugin's dependencies do not
|
|
115
|
+
* all install, rather than keep a checkout that only loads once the loader
|
|
116
|
+
* fetches them. For an install nobody is watching, which the next launch
|
|
117
|
+
* retries.
|
|
118
|
+
*/
|
|
119
|
+
requireDependencies?: boolean;
|
|
94
120
|
}
|
|
95
121
|
|
|
96
122
|
export interface PluginDirectoryInfo {
|
|
@@ -103,7 +129,7 @@ export interface PluginDirectoryInfo {
|
|
|
103
129
|
}
|
|
104
130
|
|
|
105
131
|
class GitError extends Error {
|
|
106
|
-
constructor(message: string, readonly stderr: string) {
|
|
132
|
+
constructor(message: string, readonly stderr: string, readonly timedOut = false) {
|
|
107
133
|
super(stderr.trim() ? `${message}: ${stderr.trim().split("\n").pop()}` : message);
|
|
108
134
|
this.name = "GitError";
|
|
109
135
|
}
|
|
@@ -113,6 +139,16 @@ interface RunResult {
|
|
|
113
139
|
code: number | null;
|
|
114
140
|
stdout: string;
|
|
115
141
|
stderr: string;
|
|
142
|
+
/** Stopped at its time limit. */
|
|
143
|
+
timedOut?: boolean;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/** How long a command stopped at its time limit has to exit before it is killed. */
|
|
147
|
+
const KILL_GRACE_MS = 2_000;
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
function seconds(ms: number): string {
|
|
151
|
+
return `${Math.round(ms / 1000)} s`;
|
|
116
152
|
}
|
|
117
153
|
|
|
118
154
|
/** Resolves git before a command changes into a plugin checkout. */
|
|
@@ -122,11 +158,30 @@ function gitExecutable(): string {
|
|
|
122
158
|
return executable;
|
|
123
159
|
}
|
|
124
160
|
|
|
161
|
+
/** Ends a Windows process and every process it started; `fallback` when taskkill cannot run. */
|
|
162
|
+
function stopWindowsTree(pid: number, fallback: () => void): void {
|
|
163
|
+
const killer = spawn("taskkill", ["/T", "/F", "/PID", String(pid)], { stdio: "ignore", windowsHide: true });
|
|
164
|
+
killer.once("error", () => {
|
|
165
|
+
try {
|
|
166
|
+
fallback();
|
|
167
|
+
} catch {
|
|
168
|
+
// Intentional ignore: it exited between the check and the signal.
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
killer.unref();
|
|
172
|
+
}
|
|
173
|
+
|
|
125
174
|
/**
|
|
126
175
|
* Runs a command without blocking the event loop: a fetch or `bun install`
|
|
127
176
|
* takes seconds, and the terminal UI and the desktop's Bun process keep
|
|
128
177
|
* serving the app while a plugin updates in the background. Rejects only
|
|
129
178
|
* when the command cannot be started at all.
|
|
179
|
+
*
|
|
180
|
+
* With `timeoutMs`, a command still running then is stopped and the result
|
|
181
|
+
* says so at once: a clone whose connection stalls would otherwise hold its
|
|
182
|
+
* install for good. The helpers git starts for the transfer are stopped with
|
|
183
|
+
* it: off Windows it runs in a process group of its own, and on Windows
|
|
184
|
+
* `taskkill /T` ends its process tree, where a signal reaches only git.
|
|
130
185
|
*/
|
|
131
186
|
function run(
|
|
132
187
|
command: string,
|
|
@@ -134,15 +189,56 @@ function run(
|
|
|
134
189
|
cwd: string,
|
|
135
190
|
output: { stdout: "pipe" | "inherit"; stderr: "pipe" | "inherit" },
|
|
136
191
|
env?: NodeJS.ProcessEnv,
|
|
192
|
+
timeoutMs?: number,
|
|
137
193
|
): Promise<RunResult> {
|
|
138
194
|
return new Promise((resolveRun, reject) => {
|
|
139
|
-
const
|
|
195
|
+
const group = timeoutMs !== undefined && process.platform !== "win32";
|
|
196
|
+
const child = spawn(command === "git" ? gitExecutable() : command, args, {
|
|
197
|
+
cwd,
|
|
198
|
+
env,
|
|
199
|
+
stdio: ["ignore", output.stdout, output.stderr],
|
|
200
|
+
...(group ? { detached: true } : {}),
|
|
201
|
+
});
|
|
140
202
|
let stdout = "";
|
|
141
203
|
let stderr = "";
|
|
204
|
+
let settled = false;
|
|
205
|
+
const stop = (signal: NodeJS.Signals) => {
|
|
206
|
+
try {
|
|
207
|
+
if (group && child.pid) process.kill(-child.pid, signal);
|
|
208
|
+
else if (timeoutMs !== undefined && process.platform === "win32" && child.pid) stopWindowsTree(child.pid, () => child.kill(signal));
|
|
209
|
+
else child.kill(signal);
|
|
210
|
+
} catch {
|
|
211
|
+
// Intentional ignore: it exited between the check and the signal.
|
|
212
|
+
}
|
|
213
|
+
};
|
|
214
|
+
// An install with a limit is one nobody waits on: quitting stops it.
|
|
215
|
+
const forget = timeoutMs === undefined ? null : trackInstallCommand(() => stop("SIGKILL"));
|
|
216
|
+
child.once("exit", () => forget?.());
|
|
217
|
+
const timer = timeoutMs === undefined ? null : setTimeout(() => {
|
|
218
|
+
if (settled) return;
|
|
219
|
+
settled = true;
|
|
220
|
+
stop("SIGTERM");
|
|
221
|
+
// A command that ignores the request is not left running.
|
|
222
|
+
setTimeout(() => stop("SIGKILL"), KILL_GRACE_MS).unref?.();
|
|
223
|
+
child.stdout?.destroy();
|
|
224
|
+
child.stderr?.destroy();
|
|
225
|
+
resolveRun({ code: null, stdout, stderr, timedOut: true });
|
|
226
|
+
}, timeoutMs);
|
|
142
227
|
child.stdout?.setEncoding("utf-8").on("data", (chunk: string) => { stdout += chunk; });
|
|
143
228
|
child.stderr?.setEncoding("utf-8").on("data", (chunk: string) => { stderr += chunk; });
|
|
144
|
-
child.once("error",
|
|
145
|
-
|
|
229
|
+
child.once("error", (error) => {
|
|
230
|
+
if (timer) clearTimeout(timer);
|
|
231
|
+
forget?.();
|
|
232
|
+
if (settled) return;
|
|
233
|
+
settled = true;
|
|
234
|
+
reject(error);
|
|
235
|
+
});
|
|
236
|
+
child.once("close", (code) => {
|
|
237
|
+
if (timer) clearTimeout(timer);
|
|
238
|
+
if (settled) return;
|
|
239
|
+
settled = true;
|
|
240
|
+
resolveRun({ code, stdout, stderr });
|
|
241
|
+
});
|
|
146
242
|
});
|
|
147
243
|
}
|
|
148
244
|
|
|
@@ -169,18 +265,19 @@ function gitMissingMessage(platform: string = process.platform): string {
|
|
|
169
265
|
* the detached-HEAD advice a pinned checkout prints are chatter, and a failure
|
|
170
266
|
* says what went wrong in its error, from git's last line.
|
|
171
267
|
*/
|
|
172
|
-
async function git(args: string[], cwd: string, quiet: boolean, failure: string): Promise<string> {
|
|
268
|
+
async function git(args: string[], cwd: string, quiet: boolean, failure: string, timeoutMs?: number): Promise<string> {
|
|
173
269
|
// Quiet means the app owns the screen, or there is no terminal at all: a
|
|
174
270
|
// repository that wants credentials fails instead of prompting on it.
|
|
175
271
|
const env = quiet ? { ...process.env, GIT_TERMINAL_PROMPT: "0" } : undefined;
|
|
176
272
|
let result: RunResult;
|
|
177
273
|
try {
|
|
178
|
-
result = await run("git", ["-c", "advice.detachedHead=false", ...args], cwd, { stdout: "pipe", stderr: "pipe" }, env);
|
|
274
|
+
result = await run("git", ["-c", "advice.detachedHead=false", ...args], cwd, { stdout: "pipe", stderr: "pipe" }, env, timeoutMs);
|
|
179
275
|
} catch (error) {
|
|
180
276
|
// git could not start: almost always because it is not installed.
|
|
181
277
|
const missing = (error as NodeJS.ErrnoException | null)?.code === "ENOENT";
|
|
182
278
|
throw new GitError(failure, missing ? gitMissingMessage() : String(error));
|
|
183
279
|
}
|
|
280
|
+
if (result.timedOut) throw new GitError(failure, `no answer within ${seconds(timeoutMs!)}`, true);
|
|
184
281
|
if (result.code !== 0) throw new GitError(failure, result.stderr);
|
|
185
282
|
return result.stdout.trim();
|
|
186
283
|
}
|
|
@@ -200,12 +297,13 @@ function pinMatches(commit: string | null, expected: string | undefined): boolea
|
|
|
200
297
|
* is what the ref names and the pinned commit (when known) only verifies it;
|
|
201
298
|
* with a commit alone, that commit is fetched directly.
|
|
202
299
|
*/
|
|
203
|
-
async function fetchPin(targetDir: string, pin: PluginPin, quiet: boolean): Promise<string> {
|
|
300
|
+
async function fetchPin(targetDir: string, pin: PluginPin, quiet: boolean, timeoutMs?: number): Promise<string> {
|
|
204
301
|
const wanted = pin.ref ?? pin.commit;
|
|
205
302
|
if (!wanted) throw new Error("The registry pin names no ref or commit.");
|
|
303
|
+
if (pin.ref) validatePinRef(pin.ref);
|
|
206
304
|
if (pin.commit && !COMMIT_PATTERN.test(pin.commit)) throw new Error(`Invalid commit in registry pin: ${pin.commit}`);
|
|
207
|
-
await git(["fetch", "--depth", "1", "origin", wanted], targetDir, quiet, `Could not fetch ${wanted}
|
|
208
|
-
const commit = await git(["rev-parse", "FETCH_HEAD^{commit}"], targetDir, quiet, `Could not read ${wanted}
|
|
305
|
+
await git(["fetch", "--depth", "1", "origin", "--", wanted], targetDir, quiet, `Could not fetch ${wanted}`, timeoutMs);
|
|
306
|
+
const commit = await git(["rev-parse", "FETCH_HEAD^{commit}"], targetDir, quiet, `Could not read ${wanted}`, timeoutMs);
|
|
209
307
|
if (!pinMatches(commit, pin.commit)) {
|
|
210
308
|
throw new Error(`${pin.ref ?? "The pinned ref"} now points at ${commit.slice(0, 7)}, the registry reviewed ${pin.commit!.slice(0, 7)}.`);
|
|
211
309
|
}
|
|
@@ -213,8 +311,8 @@ async function fetchPin(targetDir: string, pin: PluginPin, quiet: boolean): Prom
|
|
|
213
311
|
}
|
|
214
312
|
|
|
215
313
|
/** Leaves HEAD detached at one exact commit, which is the state `update` expects to find. */
|
|
216
|
-
async function checkoutCommit(targetDir: string, commit: string, quiet: boolean): Promise<void> {
|
|
217
|
-
await git(["checkout", "--detach", "--force", commit], targetDir, quiet, `Could not check out ${commit.slice(0, 7)}
|
|
314
|
+
async function checkoutCommit(targetDir: string, commit: string, quiet: boolean, timeoutMs?: number): Promise<void> {
|
|
315
|
+
await git(["checkout", "--detach", "--force", commit], targetDir, quiet, `Could not check out ${commit.slice(0, 7)}`, timeoutMs);
|
|
218
316
|
}
|
|
219
317
|
|
|
220
318
|
|
|
@@ -269,14 +367,19 @@ export async function describeOlderCommit(dir: string, installed: string, candid
|
|
|
269
367
|
}
|
|
270
368
|
|
|
271
369
|
/** Brings `targetDir` to the pinned commit. */
|
|
272
|
-
async function checkoutPin(targetDir: string, pin: PluginPin, quiet: boolean): Promise<void> {
|
|
370
|
+
async function checkoutPin(targetDir: string, pin: PluginPin, quiet: boolean, timeoutMs?: number): Promise<void> {
|
|
273
371
|
if (!pin.ref && !pin.commit) return;
|
|
274
|
-
await checkoutCommit(targetDir, await fetchPin(targetDir, pin, quiet), quiet);
|
|
372
|
+
await checkoutCommit(targetDir, await fetchPin(targetDir, pin, quiet, timeoutMs), quiet, timeoutMs);
|
|
275
373
|
}
|
|
276
374
|
|
|
277
|
-
|
|
375
|
+
/**
|
|
376
|
+
* Runs `bun install` in `targetDir` and links the host. `recordAs` is the
|
|
377
|
+
* folder the plugin is installed under, when `targetDir` is where it is
|
|
378
|
+
* being put together. Null when there was nothing to install or no bun.
|
|
379
|
+
*/
|
|
380
|
+
async function installDependencies(targetDir: string, quiet: boolean, timeoutMs?: number, recordAs: string = targetDir): Promise<RunResult | null> {
|
|
278
381
|
const pkgPath = join(targetDir, "package.json");
|
|
279
|
-
if (!existsSync(pkgPath)) return;
|
|
382
|
+
if (!existsSync(pkgPath)) return null;
|
|
280
383
|
if (!quiet) console.log(cliStyles.muted("Installing plugin dependencies..."));
|
|
281
384
|
// --production: plugin repos depend on `gloomberb` as a devDependency so
|
|
282
385
|
// their own CI can typecheck against the real API. At runtime the host is
|
|
@@ -285,7 +388,7 @@ async function installDependencies(targetDir: string, quiet: boolean): Promise<v
|
|
|
285
388
|
const output = quiet ? "pipe" : "inherit";
|
|
286
389
|
const bun = bunCommand();
|
|
287
390
|
const result = bun
|
|
288
|
-
? await recordDependencyInstall(
|
|
391
|
+
? await recordDependencyInstall(recordAs, () => run(bun.command, ["install", "--production"], targetDir, { stdout: output, stderr: output }, bun.env, timeoutMs)
|
|
289
392
|
.catch(logFailure("plugin-installer", "Plugin dependency installation failed", null)))
|
|
290
393
|
: null;
|
|
291
394
|
if (result?.code !== 0 && !quiet) console.error(cliStyles.warning("Warning: failed to install plugin dependencies."));
|
|
@@ -296,6 +399,7 @@ async function installDependencies(targetDir: string, quiet: boolean): Promise<v
|
|
|
296
399
|
console.error(cliStyles.warning(`Warning: could not link the Gloom runtime (${link.error}).`));
|
|
297
400
|
console.error(cliStyles.muted("The plugin's \"gloomberb/*\" imports will not resolve."));
|
|
298
401
|
}
|
|
402
|
+
return result;
|
|
299
403
|
}
|
|
300
404
|
|
|
301
405
|
async function readPluginExport(targetDir: string): Promise<Pick<GloomPlugin, "id" | "name" | "version"> | null> {
|
|
@@ -338,37 +442,67 @@ export async function installPlugin(ref: string, options: PluginInstallOptions =
|
|
|
338
442
|
ensurePluginsDir();
|
|
339
443
|
const targetDir = join(PLUGINS_DIR, name);
|
|
340
444
|
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
}
|
|
445
|
+
const alreadyInstalled = () => fail(`Plugin "${name}" already exists.`, `Use "gloom update ${name}" to refresh it.`);
|
|
446
|
+
if (existsSync(targetDir)) alreadyInstalled();
|
|
344
447
|
|
|
345
448
|
say(cliStyles.accent(`Installing ${name}`));
|
|
346
449
|
say(cliStyles.muted(url));
|
|
347
450
|
|
|
451
|
+
// Put together beside the plugins, under a dot name the loader and the
|
|
452
|
+
// seeder pass over, and moved into place only once complete: an install
|
|
453
|
+
// stopped half way (the app quit, a limit hit) never leaves a folder that
|
|
454
|
+
// passes for the plugin.
|
|
455
|
+
removeAbandonedInstalls();
|
|
456
|
+
const stagingDir = join(PLUGINS_DIR, `${STAGING_PREFIX}${name}-${process.pid}-${++stagingCount}`);
|
|
457
|
+
const timeoutMs = options.timeouts?.gitMs;
|
|
348
458
|
const pin = options.pin ?? {};
|
|
349
459
|
try {
|
|
350
460
|
const cloneArgs = ["clone", "--depth", "1"];
|
|
351
|
-
if (pin.ref) cloneArgs.push(
|
|
352
|
-
cloneArgs.push(url,
|
|
353
|
-
await git(cloneArgs, PLUGINS_DIR, quiet, `Failed to clone ${url}
|
|
461
|
+
if (pin.ref) cloneArgs.push(`--branch=${validatePinRef(pin.ref)}`);
|
|
462
|
+
cloneArgs.push("--", url, stagingDir);
|
|
463
|
+
await git(cloneArgs, PLUGINS_DIR, quiet, `Failed to clone ${url}`, timeoutMs);
|
|
354
464
|
if (pin.ref) {
|
|
355
|
-
const commit = readPluginCommit(
|
|
465
|
+
const commit = readPluginCommit(stagingDir);
|
|
356
466
|
if (!pinMatches(commit, pin.commit)) {
|
|
357
467
|
throw new Error(`${pin.ref} now points at ${commit?.slice(0, 7) ?? "?"}, the registry reviewed ${pin.commit!.slice(0, 7)}.`);
|
|
358
468
|
}
|
|
359
469
|
} else if (pin.commit) {
|
|
360
|
-
await checkoutPin(
|
|
470
|
+
await checkoutPin(stagingDir, pin, quiet, timeoutMs);
|
|
361
471
|
}
|
|
362
472
|
// A fork under another name says what it is in its gloom.json.
|
|
363
|
-
refuseAbsorbed(findAbsorbedCheckout(
|
|
473
|
+
refuseAbsorbed(findAbsorbedCheckout(stagingDir));
|
|
474
|
+
|
|
475
|
+
if (pin.ref || pin.commit) say(cliStyles.muted(`Pinned to ${pin.ref ?? pin.commit}`));
|
|
476
|
+
|
|
477
|
+
const dependenciesMs = options.timeouts?.dependenciesMs;
|
|
478
|
+
const dependencies = await installDependencies(stagingDir, quiet, dependenciesMs, targetDir);
|
|
479
|
+
if (dependencies?.timedOut) {
|
|
480
|
+
throw Object.assign(new Error(`Installing ${name}'s dependencies took longer than ${seconds(dependenciesMs!)}.`), { timedOut: true });
|
|
481
|
+
}
|
|
482
|
+
if (options.requireDependencies) {
|
|
483
|
+
const missing = missingPluginDependencies(stagingDir);
|
|
484
|
+
if (missing.length > 0) throw new Error(`${name}'s dependencies did not install: ${missing.join(", ")}.`);
|
|
485
|
+
}
|
|
364
486
|
} catch (error) {
|
|
365
|
-
|
|
366
|
-
|
|
487
|
+
removeStaging(stagingDir);
|
|
488
|
+
const timedOut = (error as { timedOut?: unknown } | null)?.timedOut === true;
|
|
489
|
+
fail(error instanceof Error ? error.message : String(error), undefined, timedOut ? INSTALL_TIMED_OUT : undefined);
|
|
367
490
|
}
|
|
368
491
|
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
492
|
+
let moved = false;
|
|
493
|
+
try {
|
|
494
|
+
moved = await moveIntoPlace(stagingDir, targetDir);
|
|
495
|
+
} catch (error) {
|
|
496
|
+
removeStaging(stagingDir);
|
|
497
|
+
fail(error instanceof Error ? error.message : String(error));
|
|
498
|
+
}
|
|
499
|
+
if (!moved) {
|
|
500
|
+
removeStaging(stagingDir);
|
|
501
|
+
// Another install of it finished first: the app beside this one, or a second click.
|
|
502
|
+
alreadyInstalled();
|
|
503
|
+
}
|
|
504
|
+
// The links were made from where it was put together.
|
|
505
|
+
linkHostPackages(targetDir);
|
|
372
506
|
|
|
373
507
|
const missing = missingPeerPlugins(targetDir);
|
|
374
508
|
if (missing.length > 0) {
|
|
@@ -378,6 +512,74 @@ export async function installPlugin(ref: string, options: PluginInstallOptions =
|
|
|
378
512
|
return validateInstall(targetDir, name, quiet);
|
|
379
513
|
}
|
|
380
514
|
|
|
515
|
+
/** Where an install is put together: `.installing-<name>-<pid>-<n>` in the plugins folder. */
|
|
516
|
+
const STAGING_PREFIX = ".installing-";
|
|
517
|
+
const STAGING_NAME = /^\.installing-.+-(\d+)-\d+$/;
|
|
518
|
+
let stagingCount = 0;
|
|
519
|
+
|
|
520
|
+
function processRunning(pid: number): boolean {
|
|
521
|
+
try {
|
|
522
|
+
process.kill(pid, 0);
|
|
523
|
+
return true;
|
|
524
|
+
} catch (error) {
|
|
525
|
+
// EPERM: it runs, as another user.
|
|
526
|
+
return (error as NodeJS.ErrnoException | null)?.code === "EPERM";
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
/**
|
|
531
|
+
* Removes an install's staging folder. A folder that will not go (a git
|
|
532
|
+
* helper that outlived its stop still holds it on Windows, a read-only file)
|
|
533
|
+
* never replaces the reason the install failed: it carries a name the loader
|
|
534
|
+
* passes over, and a later install clears it once its process has ended.
|
|
535
|
+
*/
|
|
536
|
+
function removeStaging(stagingDir: string): void {
|
|
537
|
+
try {
|
|
538
|
+
rmSync(stagingDir, { recursive: true, force: true });
|
|
539
|
+
} catch (error) {
|
|
540
|
+
logFailure("plugin-installer", "Could not remove an unfinished plugin install")(error);
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
/**
|
|
545
|
+
* Drops what installs left behind when their process ended mid-way. Best
|
|
546
|
+
* effort: one that cannot be removed stays, and never stops this install.
|
|
547
|
+
*/
|
|
548
|
+
function removeAbandonedInstalls(): void {
|
|
549
|
+
let entries: string[];
|
|
550
|
+
try {
|
|
551
|
+
entries = readdirSync(PLUGINS_DIR);
|
|
552
|
+
} catch (error) {
|
|
553
|
+
logFailure("plugin-installer", "Could not list the plugins folder for unfinished installs")(error);
|
|
554
|
+
return;
|
|
555
|
+
}
|
|
556
|
+
for (const entry of entries) {
|
|
557
|
+
const pid = Number(STAGING_NAME.exec(entry)?.[1]);
|
|
558
|
+
if (!pid || pid === process.pid || processRunning(pid)) continue;
|
|
559
|
+
removeStaging(join(PLUGINS_DIR, entry));
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
/**
|
|
564
|
+
* Renames the finished install into place. False when the folder is taken.
|
|
565
|
+
* Windows refuses a rename while a scanner still holds a file just written,
|
|
566
|
+
* so a refusal there is tried again for a moment.
|
|
567
|
+
*/
|
|
568
|
+
async function moveIntoPlace(stagingDir: string, targetDir: string): Promise<boolean> {
|
|
569
|
+
for (let attempt = 0; ; attempt += 1) {
|
|
570
|
+
if (existsSync(targetDir)) return false;
|
|
571
|
+
try {
|
|
572
|
+
renameSync(stagingDir, targetDir);
|
|
573
|
+
return true;
|
|
574
|
+
} catch (error) {
|
|
575
|
+
const code = (error as NodeJS.ErrnoException | null)?.code;
|
|
576
|
+
if (existsSync(targetDir)) return false;
|
|
577
|
+
if (attempt >= 10 || (code !== "EPERM" && code !== "EBUSY" && code !== "EACCES")) throw error;
|
|
578
|
+
await Bun.sleep(200);
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
|
|
381
583
|
/** Reads the export of a checkout that was just installed, and says what it is. */
|
|
382
584
|
async function validateInstall(targetDir: string, name: string, quiet: boolean): Promise<PluginDirectoryInfo> {
|
|
383
585
|
const say = (message: string) => {
|
|
@@ -11,20 +11,29 @@
|
|
|
11
11
|
*/
|
|
12
12
|
const PLUGIN_NAME_PREFIXES = ["gloom-", "gloomberb-"] as const;
|
|
13
13
|
|
|
14
|
+
/**
|
|
15
|
+
* A plugin package name is one folder name: a prefix, then letters, digits,
|
|
16
|
+
* dots, dashes and underscores. A name read from a plugin's manifest is
|
|
17
|
+
* joined to the plugins folder, so a slash or a backslash would reach past it.
|
|
18
|
+
*/
|
|
19
|
+
const PLUGIN_PACKAGE_NAME = /^(?:gloom|gloomberb)-[A-Za-z0-9][A-Za-z0-9._-]*$/;
|
|
20
|
+
|
|
14
21
|
/** True for a name that belongs to a plugin package under either product name. */
|
|
15
22
|
export function isPluginPackageName(name: string): boolean {
|
|
16
|
-
return
|
|
23
|
+
return PLUGIN_PACKAGE_NAME.test(name);
|
|
17
24
|
}
|
|
18
25
|
|
|
19
26
|
/**
|
|
20
27
|
* The directory names a plugin could be installed under, the given name first.
|
|
21
28
|
*
|
|
22
29
|
* A name with neither prefix is returned alone, so this is safe to call on any
|
|
23
|
-
* dependency name.
|
|
30
|
+
* dependency name. A name with a prefix that is not a plugin package name has
|
|
31
|
+
* no folder to look in.
|
|
24
32
|
*/
|
|
25
33
|
export function pluginDirectoryNames(name: string): string[] {
|
|
26
34
|
for (const prefix of PLUGIN_NAME_PREFIXES) {
|
|
27
35
|
if (!name.startsWith(prefix)) continue;
|
|
36
|
+
if (!isPluginPackageName(name)) return [];
|
|
28
37
|
const other = PLUGIN_NAME_PREFIXES.find((candidate) => candidate !== prefix);
|
|
29
38
|
return [name, `${other}${name.slice(prefix.length)}`];
|
|
30
39
|
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The commands of installs nobody waits on (a launch's restore of plugins
|
|
3
|
+
* that moved out of Gloom), which quitting the app stops rather than leave a
|
|
4
|
+
* download running after it. Kept apart from the installer, so the app's way
|
|
5
|
+
* out reaches them without loading it. A process exit stops them as well,
|
|
6
|
+
* but the app cannot count on that event, so it calls this on its way out.
|
|
7
|
+
*/
|
|
8
|
+
/** The code of an install that failed because a step ran past its time limit: the network did not answer. */
|
|
9
|
+
export const INSTALL_TIMED_OUT = "install_timed_out";
|
|
10
|
+
|
|
11
|
+
const running = new Set<() => void>();
|
|
12
|
+
let stopsOnExit = false;
|
|
13
|
+
/** Set on the way out: a command started after that, as the next install begins, stops at once. */
|
|
14
|
+
let stopped = false;
|
|
15
|
+
|
|
16
|
+
export function trackInstallCommand(stop: () => void): () => void {
|
|
17
|
+
if (stopped) {
|
|
18
|
+
stop();
|
|
19
|
+
return () => {};
|
|
20
|
+
}
|
|
21
|
+
if (!stopsOnExit) {
|
|
22
|
+
stopsOnExit = true;
|
|
23
|
+
process.once("exit", stopInstallCommands);
|
|
24
|
+
}
|
|
25
|
+
running.add(stop);
|
|
26
|
+
return () => { running.delete(stop); };
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** Stops every one still running, and any started from now on. */
|
|
30
|
+
export function stopInstallCommands(): void {
|
|
31
|
+
stopped = true;
|
|
32
|
+
for (const stop of [...running]) stop();
|
|
33
|
+
running.clear();
|
|
34
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import type { AppConfig, PluginSeedFailure } from "../types/config";
|
|
2
|
+
import { logFailure } from "../utils/log-failure";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The plugins this launch is installing because they moved out of Gloom into
|
|
6
|
+
* their own repositories (extracted-plugins.ts), as the app sees them.
|
|
7
|
+
*
|
|
8
|
+
* The installs run after the first frame, in the process that can run git and
|
|
9
|
+
* bun: the terminal's own, or the desktop's Bun process, which passes each
|
|
10
|
+
* change to its main window. The app brings every plugin into the session as
|
|
11
|
+
* it lands, then records the outcome in its config and says what could not be
|
|
12
|
+
* installed. Until then the panes they add stay in the layout, hidden like
|
|
13
|
+
* any pane whose plugin is not there, and appear in place once it is.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
export interface PluginSeedNotice {
|
|
17
|
+
body: string;
|
|
18
|
+
type: "error" | "info";
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export type PluginSeedRecord = Pick<AppConfig, "seededPlugins" | "pluginSeedFailure">;
|
|
22
|
+
|
|
23
|
+
export interface PluginSeedEntry {
|
|
24
|
+
id: string;
|
|
25
|
+
name: string;
|
|
26
|
+
state: "installing" | "installed" | "failed";
|
|
27
|
+
/** Its folder once installed, and the sibling plugins it brought along. */
|
|
28
|
+
directory?: string;
|
|
29
|
+
peers?: string[];
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface PluginSeedProgress {
|
|
33
|
+
/** Grows with every change, so a snapshot that arrives late is ignored. */
|
|
34
|
+
seq: number;
|
|
35
|
+
plugins: PluginSeedEntry[];
|
|
36
|
+
/** Set once every install is over: what the config records, and what to tell the user. */
|
|
37
|
+
outcome?: { record: PluginSeedRecord; notice: PluginSeedNotice | null };
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** Whether two recorded seed failures are the same: the same plugins, for the same reason. */
|
|
41
|
+
export function samePluginSeedFailure(a: PluginSeedFailure | undefined, b: PluginSeedFailure | undefined): boolean {
|
|
42
|
+
return a?.gitMissing === b?.gitMissing && (a?.plugins ?? []).join() === (b?.plugins ?? []).join();
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
let progress: PluginSeedProgress | null = null;
|
|
46
|
+
const listeners = new Set<() => void>();
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Adopts a snapshot unless an equal or newer one is already here. A listener
|
|
50
|
+
* that throws (the desktop's send to a window that is closing) is logged and
|
|
51
|
+
* the others still hear: the install it reports has happened either way.
|
|
52
|
+
*/
|
|
53
|
+
export function publishPluginSeedProgress(next: PluginSeedProgress): void {
|
|
54
|
+
if (progress && next.seq <= progress.seq) return;
|
|
55
|
+
progress = next;
|
|
56
|
+
for (const listener of [...listeners]) {
|
|
57
|
+
try {
|
|
58
|
+
listener();
|
|
59
|
+
} catch (error) {
|
|
60
|
+
logFailure("plugin-seed", "A plugin restore progress listener failed")(error);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export function getPluginSeedProgress(): PluginSeedProgress | null {
|
|
66
|
+
return progress;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export function subscribePluginSeed(listener: () => void): () => void {
|
|
70
|
+
listeners.add(listener);
|
|
71
|
+
return () => { listeners.delete(listener); };
|
|
72
|
+
}
|
package/src/remote/controller.ts
CHANGED
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
customViewInstanceSettings,
|
|
18
18
|
parseViewSpecOr,
|
|
19
19
|
trialLoadViewSource,
|
|
20
|
+
UnknownViewKeysError,
|
|
20
21
|
type ViewSpec,
|
|
21
22
|
} from "../plugins/builtin/custom-view";
|
|
22
23
|
import { findPaneInstance, getPlacedPaneInstanceIds, type PaneInstanceConfig, resolvePaneInstance } from "../types/config";
|
|
@@ -409,13 +410,18 @@ export function createAppRemoteController({
|
|
|
409
410
|
/**
|
|
410
411
|
* A view's source loads once before the view is kept, so a function that
|
|
411
412
|
* does not exist or cannot read answers with its own error instead of
|
|
412
|
-
* leaving a pane that never fills
|
|
413
|
+
* leaving a pane that never fills, and a column, filter or sort on a key its
|
|
414
|
+
* rows never carry is answered with the keys they do carry. What the load
|
|
415
|
+
* noted comes back as warnings.
|
|
413
416
|
*/
|
|
414
417
|
const checkViewSource = async (spec: ViewSpec, action: "create" | "update", signal?: AbortSignal): Promise<string[]> => {
|
|
415
418
|
try {
|
|
416
419
|
return await trialLoadViewSource(spec, getState().config, { registry: pluginRegistry, signal });
|
|
417
420
|
} catch (error) {
|
|
418
421
|
const reason = error instanceof Error ? error.message : String(error);
|
|
422
|
+
if (error instanceof UnknownViewKeysError) {
|
|
423
|
+
throw new Error(`${action === "create" ? "No view was created" : "The view was left as it was"}. ${reason}`);
|
|
424
|
+
}
|
|
419
425
|
throw new Error(`The view's source did not load, so ${action === "create" ? "no view was created" : "the view was left as it was"}. ${reason}`);
|
|
420
426
|
}
|
|
421
427
|
};
|
|
@@ -497,7 +503,8 @@ export function createAppRemoteController({
|
|
|
497
503
|
const name = optionalString(input, "name");
|
|
498
504
|
if (name) layout = updatePaneInstance(layout, instanceId, (entry: PaneInstanceConfig) => ({ ...entry, title: name }));
|
|
499
505
|
pluginRegistry.updateLayout(layout);
|
|
500
|
-
|
|
506
|
+
const warnings = [...parsed.result.warnings.map((entry) => entry.message), ...loadWarnings];
|
|
507
|
+
return getAfterMutationSummary({ affectedPaneIds: [instanceId], ...(warnings.length ? { warnings } : {}) });
|
|
501
508
|
}
|
|
502
509
|
case "pane.setState":
|
|
503
510
|
dispatch({
|
package/src/remote/schema.ts
CHANGED
|
@@ -169,7 +169,8 @@ export const REMOTE_OPERATIONS: RemoteOperationSchema[] = [
|
|
|
169
169
|
+ "spec = { source: { pane: <function code>, argument?: <one string>, options?: { <flag>: <value> } }, projection: { columns?: [{ key, label?, transform? }], filters?: [{ key, op, value }], sort?: { by, direction }, limit? }, presentation?: { title?, symbolKey? } }. "
|
|
170
170
|
+ "pane is a function code (app://pane-templates says what each does), never an invented name; an unknown one is answered with the closest codes and the valid ones. "
|
|
171
171
|
+ "argument is always one string, several tickers separated by spaces: \"CME AAPL\". "
|
|
172
|
-
+ "options sets the function's own flags; a wrong flag or value is answered with the ones it takes."
|
|
172
|
+
+ "options sets the function's own flags; a wrong flag or value is answered with the ones it takes. "
|
|
173
|
+
+ "Column, filter and sort keys are keys the source's rows carry; one they do not is answered with the keys they do, and no pane opens.",
|
|
173
174
|
"{ name?: string, spec: object }",
|
|
174
175
|
"local-write",
|
|
175
176
|
objectSchema({ name: stringSchema, spec: openObjectSchema }, ["spec"]),
|