@gloom-sh/terminal 0.19.5 → 0.19.6
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/@opentui%2Fcore@0.3.2.patch +86 -25
- package/src/api-client/equity-screener.ts +23 -0
- package/src/app/pane-runtime/index.tsx +2 -0
- package/src/app/pane-runtime/plugin-bindings.ts +10 -1
- package/src/app.tsx +63 -16
- package/src/cli/commands/market.ts +149 -10
- package/src/cli/commands/search.ts +21 -3
- package/src/cli/commands/ticker.ts +74 -33
- package/src/cli/glossary.ts +3 -3
- package/src/cli/known-gaps.ts +8 -0
- package/src/cli/listing-arg.ts +12 -0
- package/src/cli/pane-functions/capabilities.ts +2 -0
- package/src/cli/pane-functions/catalog.ts +22 -4
- package/src/cli/pane-functions/function-help.ts +8 -5
- package/src/cli/pane-functions/headless.ts +4 -3
- package/src/cli/pane-functions/resolver.ts +75 -2
- package/src/cli/quote-answer.ts +9 -0
- package/src/cli/symbol-list.ts +54 -2
- package/src/cli/symbol-rows.ts +14 -2
- package/src/cli/ticker-resolution.ts +89 -20
- package/src/components/chart/composite/axis-overlays.tsx +60 -27
- package/src/components/chart/composite/composite-chart.tsx +118 -63
- package/src/components/chart/composite/cursor-source.ts +111 -0
- package/src/components/chart/composite/format.ts +168 -6
- package/src/components/chart/composite/legend.tsx +8 -4
- package/src/components/chart/composite/panel-labels.ts +20 -1
- package/src/components/chart/composite/panel-surface.tsx +201 -92
- package/src/components/chart/composite/price-axis-labels.tsx +92 -46
- package/src/components/chart/composite/price-series.ts +31 -8
- package/src/components/chart/composite/scene.ts +154 -59
- package/src/components/chart/composite/series-axis-tags.tsx +4 -2
- package/src/components/chart/composite/time-axis.ts +13 -5
- package/src/components/chart/composite/time-scale.ts +211 -56
- package/src/components/chart/composite/types.ts +11 -1
- package/src/components/chart/composite/use-composite-chart-keyboard.ts +32 -12
- package/src/components/chart/curve/curve-surface.tsx +5 -2
- package/src/components/chart/curve/model.ts +4 -1
- package/src/components/chart/native/use-bitmap-metrics.ts +81 -0
- package/src/components/chart/static/series.ts +3 -0
- package/src/components/command-bar/commands/collection-list.ts +81 -0
- package/src/components/command-bar/commands/direct/index.ts +6 -0
- package/src/components/command-bar/commands/registry.ts +8 -0
- package/src/components/command-bar/layout-items/current-layout.ts +22 -1
- package/src/components/command-bar/layout-items/focused-pane.ts +22 -1
- package/src/components/command-bar/pane-templates/items.ts +19 -3
- package/src/components/command-bar/pane-templates/workflow.ts +5 -0
- package/src/components/command-bar/routes/root/results.ts +23 -3
- package/src/components/command-bar/routes/root/selection.ts +4 -2
- package/src/components/command-bar/routes/root/shortcut-feedback.ts +1 -1
- package/src/components/command-bar/routes/root/shortcut-items.ts +3 -4
- package/src/components/command-bar/routes/root/shortcuts.ts +58 -14
- package/src/components/command-bar/routes/root/ticker-first.ts +32 -0
- package/src/components/command-bar/surface/environment.ts +2 -0
- package/src/components/command-bar/view-model.ts +7 -0
- package/src/components/command-bar/workflow/ops.ts +2 -1
- package/src/components/command-bar/workflow/tickers.ts +20 -0
- package/src/components/layout/shell/menu.ts +15 -1
- package/src/components/layout/shell/pane/actions.ts +4 -0
- package/src/components/layout/shell/ticker-link-menu.ts +12 -3
- package/src/components/layout/status-bar.tsx +20 -0
- package/src/components/onboarding/onboarding-keyboard.ts +5 -1
- package/src/components/onboarding/onboarding-wizard.tsx +15 -4
- package/src/components/onboarding/portfolio-step/positions-panel.tsx +8 -5
- package/src/components/onboarding/use-onboarding-progress.ts +20 -1
- package/src/components/price-sparkline/view.tsx +14 -6
- package/src/components/ticker/badge/index.tsx +8 -4
- package/src/components/ticker/badge/list.tsx +23 -7
- package/src/components/ui/column-grid.tsx +8 -2
- package/src/components/ui/data-table/opentui/model.ts +4 -1
- package/src/components/ui/tabs.tsx +5 -2
- package/src/core/state/app/layout.ts +18 -3
- package/src/core/state/app/state.ts +2 -0
- package/src/core/state/app/types.ts +5 -0
- package/src/data/config/layout.ts +3 -0
- package/src/data/config/store/normalize.ts +39 -4
- package/src/i18n/es.ts +10 -0
- package/src/i18n/ja.ts +10 -0
- package/src/i18n/ko.ts +10 -0
- package/src/i18n/zh-cn.ts +10 -0
- package/src/i18n/zh-tw.ts +10 -0
- package/src/layout/pane-manager/floating-placement.ts +7 -4
- package/src/layout/pane-manager/floating.ts +5 -2
- package/src/market-data/bond-funds.ts +19 -0
- package/src/market-data/futures-contract.ts +14 -3
- package/src/market-data/market/freshness.ts +18 -0
- package/src/market-data/market/status.ts +15 -2
- package/src/plugins/builtin/bond-calculator/headless.ts +2 -1
- package/src/plugins/builtin/bond-calculator/index.tsx +1 -1
- package/src/plugins/builtin/bond-calculator/model.ts +14 -5
- package/src/plugins/builtin/bond-calculator/pane.tsx +1 -1
- package/src/plugins/builtin/buildout/cells.tsx +25 -45
- package/src/plugins/builtin/buildout/detail/company.tsx +3 -3
- package/src/plugins/builtin/buildout/detail/index.tsx +1 -1
- package/src/plugins/builtin/buildout/detail/intel.tsx +4 -7
- package/src/plugins/builtin/buildout/detail/site.tsx +4 -4
- package/src/plugins/builtin/buildout/detail/ui.tsx +39 -38
- package/src/plugins/builtin/buildout/format.ts +23 -1
- package/src/plugins/builtin/buildout/model/types.ts +1 -0
- package/src/plugins/builtin/buildout/pane/index.tsx +2 -8
- package/src/plugins/builtin/buildout/table-model.ts +12 -4
- package/src/plugins/builtin/cds/headless.ts +1 -0
- package/src/plugins/builtin/cds/index.tsx +1 -1
- package/src/plugins/builtin/cloud/plugin.tsx +2 -0
- package/src/plugins/builtin/cloud/upgrade-status-widget.tsx +28 -3
- package/src/plugins/builtin/correlation/headless.ts +3 -2
- package/src/plugins/builtin/crypto-board/pane.tsx +5 -4
- package/src/plugins/builtin/debt-maturities/headless.ts +11 -2
- package/src/plugins/builtin/debt-maturities/model.ts +66 -0
- package/src/plugins/builtin/debt-maturities/pane.tsx +23 -4
- package/src/plugins/builtin/earnings-ripple/pane.tsx +1 -1
- package/src/plugins/builtin/econ/calendar-model.ts +28 -6
- package/src/plugins/builtin/equity-screener/client.ts +1 -1
- package/src/plugins/builtin/equity-screener/criterion-editor.tsx +4 -16
- package/src/plugins/builtin/equity-screener/headless.ts +4 -2
- package/src/plugins/builtin/equity-screener/ideas.ts +67 -3
- package/src/plugins/builtin/equity-screener/model.ts +180 -12
- package/src/plugins/builtin/equity-screener/pane.tsx +52 -12
- package/src/plugins/builtin/equity-screener/screen-check.ts +7 -4
- package/src/plugins/builtin/equity-screener/watchlist.ts +33 -0
- package/src/plugins/builtin/futures-curve/client.ts +19 -0
- package/src/plugins/builtin/futures-curve/headless.ts +52 -13
- package/src/plugins/builtin/futures-curve/index.tsx +1 -1
- package/src/plugins/builtin/futures-curve/model.ts +77 -6
- package/src/plugins/builtin/futures-curve/pane.tsx +19 -3
- package/src/plugins/builtin/macro-day/client.ts +41 -0
- package/src/plugins/builtin/macro-day/headless.ts +19 -9
- package/src/plugins/builtin/macro-day/model.ts +3 -1
- package/src/plugins/builtin/market-movers/index.tsx +4 -3
- package/src/plugins/builtin/mna/distress/headless.ts +1 -0
- package/src/plugins/builtin/perps/pane.tsx +3 -1
- package/src/plugins/builtin/portfolio-list/cli/bulk-symbols.ts +17 -0
- package/src/plugins/builtin/portfolio-list/cli/portfolio-command.ts +2 -1
- package/src/plugins/builtin/portfolio-list/cli/watchlist-command.ts +2 -1
- package/src/plugins/builtin/rate-path/headless.ts +24 -10
- package/src/plugins/builtin/research/event-model.ts +10 -3
- package/src/plugins/builtin/research/events-headless.ts +20 -2
- package/src/plugins/builtin/sec/fund-facts.ts +17 -1
- package/src/plugins/builtin/sec/index.tsx +1 -1
- package/src/plugins/builtin/shared/members-menu.tsx +103 -38
- package/src/plugins/builtin/short-interest/publications-model.ts +22 -1
- package/src/plugins/builtin/short-interest/publications-pane.tsx +13 -4
- package/src/plugins/builtin/short-interest/watch-model.ts +1 -1
- package/src/plugins/builtin/time-sales/pane.tsx +3 -2
- package/src/plugins/builtin/trace-bonds/client.ts +7 -4
- package/src/plugins/builtin/trace-bonds/index.tsx +1 -1
- package/src/plugins/builtin/volatility/client.ts +6 -1
- package/src/plugins/builtin/volatility/headless.ts +0 -1
- package/src/plugins/builtin/yield-curve/curves.ts +15 -0
- package/src/plugins/builtin/yield-curve/headless.ts +6 -1
- package/src/plugins/builtin/yield-curve/index.tsx +5 -8
- package/src/plugins/host-modules.ts +22 -3
- package/src/plugins/host-smoke.ts +6 -3
- package/src/portfolio/collection-name.ts +19 -0
- package/src/renderers/browser/http-proxy-transport.ts +78 -8
- package/src/renderers/cloudflare/http-proxy.ts +13 -2
- package/src/renderers/cloudflare/proxy-session.ts +47 -24
- package/src/renderers/cloudflare/worker.ts +15 -2
- package/src/renderers/desktop/geometry.ts +279 -0
- package/src/renderers/desktop/screen-setup.ts +246 -0
- package/src/renderers/desktop/sequential-window-host.ts +179 -0
- package/src/renderers/desktop/test-utils.ts +71 -0
- package/src/renderers/desktop/window-controller.ts +433 -0
- package/src/renderers/desktop/window-host.ts +70 -0
- package/src/renderers/desktop/window-layouts.ts +630 -0
- package/src/renderers/dom/data-frames.ts +15 -4
- package/src/renderers/electrobun/bun/application-menu/click.ts +1 -0
- package/src/renderers/electrobun/bun/application-menu/index.ts +4 -1
- package/src/renderers/electrobun/bun/desktop/backend-requests.ts +19 -8
- package/src/renderers/electrobun/bun/desktop/backend.ts +320 -19
- package/src/renderers/electrobun/bun/desktop/detached-windows.ts +83 -61
- package/src/renderers/electrobun/bun/desktop/host-requests.ts +4 -14
- package/src/renderers/electrobun/bun/desktop/initialization.ts +30 -11
- package/src/renderers/electrobun/bun/desktop/screen-setup-file.ts +55 -0
- package/src/renderers/electrobun/bun/desktop/state-broadcaster.ts +44 -8
- package/src/renderers/electrobun/bun/desktop/workspace/index.ts +298 -97
- package/src/renderers/electrobun/bun/desktop/workspace/requests.ts +44 -6
- package/src/renderers/electrobun/bun/index.ts +4 -97
- package/src/renderers/electrobun/bun/window/electrobun-window-host.ts +306 -0
- package/src/renderers/electrobun/bun/window/focus.ts +0 -25
- package/src/renderers/electrobun/bun/window/remembered-frame.ts +4 -82
- package/src/renderers/electrobun/shared/protocol.ts +44 -2
- package/src/renderers/electrobun/view/backend-rpc.ts +15 -0
- package/src/renderers/electrobun/view/desktop/window/bridge.ts +63 -3
- package/src/renderers/electrobun/view/main.tsx +13 -7
- package/src/series/fred-argument.ts +17 -0
- package/src/sources/provider-router/financial-routes.ts +7 -1
- package/src/state/app/context/index.tsx +16 -2
- package/src/state/desktop-windows.ts +63 -0
- package/src/sync/other-window-tabs.ts +62 -0
- package/src/tickers/company-name-listing.ts +23 -3
- package/src/tickers/listing-fate.ts +147 -1
- package/src/tickers/terminal-codes.ts +5 -0
- package/src/time-series/types.ts +6 -0
- package/src/types/config.ts +10 -1
- package/src/types/desktop-window.ts +71 -2
- package/src/types/financials.ts +4 -0
- package/src/types/headless.ts +19 -0
- package/src/types/plugin.ts +6 -0
- package/src/ui/index.tsx +14 -13
- package/src/ui/same-props.ts +58 -0
- package/src/utils/cli-output.ts +33 -4
- package/src/utils/format.ts +7 -2
- package/src/utils/futures-generic.ts +12 -0
- package/src/utils/http-proxy-upstream.ts +6 -2
- package/src/utils/plugin-proxy-hosts.json +0 -4
- package/src/utils/plugin-proxy-hosts.ts +22 -0
- package/src/utils/sec-filings.ts +7 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import Electrobun, { ApplicationMenu,
|
|
1
|
+
import Electrobun, { ApplicationMenu, Utils } from "electrobun/bun";
|
|
2
2
|
import { homedir } from "os";
|
|
3
3
|
import { debugLog } from "../../../utils/debug-log";
|
|
4
4
|
import { setConfigStoreHost } from "../../../data/config/store";
|
|
@@ -8,24 +8,7 @@ import { contextMenuSelectionMessage } from "./context-menu/click";
|
|
|
8
8
|
import { applicationMenuCommand, createApplicationMenuGate } from "./application-menu/click";
|
|
9
9
|
import { DesktopBackend } from "./desktop/backend";
|
|
10
10
|
import { startDesktopBackend } from "./desktop/initialization";
|
|
11
|
-
import {
|
|
12
|
-
MAIN_WINDOW_MIN_SIZE,
|
|
13
|
-
defaultMainWindowFrame,
|
|
14
|
-
normalizeWindowFrameWithMinimum,
|
|
15
|
-
} from "./window/frame";
|
|
16
|
-
import { MAIN_WINDOW_RPC_KEY } from "./window/focus";
|
|
17
|
-
import { createAppWindow } from "./window/create";
|
|
18
|
-
import { desktopBootFramePath, desktopBootFramePreload, readDesktopBootFrame } from "./window/boot-frame";
|
|
19
|
-
import { getWindowFrame } from "./window/events";
|
|
20
|
-
import {
|
|
21
|
-
fitWindowFrameToDisplays,
|
|
22
|
-
readRememberedDesktopWindow,
|
|
23
|
-
rememberedDesktopWindowPath,
|
|
24
|
-
writeRememberedDesktopWindow,
|
|
25
|
-
type RememberedDesktopWindow,
|
|
26
|
-
} from "./window/remembered-frame";
|
|
27
11
|
import { reapStaleTerminalMedia } from "../../opentui/terminal-media";
|
|
28
|
-
import { quitWindowsEventLoopOnItsThread } from "./window/windows-quit";
|
|
29
12
|
import { installProcessCrashListeners } from "../../../telemetry/crash-reports-node";
|
|
30
13
|
import { renameLegacyMacApp } from "./desktop/app-name";
|
|
31
14
|
import { scheduleDesktopRelaunch } from "./desktop/relaunch";
|
|
@@ -123,87 +106,11 @@ backend.installApplicationMenu();
|
|
|
123
106
|
// started from. Cleaning up here is what makes the stray actually die.
|
|
124
107
|
reapStaleTerminalMedia();
|
|
125
108
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
const fallbackMainWindowFrame = defaultMainWindowFrame();
|
|
130
|
-
const initialMainWindowFrame = fitWindowFrameToDisplays(
|
|
131
|
-
normalizeWindowFrameWithMinimum(rememberedWindow?.frame, fallbackMainWindowFrame, MAIN_WINDOW_MIN_SIZE),
|
|
132
|
-
readDisplayWorkAreas(),
|
|
133
|
-
);
|
|
134
|
-
|
|
135
|
-
let windowedFrame = initialMainWindowFrame;
|
|
136
|
-
let rememberTimer: ReturnType<typeof setTimeout> | null = null;
|
|
137
|
-
|
|
138
|
-
function readDisplayWorkAreas() {
|
|
139
|
-
try {
|
|
140
|
-
return Screen.getAllDisplays().map((display) => ({
|
|
141
|
-
x: display.workArea?.x ?? display.bounds.x,
|
|
142
|
-
y: display.workArea?.y ?? display.bounds.y,
|
|
143
|
-
width: display.workArea?.width ?? display.bounds.width,
|
|
144
|
-
height: display.workArea?.height ?? display.bounds.height,
|
|
145
|
-
primary: display.isPrimary,
|
|
146
|
-
}));
|
|
147
|
-
} catch {
|
|
148
|
-
return [];
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
function rememberedFromWindow(): RememberedDesktopWindow | null {
|
|
153
|
-
const window = backend.mainWindow;
|
|
154
|
-
const live = getWindowFrame(window) ?? windowedFrame;
|
|
155
|
-
let minimized = false;
|
|
156
|
-
let fullscreen = false;
|
|
157
|
-
let maximized = false;
|
|
158
|
-
try { minimized = window?.isMinimized() === true; } catch { minimized = false; }
|
|
159
|
-
if (minimized) return null;
|
|
160
|
-
try { fullscreen = window?.isFullScreen() === true; } catch { fullscreen = false; }
|
|
161
|
-
try { maximized = !fullscreen && window?.isMaximized() === true; } catch { maximized = false; }
|
|
162
|
-
if (!fullscreen && !maximized) windowedFrame = live;
|
|
163
|
-
return { frame: windowedFrame, maximized, fullscreen };
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
function flushRememberedWindow(): void {
|
|
167
|
-
if (rememberTimer) {
|
|
168
|
-
clearTimeout(rememberTimer);
|
|
169
|
-
rememberTimer = null;
|
|
170
|
-
}
|
|
171
|
-
const next = rememberedFromWindow();
|
|
172
|
-
if (next) writeRememberedDesktopWindow(rememberedWindowPath, next);
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
function scheduleRememberedWindow(): void {
|
|
176
|
-
if (rememberTimer) clearTimeout(rememberTimer);
|
|
177
|
-
rememberTimer = setTimeout(() => {
|
|
178
|
-
rememberTimer = null;
|
|
179
|
-
const next = rememberedFromWindow();
|
|
180
|
-
if (next) writeRememberedDesktopWindow(rememberedWindowPath, next);
|
|
181
|
-
}, 300);
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
const mainWindow = createAppWindow({
|
|
185
|
-
title: "Gloom",
|
|
186
|
-
frame: initialMainWindowFrame,
|
|
187
|
-
rpc: mainRpc,
|
|
188
|
-
minSize: MAIN_WINDOW_MIN_SIZE,
|
|
189
|
-
onFrameChange: scheduleRememberedWindow,
|
|
190
|
-
// The layout the window last drew, which its page draws before its script
|
|
191
|
-
// has loaded (dom/boot-frame.ts).
|
|
192
|
-
preload: desktopBootFramePreload(readDesktopBootFrame(desktopBootFramePath())),
|
|
193
|
-
});
|
|
194
|
-
backend.mainWindow = mainWindow;
|
|
195
|
-
quitWindowsEventLoopOnItsThread(mainWindow);
|
|
109
|
+
// The main window opens where it was left on these screens; extra windows
|
|
110
|
+
// follow once it has its data (desktop/window-controller.ts).
|
|
111
|
+
backend.startWindows();
|
|
196
112
|
// The window is loading its view; the services it will ask for start now
|
|
197
113
|
// rather than when it asks. Its `init` reports a failure, and retries.
|
|
198
114
|
startDesktopBackend(backend).catch((error) => {
|
|
199
115
|
console.error("[desktop] startup failed", error instanceof Error ? error.stack ?? error.message : String(error));
|
|
200
116
|
});
|
|
201
|
-
// Windows has no way into fullscreen here, and builds whose frameless window
|
|
202
|
-
// Windows took for fullscreen saved every window as fullscreen.
|
|
203
|
-
if (rememberedWindow?.fullscreen && process.platform !== "win32") {
|
|
204
|
-
try { mainWindow.setFullScreen(true); } catch { /* the framed window is still the one they sized */ }
|
|
205
|
-
} else if (rememberedWindow?.maximized) {
|
|
206
|
-
try { mainWindow.maximize(); } catch { /* the framed window is still the one they sized */ }
|
|
207
|
-
}
|
|
208
|
-
(mainWindow as { on?: (event: "close", listener: () => void) => void }).on?.("close", flushRememberedWindow);
|
|
209
|
-
backend.detachedWindows.focusWindowForRpcKey(MAIN_WINDOW_RPC_KEY);
|
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
import type { BrowserWindow, Screen } from "electrobun/bun";
|
|
2
|
+
import { arrangementKey, type DesktopDisplay, type Rect } from "../../../desktop/geometry";
|
|
3
|
+
import type {
|
|
4
|
+
DesktopWindowHost,
|
|
5
|
+
NativeWindowEvent,
|
|
6
|
+
NativeWindowState,
|
|
7
|
+
OpenWindowSpec,
|
|
8
|
+
} from "../../../desktop/window-host";
|
|
9
|
+
import { getWindowFrame, updateWindowFrameCache } from "./events";
|
|
10
|
+
import type { FocusableElectrobunWindow } from "./focus";
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Electrobun 1.18 has no event for displays coming and going, nor for a window
|
|
14
|
+
* being minimized: both are read on a timer, this often while there is more
|
|
15
|
+
* than one window...
|
|
16
|
+
*/
|
|
17
|
+
const POLL_MS = 3_000;
|
|
18
|
+
/**
|
|
19
|
+
* ...and this often with one, which reads the displays only: its page's own
|
|
20
|
+
* visibility says when it is hidden, as it did before there were more windows.
|
|
21
|
+
*/
|
|
22
|
+
const QUIET_POLL_MS = 10_000;
|
|
23
|
+
/**
|
|
24
|
+
* A window's own events read whether it is minimized at once, so one coming
|
|
25
|
+
* back redraws without waiting for the timer: a focus, a move or a resize
|
|
26
|
+
* (a restore on Windows). A blur reads it again this long after, once the
|
|
27
|
+
* minimize animation has run.
|
|
28
|
+
*/
|
|
29
|
+
const AFTER_BLUR_MS = 600;
|
|
30
|
+
|
|
31
|
+
export interface ElectrobunWindowHostOptions {
|
|
32
|
+
/**
|
|
33
|
+
* Makes the native window: the view it loads, its RPC channel and preload
|
|
34
|
+
* are the backend's. `onFrameChange` runs after each move or resize.
|
|
35
|
+
*/
|
|
36
|
+
create(spec: OpenWindowSpec, hooks: { onFrameChange: () => void }): BrowserWindow;
|
|
37
|
+
platform?: NodeJS.Platform;
|
|
38
|
+
env?: NodeJS.ProcessEnv;
|
|
39
|
+
/** The displays as Electrobun lists them: `Screen.getAllDisplays`. */
|
|
40
|
+
readDisplays: () => ElectrobunDisplay[];
|
|
41
|
+
pollMs?: number;
|
|
42
|
+
quietPollMs?: number;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
type ElectrobunDisplay = ReturnType<typeof Screen.getAllDisplays>[number];
|
|
46
|
+
|
|
47
|
+
function toRect(value: Partial<Rect> | undefined, fallback: Rect): Rect {
|
|
48
|
+
return {
|
|
49
|
+
x: typeof value?.x === "number" ? value.x : fallback.x,
|
|
50
|
+
y: typeof value?.y === "number" ? value.y : fallback.y,
|
|
51
|
+
width: typeof value?.width === "number" ? value.width : fallback.width,
|
|
52
|
+
height: typeof value?.height === "number" ? value.height : fallback.height,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function readElectrobunDisplays(read: () => ElectrobunDisplay[]): DesktopDisplay[] {
|
|
57
|
+
try {
|
|
58
|
+
return read().map((display) => {
|
|
59
|
+
const bounds = toRect(display.bounds, { x: 0, y: 0, width: 0, height: 0 });
|
|
60
|
+
return {
|
|
61
|
+
id: String(display.id),
|
|
62
|
+
bounds,
|
|
63
|
+
workArea: toRect(display.workArea, bounds),
|
|
64
|
+
scaleFactor: typeof display.scaleFactor === "number" && display.scaleFactor > 0 ? display.scaleFactor : 1,
|
|
65
|
+
primary: display.isPrimary === true,
|
|
66
|
+
};
|
|
67
|
+
});
|
|
68
|
+
} catch {
|
|
69
|
+
return [];
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Whether windows can place themselves. Under a Wayland session GTK talks to
|
|
75
|
+
* the compositor, which ignores a window's own position; run through XWayland
|
|
76
|
+
* (GDK_BACKEND=x11) they can.
|
|
77
|
+
*/
|
|
78
|
+
function canPlaceWindowsOn(platform: NodeJS.Platform, env: NodeJS.ProcessEnv): boolean {
|
|
79
|
+
if (platform !== "linux") return true;
|
|
80
|
+
const wayland = env.XDG_SESSION_TYPE === "wayland" || !!env.WAYLAND_DISPLAY;
|
|
81
|
+
return !wayland || env.GDK_BACKEND === "x11";
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/** A native yes or no; false when the window cannot answer. */
|
|
85
|
+
function read(call: () => boolean): boolean {
|
|
86
|
+
try {
|
|
87
|
+
return call() === true;
|
|
88
|
+
} catch {
|
|
89
|
+
return false;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/** The desktop window host on Electrobun 1.18: windows, their frames and events, and the displays. */
|
|
94
|
+
export class ElectrobunWindowHost implements DesktopWindowHost {
|
|
95
|
+
readonly canPlaceWindows: boolean;
|
|
96
|
+
/** Windows has no way into full screen with Electrobun's frameless windows. */
|
|
97
|
+
readonly canFullscreen: boolean;
|
|
98
|
+
private readonly windows = new Map<string, BrowserWindow>();
|
|
99
|
+
private readonly minimized = new Map<string, boolean>();
|
|
100
|
+
/** Each window's maximized and full screen state as last read: a closed window cannot be asked. */
|
|
101
|
+
private readonly modes = new Map<string, { maximized: boolean; fullscreen: boolean }>();
|
|
102
|
+
/** A window closed from outside, as last known, while its close is being reported. */
|
|
103
|
+
private readonly closing = new Map<string, NativeWindowState>();
|
|
104
|
+
private readonly displayListeners = new Set<(displays: DesktopDisplay[]) => void>();
|
|
105
|
+
private readonly windowListeners = new Set<(event: NativeWindowEvent) => void>();
|
|
106
|
+
private poll: ReturnType<typeof setTimeout> | null = null;
|
|
107
|
+
private lastArrangement: string;
|
|
108
|
+
|
|
109
|
+
constructor(private readonly options: ElectrobunWindowHostOptions) {
|
|
110
|
+
const platform = options.platform ?? process.platform;
|
|
111
|
+
this.canPlaceWindows = canPlaceWindowsOn(platform, options.env ?? process.env);
|
|
112
|
+
this.canFullscreen = platform !== "win32";
|
|
113
|
+
this.lastArrangement = arrangementKey(this.listDisplays());
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/** The Electrobun window, for the few calls only this shell makes (its native handle, devtools). */
|
|
117
|
+
browserWindow(id: string): BrowserWindow | null {
|
|
118
|
+
return this.windows.get(id) ?? null;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
listDisplays(): DesktopDisplay[] {
|
|
122
|
+
return readElectrobunDisplays(this.options.readDisplays);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
openWindow(spec: OpenWindowSpec): void {
|
|
126
|
+
if (this.windows.has(spec.id)) return;
|
|
127
|
+
const window = this.options.create(spec, {
|
|
128
|
+
onFrameChange: () => {
|
|
129
|
+
this.checkMinimized(spec.id);
|
|
130
|
+
this.readModes(spec.id);
|
|
131
|
+
this.emit({ type: "frame", id: spec.id });
|
|
132
|
+
},
|
|
133
|
+
});
|
|
134
|
+
this.windows.set(spec.id, window);
|
|
135
|
+
this.minimized.set(spec.id, false);
|
|
136
|
+
const on = (window as { on?: (name: string, handler: (event: unknown) => void) => void }).on;
|
|
137
|
+
on?.call(window, "focus", () => {
|
|
138
|
+
this.checkMinimized(spec.id);
|
|
139
|
+
this.emit({ type: "focus", id: spec.id });
|
|
140
|
+
});
|
|
141
|
+
on?.call(window, "blur", () => {
|
|
142
|
+
this.checkMinimized(spec.id);
|
|
143
|
+
setTimeout(() => this.checkMinimized(spec.id), AFTER_BLUR_MS);
|
|
144
|
+
});
|
|
145
|
+
on?.call(window, "close", () => {
|
|
146
|
+
// Only the person's closes are reported: `closeWindow` forgets the window first.
|
|
147
|
+
if (this.windows.get(spec.id) !== window) return;
|
|
148
|
+
// The native window is gone: what is known of it answers while its close is reported.
|
|
149
|
+
const frame = getWindowFrame(window);
|
|
150
|
+
const modes = this.modes.get(spec.id) ?? { maximized: false, fullscreen: false };
|
|
151
|
+
if (frame) this.closing.set(spec.id, { frame, ...modes, minimized: this.minimized.get(spec.id) === true });
|
|
152
|
+
this.forget(spec.id);
|
|
153
|
+
try {
|
|
154
|
+
this.emit({ type: "close", id: spec.id });
|
|
155
|
+
} finally {
|
|
156
|
+
this.closing.delete(spec.id);
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
// A second window reads sooner than the timer one window left.
|
|
160
|
+
this.schedulePoll(true);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
closeWindow(id: string): void {
|
|
164
|
+
const window = this.windows.get(id);
|
|
165
|
+
if (!window) return;
|
|
166
|
+
this.forget(id);
|
|
167
|
+
window.close();
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
private forget(id: string): void {
|
|
171
|
+
this.windows.delete(id);
|
|
172
|
+
this.minimized.delete(id);
|
|
173
|
+
this.modes.delete(id);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
hasWindow(id: string): boolean {
|
|
177
|
+
return this.windows.has(id);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
getWindowState(id: string): NativeWindowState | null {
|
|
181
|
+
const window = this.windows.get(id);
|
|
182
|
+
if (!window) return this.closing.get(id) ?? null;
|
|
183
|
+
const frame = getWindowFrame(window);
|
|
184
|
+
if (!frame) return null;
|
|
185
|
+
return { frame, ...this.readModes(id), minimized: read(() => window.isMinimized()) };
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
private readModes(id: string): { maximized: boolean; fullscreen: boolean } {
|
|
189
|
+
const window = this.windows.get(id);
|
|
190
|
+
if (!window) return { maximized: false, fullscreen: false };
|
|
191
|
+
const fullscreen = this.canFullscreen && read(() => window.isFullScreen());
|
|
192
|
+
const modes = { maximized: !fullscreen && read(() => window.isMaximized()), fullscreen };
|
|
193
|
+
this.modes.set(id, modes);
|
|
194
|
+
return modes;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
setFrame(id: string, frame: Rect): void {
|
|
198
|
+
const window = this.windows.get(id);
|
|
199
|
+
if (!window) return;
|
|
200
|
+
window.setFrame(frame.x, frame.y, frame.width, frame.height);
|
|
201
|
+
updateWindowFrameCache(window, frame);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
setMaximized(id: string, maximized: boolean): void {
|
|
205
|
+
const window = this.windows.get(id);
|
|
206
|
+
try {
|
|
207
|
+
if (maximized) window?.maximize();
|
|
208
|
+
else window?.unmaximize();
|
|
209
|
+
} catch {
|
|
210
|
+
// The window keeps the frame it has.
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
setFullscreen(id: string, fullscreen: boolean): void {
|
|
215
|
+
if (!this.canFullscreen) return;
|
|
216
|
+
try {
|
|
217
|
+
this.windows.get(id)?.setFullScreen(fullscreen);
|
|
218
|
+
} catch {
|
|
219
|
+
// The window keeps the frame it has.
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
setTitle(id: string, title: string): void {
|
|
224
|
+
(this.windows.get(id) as { setTitle?: (title: string) => void } | undefined)?.setTitle?.(title);
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
focusWindow(id: string): void {
|
|
228
|
+
const window = this.windows.get(id) as FocusableElectrobunWindow | undefined;
|
|
229
|
+
if (!window) return;
|
|
230
|
+
if (this.minimized.get(id)) {
|
|
231
|
+
try {
|
|
232
|
+
(window as unknown as BrowserWindow).unminimize();
|
|
233
|
+
} catch {
|
|
234
|
+
// Focusing it still brings it forward where the system allows.
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
if (window.activate) window.activate();
|
|
238
|
+
else window.focus?.();
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
onDisplaysChanged(listener: (displays: DesktopDisplay[]) => void): () => void {
|
|
242
|
+
this.displayListeners.add(listener);
|
|
243
|
+
this.schedulePoll(false);
|
|
244
|
+
return () => {
|
|
245
|
+
this.displayListeners.delete(listener);
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
onWindowEvent(listener: (event: NativeWindowEvent) => void): () => void {
|
|
250
|
+
this.windowListeners.add(listener);
|
|
251
|
+
return () => {
|
|
252
|
+
this.windowListeners.delete(listener);
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
dispose(): void {
|
|
257
|
+
if (this.poll) clearTimeout(this.poll);
|
|
258
|
+
this.poll = null;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
private emit(event: NativeWindowEvent): void {
|
|
262
|
+
for (const listener of [...this.windowListeners]) listener(event);
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
private pollInterval(): number {
|
|
266
|
+
return this.windows.size > 1 ? this.options.pollMs ?? POLL_MS : this.options.quietPollMs ?? QUIET_POLL_MS;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
/** Sets the next read; `sooner` moves one already set closer when there are now more windows. */
|
|
270
|
+
private schedulePoll(sooner: boolean): void {
|
|
271
|
+
if (this.poll && !sooner) return;
|
|
272
|
+
if (this.poll) clearTimeout(this.poll);
|
|
273
|
+
this.poll = setTimeout(() => {
|
|
274
|
+
this.poll = null;
|
|
275
|
+
this.check();
|
|
276
|
+
this.schedulePoll(false);
|
|
277
|
+
}, this.pollInterval());
|
|
278
|
+
(this.poll as { unref?: () => void }).unref?.();
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
private check(): void {
|
|
282
|
+
const displays = this.listDisplays();
|
|
283
|
+
const arrangement = arrangementKey(displays);
|
|
284
|
+
if (displays.length > 0 && arrangement !== this.lastArrangement) {
|
|
285
|
+
this.lastArrangement = arrangement;
|
|
286
|
+
for (const listener of [...this.displayListeners]) listener(displays);
|
|
287
|
+
}
|
|
288
|
+
if (this.windows.size > 1) {
|
|
289
|
+
for (const id of this.windows.keys()) this.checkMinimized(id);
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
private checkMinimized(id: string): void {
|
|
294
|
+
const window = this.windows.get(id);
|
|
295
|
+
if (!window) return;
|
|
296
|
+
let minimized: boolean;
|
|
297
|
+
try {
|
|
298
|
+
minimized = window.isMinimized() === true;
|
|
299
|
+
} catch {
|
|
300
|
+
return;
|
|
301
|
+
}
|
|
302
|
+
if (this.minimized.get(id) === minimized) return;
|
|
303
|
+
this.minimized.set(id, minimized);
|
|
304
|
+
this.emit({ type: "visibility", id, visible: !minimized });
|
|
305
|
+
}
|
|
306
|
+
}
|
|
@@ -15,28 +15,3 @@ export function paneIdFromDetachedRpcKey(rpcKey: string | undefined): string | n
|
|
|
15
15
|
if (!rpcKey?.startsWith(DETACHED_WINDOW_RPC_PREFIX)) return null;
|
|
16
16
|
return rpcKey.slice(DETACHED_WINDOW_RPC_PREFIX.length) || null;
|
|
17
17
|
}
|
|
18
|
-
|
|
19
|
-
function resolveWindowForRpcKey<T>(
|
|
20
|
-
rpcKey: string | undefined,
|
|
21
|
-
mainWindow: T | null,
|
|
22
|
-
detachedWindows: ReadonlyMap<string, T>,
|
|
23
|
-
): T | null {
|
|
24
|
-
if (rpcKey === MAIN_WINDOW_RPC_KEY) return mainWindow;
|
|
25
|
-
const paneId = paneIdFromDetachedRpcKey(rpcKey);
|
|
26
|
-
return paneId ? detachedWindows.get(paneId) ?? null : null;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export function focusWindowForRpcKey(
|
|
30
|
-
rpcKey: string | undefined,
|
|
31
|
-
mainWindow: FocusableElectrobunWindow | null,
|
|
32
|
-
detachedWindows: ReadonlyMap<string, FocusableElectrobunWindow>,
|
|
33
|
-
): boolean {
|
|
34
|
-
const window = resolveWindowForRpcKey(rpcKey, mainWindow, detachedWindows);
|
|
35
|
-
if (window?.activate) {
|
|
36
|
-
window.activate();
|
|
37
|
-
return true;
|
|
38
|
-
}
|
|
39
|
-
if (!window?.focus) return false;
|
|
40
|
-
window.focus();
|
|
41
|
-
return true;
|
|
42
|
-
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { readFileSync } from "fs";
|
|
2
2
|
import { dirname, join } from "path";
|
|
3
3
|
import { getGloomberbDirs } from "../../../../data/config/home";
|
|
4
4
|
import type { WindowFrame } from "./frame";
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
7
|
+
* Where builds before the window setup (desktop/screen-setup.ts) kept the
|
|
8
|
+
* main window's last frame. Read once, for the first launch after the
|
|
9
|
+
* update, when the setup has nothing for the main window yet.
|
|
10
10
|
*/
|
|
11
11
|
const FILE_NAME = "desktop-window.json";
|
|
12
12
|
|
|
@@ -16,14 +16,6 @@ export interface RememberedDesktopWindow {
|
|
|
16
16
|
fullscreen: boolean;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
export interface DisplayWorkArea {
|
|
20
|
-
x: number;
|
|
21
|
-
y: number;
|
|
22
|
-
width: number;
|
|
23
|
-
height: number;
|
|
24
|
-
primary?: boolean;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
19
|
export function rememberedDesktopWindowPath(env: NodeJS.ProcessEnv = process.env): string {
|
|
28
20
|
return join(dirname(getGloomberbDirs(env).configFile), FILE_NAME);
|
|
29
21
|
}
|
|
@@ -50,73 +42,3 @@ export function readRememberedDesktopWindow(path: string): RememberedDesktopWind
|
|
|
50
42
|
return null;
|
|
51
43
|
}
|
|
52
44
|
}
|
|
53
|
-
|
|
54
|
-
export function writeRememberedDesktopWindow(path: string, value: RememberedDesktopWindow): void {
|
|
55
|
-
mkdirSync(dirname(path), { recursive: true });
|
|
56
|
-
const temporary = `${path}.${process.pid}.tmp`;
|
|
57
|
-
writeFileSync(temporary, JSON.stringify(value));
|
|
58
|
-
renameSync(temporary, path);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
function overlapArea(frame: WindowFrame, display: DisplayWorkArea): number {
|
|
62
|
-
const width = Math.min(frame.x + frame.width, display.x + display.width) - Math.max(frame.x, display.x);
|
|
63
|
-
const height = Math.min(frame.y + frame.height, display.y + display.height) - Math.max(frame.y, display.y);
|
|
64
|
-
return width > 0 && height > 0 ? width * height : 0;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
function clamp(value: number, min: number, max: number): number {
|
|
68
|
-
return Math.min(max, Math.max(min, value));
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* Puts a saved frame on a connected display. A window that still intersects
|
|
73
|
-
* one stays put. One left on a display that is gone moves onto the display
|
|
74
|
-
* with the most overlap, or the primary display.
|
|
75
|
-
*/
|
|
76
|
-
export function fitWindowFrameToDisplays(
|
|
77
|
-
frame: WindowFrame,
|
|
78
|
-
displays: readonly DisplayWorkArea[],
|
|
79
|
-
): WindowFrame {
|
|
80
|
-
const usable = displays.filter((display) => display.width >= 1 && display.height >= 1);
|
|
81
|
-
if (usable.length === 0) return frame;
|
|
82
|
-
const centerX = frame.x + frame.width / 2;
|
|
83
|
-
const centerY = frame.y + frame.height / 2;
|
|
84
|
-
const containing = usable.find((display) => (
|
|
85
|
-
centerX >= display.x && centerX < display.x + display.width
|
|
86
|
-
&& centerY >= display.y && centerY < display.y + display.height
|
|
87
|
-
));
|
|
88
|
-
let display = containing;
|
|
89
|
-
if (!display) {
|
|
90
|
-
let best = usable[0]!;
|
|
91
|
-
let bestArea = overlapArea(frame, best);
|
|
92
|
-
for (const candidate of usable.slice(1)) {
|
|
93
|
-
const area = overlapArea(frame, candidate);
|
|
94
|
-
if (area > bestArea) {
|
|
95
|
-
best = candidate;
|
|
96
|
-
bestArea = area;
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
display = bestArea > 0 ? best : usable.find((candidate) => candidate.primary) ?? usable[0]!;
|
|
100
|
-
}
|
|
101
|
-
const width = Math.min(frame.width, display.width);
|
|
102
|
-
const height = Math.min(frame.height, display.height);
|
|
103
|
-
// A window left on a display that is no longer connected comes back on the
|
|
104
|
-
// one that remains, at that display's left edge, keeping its vertical place.
|
|
105
|
-
if (overlapArea(frame, display) === 0) {
|
|
106
|
-
const minY = display.y;
|
|
107
|
-
const maxY = display.y + display.height - height;
|
|
108
|
-
return { x: display.x, y: clamp(frame.y, minY, Math.max(minY, maxY)), width, height };
|
|
109
|
-
}
|
|
110
|
-
const marginX = Math.min(48, width);
|
|
111
|
-
const marginY = Math.min(48, height);
|
|
112
|
-
const minX = display.x + marginX - width;
|
|
113
|
-
const maxX = display.x + display.width - marginX;
|
|
114
|
-
const minY = display.y;
|
|
115
|
-
const maxY = display.y + display.height - marginY;
|
|
116
|
-
return {
|
|
117
|
-
x: width === display.width ? display.x : clamp(frame.x, minX, Math.max(minX, maxX)),
|
|
118
|
-
y: height === display.height ? display.y : clamp(frame.y, minY, Math.max(minY, maxY)),
|
|
119
|
-
width,
|
|
120
|
-
height,
|
|
121
|
-
};
|
|
122
|
-
}
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import type { AppSessionSnapshot } from "../../../core/state/session-persistence";
|
|
2
2
|
import type { PaneRuntimeState } from "../../../core/state/app/state";
|
|
3
|
-
import type {
|
|
3
|
+
import type {
|
|
4
|
+
DesktopDockPreviewState,
|
|
5
|
+
DesktopSharedStateSnapshot,
|
|
6
|
+
DesktopThemePreviewState,
|
|
7
|
+
DesktopWindowInfo,
|
|
8
|
+
OtherWindowTab,
|
|
9
|
+
} from "../../../types/desktop-window";
|
|
4
10
|
import type { DesktopApplicationMenuCommand } from "../../../types/desktop-menu";
|
|
5
11
|
import type { AppConfig, UpdateChannel } from "../../../types/config";
|
|
6
12
|
import type { CachedResourceRecord, ResourceCacheKey } from "../../../data/resource-store";
|
|
@@ -29,6 +35,12 @@ export interface ElectrobunBackendInit {
|
|
|
29
35
|
hostName?: string;
|
|
30
36
|
windowKind: "main" | "detached";
|
|
31
37
|
paneId?: string;
|
|
38
|
+
/** A full window's id: `main`, or an extra window's. Absent for a popped-out pane's window. */
|
|
39
|
+
windowId?: string;
|
|
40
|
+
/** Every full window, for moving a tab or pane between them. */
|
|
41
|
+
windows?: DesktopWindowInfo[];
|
|
42
|
+
/** The main window's: the tabs the other windows hold, for cloud sync. */
|
|
43
|
+
otherWindowTabs?: OtherWindowTab[];
|
|
32
44
|
/** What the launch's plugin seed could not install, for the main window to say once. */
|
|
33
45
|
pluginSeedNotice?: { body: string; type: "error" | "info" };
|
|
34
46
|
/** What the view needs to send crash reports and usage counts the same way the Bun process would. */
|
|
@@ -183,7 +195,8 @@ interface DesktopBackendRequestMap {
|
|
|
183
195
|
"capability.cancel": { request: { invocationId: string }; response: null };
|
|
184
196
|
"capability.subscribe": { request: DesktopCapabilitySubscribeRequest; response: null };
|
|
185
197
|
"capability.unsubscribe": { request: { subscriptionId: string }; response: null };
|
|
186
|
-
|
|
198
|
+
/** A full window's whole state. `baseSeq` names the last state it took from here; null, its own last sync. */
|
|
199
|
+
"desktop.syncMainState": { request: { snapshot: DesktopSharedStateSnapshot; baseSeq?: number | null }; response: null };
|
|
187
200
|
"desktop.setThemePreview": { request: { preview: DesktopThemePreviewState }; response: null };
|
|
188
201
|
"desktop.replaceDetachedPaneState": {
|
|
189
202
|
request: { paneId: string; paneState: PaneRuntimeState };
|
|
@@ -196,6 +209,13 @@ interface DesktopBackendRequestMap {
|
|
|
196
209
|
};
|
|
197
210
|
"desktop.closeDetachedPane": { request: { paneId: string }; response: null };
|
|
198
211
|
"desktop.focusDetachedPane": { request: { paneId: string }; response: null };
|
|
212
|
+
"desktop.openWindow": { request: null; response: null };
|
|
213
|
+
/** `windowId` null moves it to a new window. False when it cannot go. */
|
|
214
|
+
"desktop.moveLayoutToWindow": { request: { layoutId: string; windowId: string | null }; response: boolean };
|
|
215
|
+
"desktop.movePaneToWindow": { request: { paneId: string; windowId: string | null }; response: boolean };
|
|
216
|
+
"desktop.focusWindow": { request: { windowId: string }; response: null };
|
|
217
|
+
/** Brings forward the full window that shows a pane, on its tab, with the pane focused. False when no window has it. */
|
|
218
|
+
"desktop.focusPane": { request: { paneId: string }; response: boolean };
|
|
199
219
|
"pluginState.setMany": { request: { entries: DesktopPluginStateSetEntry[] }; response: null };
|
|
200
220
|
"pluginState.delete": { request: { pluginId: string; key: string }; response: null };
|
|
201
221
|
"plugins.listExternal": { request: null; response: DesktopExternalPluginBundle[] };
|
|
@@ -334,6 +354,24 @@ export interface DesktopDeepLinkMessage {
|
|
|
334
354
|
url: string;
|
|
335
355
|
}
|
|
336
356
|
|
|
357
|
+
interface DesktopWindowsMessage {
|
|
358
|
+
windows: DesktopWindowInfo[];
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
interface DesktopOtherWindowTabsMessage {
|
|
362
|
+
/** `OtherWindowTab[]`, encoded as the shared state is. */
|
|
363
|
+
tabs: unknown;
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
interface DesktopFocusPaneMessage {
|
|
367
|
+
paneId: string;
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
/** The window was minimized or brought back; a page cannot always tell by itself. */
|
|
371
|
+
interface DesktopWindowVisibilityMessage {
|
|
372
|
+
visible: boolean;
|
|
373
|
+
}
|
|
374
|
+
|
|
337
375
|
/** Plugin folders the Bun process updated in the background, for the main window to bring into its session. */
|
|
338
376
|
interface PluginsUpdatedMessage {
|
|
339
377
|
directories: string[];
|
|
@@ -371,6 +409,10 @@ export interface ElectrobunDesktopRpcSchema {
|
|
|
371
409
|
"desktop.dockPreview": DesktopDockPreviewMessage;
|
|
372
410
|
"desktop.themePreview": DesktopThemePreviewMessage;
|
|
373
411
|
"desktop.deepLink": DesktopDeepLinkMessage;
|
|
412
|
+
"desktop.windows": DesktopWindowsMessage;
|
|
413
|
+
"desktop.otherWindowTabs": DesktopOtherWindowTabsMessage;
|
|
414
|
+
"desktop.focusPane": DesktopFocusPaneMessage;
|
|
415
|
+
"desktop.windowVisibility": DesktopWindowVisibilityMessage;
|
|
374
416
|
"plugins.updated": PluginsUpdatedMessage;
|
|
375
417
|
"update.progress": UpdateProgressMessage;
|
|
376
418
|
"capability.event": CapabilityEventMessage;
|
|
@@ -85,6 +85,21 @@ const rpc = Electroview.defineRPC<ElectrobunDesktopRpcSchema>({
|
|
|
85
85
|
"desktop.themePreview": (message) => {
|
|
86
86
|
emit("desktop.themePreview", { preview: decodeRpcValue<DesktopThemePreviewMessage["preview"]>(message.preview) });
|
|
87
87
|
},
|
|
88
|
+
"desktop.windows": (message) => {
|
|
89
|
+
if (!Array.isArray(message?.windows)) return;
|
|
90
|
+
emit("desktop.windows", { windows: message.windows });
|
|
91
|
+
},
|
|
92
|
+
"desktop.otherWindowTabs": (message) => {
|
|
93
|
+
const tabs = decodeRpcValue<unknown>(message?.tabs);
|
|
94
|
+
if (Array.isArray(tabs)) emit("desktop.otherWindowTabs", { tabs });
|
|
95
|
+
},
|
|
96
|
+
"desktop.focusPane": (message) => {
|
|
97
|
+
if (typeof message?.paneId !== "string" || !message.paneId) return;
|
|
98
|
+
emit("desktop.focusPane", { paneId: message.paneId });
|
|
99
|
+
},
|
|
100
|
+
"desktop.windowVisibility": (message) => {
|
|
101
|
+
emit("desktop.windowVisibility", { visible: message?.visible !== false });
|
|
102
|
+
},
|
|
88
103
|
"update.progress": (message) => {
|
|
89
104
|
emit("update.progress", { progress: decodeRpcValue(message.progress) });
|
|
90
105
|
},
|