@gloom-sh/terminal 0.19.5 → 0.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +0 -4
- package/package.json +6 -5
- package/patches/@opentui%2Fcore@0.3.2.patch +86 -25
- package/patches/electrobun-devkit@2.0.5.patch +148 -0
- package/src/api-client/bond-trades.ts +59 -0
- package/src/api-client/data.ts +21 -0
- package/src/api-client/equity-screener.ts +23 -0
- 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 +350 -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/pane-runtime/index.tsx +2 -0
- package/src/app/pane-runtime/plugin-bindings.ts +10 -1
- package/src/app/runtime/desktop-deeplink.ts +41 -6
- package/src/app/star-prompt/status-line.tsx +1 -1
- package/src/app.tsx +64 -23
- package/src/architecture/ui-tokens-allowlist.json +0 -8
- package/src/cli/commands/market.ts +149 -10
- package/src/cli/commands/search.ts +21 -3
- package/src/cli/commands/ticker.ts +90 -36
- package/src/cli/desktop-pane-shot-browser.ts +69 -3
- 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 +25 -5
- 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 +43 -14
- 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/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/menu.ts +15 -1
- package/src/components/layout/shell/pane/actions.ts +10 -2
- package/src/components/layout/shell/pane/management-shortcuts.ts +13 -51
- package/src/components/layout/shell/ticker-link-menu.ts +12 -3
- package/src/components/layout/status-bar.tsx +24 -78
- package/src/components/layout/status-widget-space.ts +5 -5
- 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 +9 -6
- 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/index.tsx +5 -1
- package/src/components/ui/data-table/opentui/model.ts +4 -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/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 +13 -3
- package/src/i18n/ja.ts +13 -3
- package/src/i18n/ko.ts +13 -3
- package/src/i18n/zh-cn.ts +13 -3
- package/src/i18n/zh-tw.ts +13 -3
- 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/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/plugin.tsx +2 -0
- package/src/plugins/builtin/cloud/trial-offer-status-widget.tsx +3 -3
- package/src/plugins/builtin/cloud/upgrade-status-widget.tsx +44 -12
- 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/headless.ts +3 -2
- package/src/plugins/builtin/crypto-board/pane.tsx +5 -4
- 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/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 +16 -19
- package/src/plugins/builtin/equity-screener/headless.ts +37 -3
- package/src/plugins/builtin/equity-screener/ideas.ts +67 -3
- package/src/plugins/builtin/equity-screener/model.ts +238 -27
- package/src/plugins/builtin/equity-screener/pane.tsx +88 -18
- 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/executives/format.ts +5 -4
- package/src/plugins/builtin/executives/pane.tsx +1 -1
- 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/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/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/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/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/portfolio-list/header.tsx +1 -1
- package/src/plugins/builtin/rate-path/headless.ts +24 -10
- package/src/plugins/builtin/research/corporate-actions-pane.tsx +29 -25
- 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/series-inventory.ts +1 -0
- package/src/plugins/builtin/shared/earnings-report.ts +7 -2
- package/src/plugins/builtin/shared/members-menu.tsx +103 -38
- 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/publications-model.ts +22 -1
- package/src/plugins/builtin/short-interest/publications-pane.tsx +13 -4
- package/src/plugins/builtin/short-interest/types.ts +2 -0
- package/src/plugins/builtin/short-interest/watch-model.ts +1 -1
- 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 +5 -3
- package/src/plugins/builtin/ticker-detail/overview-tab.tsx +4 -4
- 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/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/index.tsx +1 -1
- package/src/plugins/builtin/trace-bonds/pane.tsx +64 -5
- 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/plugins/installer.ts +16 -3
- package/src/plugins/plugin-names.ts +11 -2
- package/src/portfolio/collection-name.ts +19 -0
- package/src/remote/controller.ts +9 -2
- package/src/remote/schema.ts +2 -1
- package/src/renderers/browser/http-proxy-transport.ts +78 -8
- package/src/renderers/cloudflare/http-proxy.ts +73 -3
- package/src/renderers/cloudflare/proxy-session.ts +47 -24
- package/src/renderers/cloudflare/worker.ts +44 -4
- 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/dom/desktop/icons.tsx +0 -2
- package/src/renderers/dom/styles.css +0 -3
- 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/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/screen-setup-file.ts +55 -0
- package/src/renderers/electrobun/bun/desktop/state-broadcaster.ts +44 -8
- package/src/renderers/electrobun/bun/desktop/update.ts +1 -1
- 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 +22 -109
- package/src/renderers/electrobun/bun/window/create.ts +23 -3
- package/src/renderers/electrobun/bun/window/electrobun-window-host.ts +306 -0
- package/src/renderers/electrobun/bun/window/events.ts +4 -4
- package/src/renderers/electrobun/bun/window/focus.ts +0 -25
- package/src/renderers/electrobun/bun/window/frame.ts +2 -1
- package/src/renderers/electrobun/bun/window/native-min-size.ts +322 -0
- 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 +16 -1
- 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/gloomberb-cloud/index.ts +5 -7
- package/src/sources/provider-router/batches.ts +18 -3
- package/src/sources/provider-router/financial-routes.ts +7 -1
- package/src/sources/provider-router/financials.ts +18 -4
- 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/data-provider.ts +14 -0
- package/src/types/desktop-window.ts +71 -2
- package/src/types/financials.ts +19 -3
- package/src/types/headless.ts +21 -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/double-escape-close.ts +38 -16
- package/src/utils/format.ts +30 -5
- 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/price-earnings.ts +18 -0
- package/src/utils/sec-filings.ts +7 -1
- package/patches/electrobun@1.18.1.patch +0 -633
- package/src/api-client/types.ts +0 -2441
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import Electrobun, { ApplicationMenu,
|
|
1
|
+
import Electrobun, { ApplicationMenu, Updater, 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,28 +8,12 @@ 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";
|
|
32
15
|
import { settleInstallerFolder } from "./desktop/installer-folder";
|
|
16
|
+
import { ensureInstallRecords } from "./desktop/install-records";
|
|
33
17
|
|
|
34
18
|
console.log = (...args) => console.error(...args);
|
|
35
19
|
console.info = (...args) => console.error(...args);
|
|
@@ -47,24 +31,17 @@ setConfigStoreHost(nodeConfigStoreHost);
|
|
|
47
31
|
// before the config, and its off switch, has been read.
|
|
48
32
|
installProcessCrashListeners();
|
|
49
33
|
|
|
50
|
-
//
|
|
51
|
-
//
|
|
52
|
-
// Electrobun
|
|
53
|
-
|
|
54
|
-
// from it before any window shows.
|
|
55
|
-
const installerFolderMove = await settleInstallerFolder({
|
|
34
|
+
// A Windows install from before Electrobun 2 lives in the installer's folder.
|
|
35
|
+
// Its last update put this build in Electrobun's folder, the only one
|
|
36
|
+
// Electrobun 2 updates: the installer's folder is retired in the background.
|
|
37
|
+
void settleInstallerFolder({
|
|
56
38
|
platform: process.platform,
|
|
57
39
|
execPath: process.execPath,
|
|
58
40
|
homeDir: homedir(),
|
|
59
41
|
localAppData: process.env.LOCALAPPDATA,
|
|
60
42
|
}).catch((error: unknown) => {
|
|
61
|
-
console.error("[desktop] could not
|
|
62
|
-
return null;
|
|
43
|
+
console.error("[desktop] could not retire the installer's folder", error instanceof Error ? error.message : String(error));
|
|
63
44
|
});
|
|
64
|
-
if (installerFolderMove?.kind === "relaunching") {
|
|
65
|
-
Utils.quit();
|
|
66
|
-
await new Promise<never>(() => {});
|
|
67
|
-
}
|
|
68
45
|
|
|
69
46
|
// An install from before the rename runs from Gloomberb.app, where its updater
|
|
70
47
|
// put this build. It takes the new name and opens again from there before any
|
|
@@ -87,6 +64,18 @@ if (appRename?.kind === "renamed") {
|
|
|
87
64
|
console.error(`[desktop] kept the app's old name: ${appRename.reason}`);
|
|
88
65
|
}
|
|
89
66
|
|
|
67
|
+
// A Mac app that has not updated yet has no folder for Electrobun's install
|
|
68
|
+
// records, which its launcher otherwise fails to write at every start. The
|
|
69
|
+
// records name the bundle the app runs from, so they are written once it has
|
|
70
|
+
// its new name: a Gloomberb.app being renamed above opens again as Gloom.app
|
|
71
|
+
// and writes them from there.
|
|
72
|
+
void ensureInstallRecords({
|
|
73
|
+
platform: process.platform,
|
|
74
|
+
execPath: process.execPath,
|
|
75
|
+
channel: () => Updater.localInfo.channel(),
|
|
76
|
+
channelRoot: () => Updater.appDataFolder(),
|
|
77
|
+
});
|
|
78
|
+
|
|
90
79
|
function readOpenUrlEvent(event: unknown): string | null {
|
|
91
80
|
const data = event && typeof event === "object" ? (event as { data?: unknown }).data : null;
|
|
92
81
|
if (!data || typeof data !== "object") return null;
|
|
@@ -123,87 +112,11 @@ backend.installApplicationMenu();
|
|
|
123
112
|
// started from. Cleaning up here is what makes the stray actually die.
|
|
124
113
|
reapStaleTerminalMedia();
|
|
125
114
|
|
|
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);
|
|
115
|
+
// The main window opens where it was left on these screens; extra windows
|
|
116
|
+
// follow once it has its data (desktop/window-controller.ts).
|
|
117
|
+
backend.startWindows();
|
|
196
118
|
// The window is loading its view; the services it will ask for start now
|
|
197
119
|
// rather than when it asks. Its `init` reports a failure, and retries.
|
|
198
120
|
startDesktopBackend(backend).catch((error) => {
|
|
199
121
|
console.error("[desktop] startup failed", error instanceof Error ? error.stack ?? error.message : String(error));
|
|
200
122
|
});
|
|
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);
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { BrowserWindow } from "electrobun/bun";
|
|
2
|
+
import { readFileSync } from "fs";
|
|
3
|
+
import { resolve } from "path";
|
|
2
4
|
import { measurePerf } from "../../../../utils/perf-marks";
|
|
3
5
|
import { trackWindowAttention } from "./attention";
|
|
4
6
|
import {
|
|
@@ -10,6 +12,7 @@ import {
|
|
|
10
12
|
type WindowResizeEvent,
|
|
11
13
|
} from "./events";
|
|
12
14
|
import type { WindowFrame, WindowMinimumSize } from "./frame";
|
|
15
|
+
import { applyNativeMinimumSize } from "./native-min-size";
|
|
13
16
|
import { applyWindowsCustomChrome } from "./windows-custom-chrome";
|
|
14
17
|
import { applyWindowsWindowIcon } from "./windows-icons";
|
|
15
18
|
import { fitPageToClientArea } from "./windows-native";
|
|
@@ -33,10 +36,24 @@ function desktopTitleBarStyle(): DesktopTitleBarStyle {
|
|
|
33
36
|
return process.platform === "linux" ? "hidden" : "hiddenInset";
|
|
34
37
|
}
|
|
35
38
|
|
|
39
|
+
let chromiumShipped: boolean | undefined;
|
|
40
|
+
|
|
41
|
+
/** Whether this build ships Chromium (Resources/build.json); a build that does not say is taken to. */
|
|
42
|
+
function shipsChromium(): boolean {
|
|
43
|
+
if (chromiumShipped !== undefined) return chromiumShipped;
|
|
44
|
+
try {
|
|
45
|
+
const build = JSON.parse(readFileSync(resolve("../Resources/build.json"), "utf8")) as { availableRenderers?: unknown };
|
|
46
|
+
chromiumShipped = !Array.isArray(build.availableRenderers) || build.availableRenderers.includes("cef");
|
|
47
|
+
} catch {
|
|
48
|
+
chromiumShipped = true;
|
|
49
|
+
}
|
|
50
|
+
return chromiumShipped;
|
|
51
|
+
}
|
|
52
|
+
|
|
36
53
|
function desktopWindowRenderer(): DesktopWindowRenderer {
|
|
37
54
|
if (process.platform === "win32") {
|
|
38
55
|
const hostArchitecture = process.env.PROCESSOR_ARCHITEW6432 ?? process.env.PROCESSOR_ARCHITECTURE;
|
|
39
|
-
return hostArchitecture?.toLowerCase() === "arm64" ? "native" : "cef";
|
|
56
|
+
return hostArchitecture?.toLowerCase() === "arm64" || !shipsChromium() ? "native" : "cef";
|
|
40
57
|
}
|
|
41
58
|
return "native";
|
|
42
59
|
}
|
|
@@ -82,7 +99,8 @@ interface AppWindowOptions {
|
|
|
82
99
|
|
|
83
100
|
/**
|
|
84
101
|
* Opens a window on the app view with this platform's chrome and icon, keeps
|
|
85
|
-
* its cached frame current as it moves, and holds it to `minSize
|
|
102
|
+
* its cached frame current as it moves, and holds it to `minSize`: the system
|
|
103
|
+
* does while it is resized, and a resize that still ends under it is undone.
|
|
86
104
|
*/
|
|
87
105
|
export function createAppWindow({ title, frame, rpc, minSize, onFrameChange, preload }: AppWindowOptions): BrowserWindow {
|
|
88
106
|
// Opening a window waits on the native layer, the webview's creation included.
|
|
@@ -100,11 +118,13 @@ export function createAppWindow({ title, frame, rpc, minSize, onFrameChange, pre
|
|
|
100
118
|
}));
|
|
101
119
|
applyWindowsWindowIcon(title);
|
|
102
120
|
applyWindowsCustomChrome(title);
|
|
121
|
+
applyNativeMinimumSize(window, minSize);
|
|
103
122
|
if (process.platform === "win32") {
|
|
104
123
|
loadAgainWhenTakenForCtrlClick(window);
|
|
105
124
|
// The page exists once it has loaded; until then there is nothing to fit.
|
|
106
125
|
window.webview.on("dom-ready", () => {
|
|
107
|
-
|
|
126
|
+
const handle = window.ptr;
|
|
127
|
+
if (handle) fitPageToClientArea(handle);
|
|
108
128
|
});
|
|
109
129
|
}
|
|
110
130
|
updateWindowFrameCache(window, frame, minSize);
|
|
@@ -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 (2.0.5, as 1.18) has no event for displays coming and going, nor
|
|
14
|
+
* for a window being minimized: both are read on a timer, this often while
|
|
15
|
+
* there is more 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: 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
|
+
}
|
|
@@ -52,10 +52,10 @@ type FramedWindow = Pick<BrowserWindow, "frame" | "getFrame" | "isMinimized" | "
|
|
|
52
52
|
|
|
53
53
|
/**
|
|
54
54
|
* Electrobun's Windows events do not carry the window's frame: a resize
|
|
55
|
-
* reports the client area's size
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
* frame it had.
|
|
55
|
+
* reports the client area's size rather than the window's (2.0.5; 1.18 put it
|
|
56
|
+
* at 0,0 too, and a move gave the client area's corner as unsigned 16-bit
|
|
57
|
+
* values), and both come while the window is minimized. There the frame is
|
|
58
|
+
* read from the window itself, and a minimized window keeps the frame it had.
|
|
59
59
|
*/
|
|
60
60
|
export function applyNativeWindowFrame(window: FramedWindow, minimumSize?: WindowMinimumSize): WindowFrame | null {
|
|
61
61
|
if (window.isMinimized()) return null;
|
|
@@ -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
|
-
}
|
|
@@ -12,7 +12,8 @@ export interface WindowMinimumSize {
|
|
|
12
12
|
|
|
13
13
|
export const DEFAULT_WINDOW_FRAME: WindowFrame = { x: 64, y: 48, width: 1440, height: 920 };
|
|
14
14
|
const DEFAULT_WINDOWS_WINDOW_FRAME: WindowFrame = { x: 32, y: 32, width: 960, height: 680 };
|
|
15
|
-
//
|
|
15
|
+
// Held by the system while a window is resized (native-min-size.ts), and by
|
|
16
|
+
// the resize handlers where that does not apply: Electrobun has no minimum size,
|
|
16
17
|
// https://github.com/blackboardsh/electrobun/issues/188
|
|
17
18
|
export const MAIN_WINDOW_MIN_SIZE: WindowMinimumSize = { width: 640, height: 400 };
|
|
18
19
|
export const DETACHED_WINDOW_MIN_SIZE: WindowMinimumSize = { width: 360, height: 240 };
|