gloomberb 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,7 @@
|
|
|
1
1
|
import type { BrowserWindow } from "electrobun/bun";
|
|
2
|
+
import type { NativeWindowEvent } from "../../../desktop/window-host";
|
|
3
|
+
import { clampFrameToScreens, sameRect } from "../../../desktop/geometry";
|
|
4
|
+
import { MAIN_WINDOW_ID } from "../../../desktop/screen-setup";
|
|
2
5
|
import { findPaneInstance } from "../../../../types/config";
|
|
3
6
|
import { isPaneDetached } from "../../../../layout/pane-manager";
|
|
4
7
|
import {
|
|
@@ -7,13 +10,7 @@ import {
|
|
|
7
10
|
normalizeWindowFrameWithMinimum,
|
|
8
11
|
type WindowFrame,
|
|
9
12
|
} from "../window/frame";
|
|
10
|
-
import {
|
|
11
|
-
detachedRpcKey,
|
|
12
|
-
focusWindowForRpcKey,
|
|
13
|
-
paneIdFromDetachedRpcKey,
|
|
14
|
-
} from "../window/focus";
|
|
15
|
-
import { getWindowFrame } from "../window/events";
|
|
16
|
-
import { createAppWindow } from "../window/create";
|
|
13
|
+
import { detachedRpcKey, paneIdFromDetachedRpcKey } from "../window/focus";
|
|
17
14
|
import type { DesktopBackend } from "./backend";
|
|
18
15
|
|
|
19
16
|
const INITIAL_DOCK_SUPPRESSION_MS = 800;
|
|
@@ -21,11 +18,16 @@ const WINDOW_CONTROL_DOCK_SUPPRESSION_MS = 5_000;
|
|
|
21
18
|
/** How long after the main window has its data the popped-out windows of the last session open. */
|
|
22
19
|
const LAUNCH_WINDOWS_DELAY_MS = 300;
|
|
23
20
|
|
|
21
|
+
/**
|
|
22
|
+
* The windows that hold one popped-out pane each, opened and moved through
|
|
23
|
+
* the window host like every other window. Their frames live in the config's
|
|
24
|
+
* layout, which is how they reopen where they were.
|
|
25
|
+
*/
|
|
24
26
|
export class DesktopDetachedWindowManager {
|
|
25
|
-
|
|
27
|
+
/** The panes with a window open. */
|
|
28
|
+
private readonly windows = new Set<string>();
|
|
26
29
|
private readonly frameTimers = new Map<string, ReturnType<typeof setTimeout>>();
|
|
27
30
|
private readonly dockTimers = new Map<string, ReturnType<typeof setTimeout>>();
|
|
28
|
-
private readonly closingPanes = new Set<string>();
|
|
29
31
|
private readonly pendingMoveFlush = new Set<string>();
|
|
30
32
|
private readonly suppressDockUntil = new Map<string, number>();
|
|
31
33
|
private readonly windowControlDockSuppressed = new Set<string>();
|
|
@@ -41,28 +43,58 @@ export class DesktopDetachedWindowManager {
|
|
|
41
43
|
|
|
42
44
|
/**
|
|
43
45
|
* The main window has its data: the popped-out windows open shortly
|
|
44
|
-
* after, once it has had a moment to draw and ask for what it shows
|
|
46
|
+
* after, once it has had a moment to draw and ask for what it shows, and
|
|
47
|
+
* then `onOpen` runs (the extra full windows open there).
|
|
45
48
|
*/
|
|
46
|
-
openAfterMainWindow(): void {
|
|
49
|
+
openAfterMainWindow(onOpen?: () => void): void {
|
|
47
50
|
if (this.windowsAllowed || this.windowsTimer) return;
|
|
48
51
|
this.windowsTimer = setTimeout(() => {
|
|
49
52
|
this.windowsTimer = null;
|
|
50
53
|
this.windowsAllowed = true;
|
|
51
54
|
this.reconcile();
|
|
55
|
+
onOpen?.();
|
|
52
56
|
}, LAUNCH_WINDOWS_DELAY_MS);
|
|
53
57
|
}
|
|
54
58
|
|
|
55
59
|
focusDetachedPane(instanceId: string): boolean {
|
|
56
|
-
return this.
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
focusWindowForRpcKey(rpcKey: string | undefined): boolean {
|
|
60
|
-
return focusWindowForRpcKey(rpcKey, this.backend.mainWindow, this.windows);
|
|
60
|
+
return this.backend.focusWindow(detachedRpcKey(instanceId));
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
getWindowForRpcKey(rpcKey: string | undefined): BrowserWindow | null {
|
|
64
64
|
const paneId = paneIdFromDetachedRpcKey(rpcKey);
|
|
65
|
-
return paneId
|
|
65
|
+
return paneId && this.windows.has(paneId) ? this.backend.nativeWindow(rpcKey) : null;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/** A popped-out pane's window moved or closed. */
|
|
69
|
+
handleWindowEvent(event: NativeWindowEvent): void {
|
|
70
|
+
const instanceId = paneIdFromDetachedRpcKey(event.id);
|
|
71
|
+
// A window this side closed says nothing (the host only reports the
|
|
72
|
+
// person's closes), and its state went with the close.
|
|
73
|
+
if (!instanceId || !this.windows.has(instanceId)) return;
|
|
74
|
+
if (event.type === "frame") {
|
|
75
|
+
this.scheduleMove(instanceId);
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
if (event.type !== "close") return;
|
|
79
|
+
this.cleanupState(instanceId);
|
|
80
|
+
const workspace = this.backend.workspace;
|
|
81
|
+
const config = this.backend.config;
|
|
82
|
+
if (!workspace || !config || !isPaneDetached(config.layout, instanceId)) return;
|
|
83
|
+
void this.backend.commitDesktopSnapshot(workspace.closeDetachedPane(instanceId));
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* A popped-out pane's saved frame, on a screen that is connected: one
|
|
88
|
+
* saved on a monitor since unplugged or at another resolution opens on
|
|
89
|
+
* screen, as the shell would leave it where it was asked.
|
|
90
|
+
*/
|
|
91
|
+
private onScreen(frame: WindowFrame): WindowFrame {
|
|
92
|
+
const host = this.backend.windowHost;
|
|
93
|
+
return host?.canPlaceWindows ? clampFrameToScreens(frame, host.listDisplays()) : frame;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
private frameOf(rpcKey: string): WindowFrame | null {
|
|
97
|
+
return this.backend.windowHost?.getWindowState(rpcKey)?.frame ?? null;
|
|
66
98
|
}
|
|
67
99
|
|
|
68
100
|
suppressAutoDockForRpcKey(rpcKey: string | undefined): void {
|
|
@@ -82,7 +114,7 @@ export class DesktopDetachedWindowManager {
|
|
|
82
114
|
if (remembered) {
|
|
83
115
|
return normalizeWindowFrameWithMinimum(remembered, DEFAULT_WINDOW_FRAME, DETACHED_WINDOW_MIN_SIZE);
|
|
84
116
|
}
|
|
85
|
-
const mainFrame =
|
|
117
|
+
const mainFrame = this.frameOf(MAIN_WINDOW_ID) ?? DEFAULT_WINDOW_FRAME;
|
|
86
118
|
return normalizeWindowFrameWithMinimum({
|
|
87
119
|
x: mainFrame.x + 72,
|
|
88
120
|
y: mainFrame.y + 72,
|
|
@@ -107,20 +139,26 @@ export class DesktopDetachedWindowManager {
|
|
|
107
139
|
const desiredEntries = new Map(config.layout.detached
|
|
108
140
|
.filter((entry) => !hidden(entry.instanceId))
|
|
109
141
|
.map((entry) => [entry.instanceId, entry] as const));
|
|
142
|
+
const host = this.backend.windowHost;
|
|
110
143
|
for (const [instanceId, entry] of desiredEntries) {
|
|
111
|
-
|
|
112
|
-
if (!existingWindow) {
|
|
144
|
+
if (!this.windows.has(instanceId)) {
|
|
113
145
|
if (this.windowsAllowed) this.createWindow(instanceId, entry);
|
|
114
146
|
continue;
|
|
115
147
|
}
|
|
116
148
|
|
|
117
|
-
const
|
|
149
|
+
const key = detachedRpcKey(instanceId);
|
|
150
|
+
const currentFrame = this.frameOf(key);
|
|
118
151
|
const hasLiveFrameUpdate = this.pendingMoveFlush.has(instanceId)
|
|
119
152
|
|| this.frameTimers.has(instanceId)
|
|
120
153
|
|| this.dockTimers.has(instanceId);
|
|
121
|
-
const
|
|
154
|
+
const savedFrame = currentFrame
|
|
122
155
|
? normalizeWindowFrameWithMinimum(entry, currentFrame, DETACHED_WINDOW_MIN_SIZE)
|
|
123
156
|
: null;
|
|
157
|
+
// Where the person left the window stays, even part off screen; a
|
|
158
|
+
// frame from elsewhere (or one saved off screen) lands on one.
|
|
159
|
+
const nextFrame = savedFrame && currentFrame && !sameRect(savedFrame, currentFrame)
|
|
160
|
+
? this.onScreen(savedFrame)
|
|
161
|
+
: savedFrame;
|
|
124
162
|
if (!hasLiveFrameUpdate
|
|
125
163
|
&& currentFrame
|
|
126
164
|
&& nextFrame
|
|
@@ -128,28 +166,27 @@ export class DesktopDetachedWindowManager {
|
|
|
128
166
|
|| currentFrame.y !== nextFrame.y
|
|
129
167
|
|| currentFrame.width !== nextFrame.width
|
|
130
168
|
|| currentFrame.height !== nextFrame.height)) {
|
|
131
|
-
|
|
169
|
+
host?.setFrame(key, nextFrame);
|
|
132
170
|
}
|
|
133
|
-
(
|
|
171
|
+
host?.setTitle(key, this.resolveTitle(instanceId));
|
|
134
172
|
}
|
|
135
173
|
|
|
136
|
-
for (const
|
|
174
|
+
for (const instanceId of [...this.windows]) {
|
|
137
175
|
if (desiredEntries.has(instanceId)) continue;
|
|
138
|
-
this.
|
|
139
|
-
this.cleanupState(instanceId);
|
|
140
|
-
(window as any).close?.();
|
|
176
|
+
this.closePaneWindow(instanceId);
|
|
141
177
|
}
|
|
142
178
|
}
|
|
143
179
|
|
|
144
180
|
closeAll(): void {
|
|
145
|
-
for (const
|
|
146
|
-
this.closingPanes.add(instanceId);
|
|
147
|
-
this.cleanupState(instanceId);
|
|
148
|
-
(window as any).close?.();
|
|
149
|
-
}
|
|
181
|
+
for (const instanceId of [...this.windows]) this.closePaneWindow(instanceId);
|
|
150
182
|
this.backend.stateBroadcaster.resetDockPreview();
|
|
151
183
|
}
|
|
152
184
|
|
|
185
|
+
private closePaneWindow(instanceId: string): void {
|
|
186
|
+
this.cleanupState(instanceId);
|
|
187
|
+
this.backend.windowHost?.closeWindow(detachedRpcKey(instanceId));
|
|
188
|
+
}
|
|
189
|
+
|
|
153
190
|
private resolveTitle(instanceId: string): string {
|
|
154
191
|
const config = this.backend.config;
|
|
155
192
|
const instance = config ? findPaneInstance(config.layout, instanceId) : null;
|
|
@@ -158,7 +195,7 @@ export class DesktopDetachedWindowManager {
|
|
|
158
195
|
}
|
|
159
196
|
|
|
160
197
|
private resolveDockEdge(frame: WindowFrame): "left" | "right" | "top" | "bottom" | null {
|
|
161
|
-
const mainFrame =
|
|
198
|
+
const mainFrame = this.frameOf(MAIN_WINDOW_ID);
|
|
162
199
|
if (!mainFrame) return null;
|
|
163
200
|
const threshold = 72;
|
|
164
201
|
const headerMidX = frame.x + (frame.width / 2);
|
|
@@ -187,32 +224,18 @@ export class DesktopDetachedWindowManager {
|
|
|
187
224
|
private createWindow(
|
|
188
225
|
instanceId: string,
|
|
189
226
|
frame: Partial<WindowFrame>,
|
|
190
|
-
):
|
|
191
|
-
const
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
const window = createAppWindow({
|
|
195
|
-
title,
|
|
196
|
-
frame: initialFrame,
|
|
197
|
-
rpc: rpc as never,
|
|
198
|
-
minSize: DETACHED_WINDOW_MIN_SIZE,
|
|
199
|
-
onFrameChange: () => this.scheduleMove(instanceId),
|
|
200
|
-
});
|
|
201
|
-
this.windows.set(instanceId, window);
|
|
227
|
+
): void {
|
|
228
|
+
const host = this.backend.windowHost;
|
|
229
|
+
if (!host) return;
|
|
230
|
+
this.windows.add(instanceId);
|
|
202
231
|
this.suppressDockUntil.set(instanceId, Date.now() + INITIAL_DOCK_SUPPRESSION_MS);
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
this.
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
if (shouldIgnore || !workspace || !config || !isPaneDetached(config.layout, instanceId)) {
|
|
210
|
-
return;
|
|
211
|
-
}
|
|
212
|
-
void this.backend.commitDesktopSnapshot(this.backend.requireWorkspace().closeDetachedPane(instanceId));
|
|
232
|
+
host.openWindow({
|
|
233
|
+
id: detachedRpcKey(instanceId),
|
|
234
|
+
kind: "pane",
|
|
235
|
+
title: this.resolveTitle(instanceId),
|
|
236
|
+
frame: this.onScreen(normalizeWindowFrameWithMinimum(frame, DEFAULT_WINDOW_FRAME, DETACHED_WINDOW_MIN_SIZE)),
|
|
237
|
+
minSize: DETACHED_WINDOW_MIN_SIZE,
|
|
213
238
|
});
|
|
214
|
-
|
|
215
|
-
return window;
|
|
216
239
|
}
|
|
217
240
|
|
|
218
241
|
private scheduleMove(instanceId: string): void {
|
|
@@ -225,14 +248,13 @@ export class DesktopDetachedWindowManager {
|
|
|
225
248
|
}
|
|
226
249
|
|
|
227
250
|
private handleMove(instanceId: string): void {
|
|
228
|
-
const window = this.windows.get(instanceId);
|
|
229
251
|
const workspace = this.backend.workspace;
|
|
230
252
|
const config = this.backend.config;
|
|
231
|
-
if (!
|
|
253
|
+
if (!this.windows.has(instanceId) || !workspace || !config || !isPaneDetached(config.layout, instanceId)) {
|
|
232
254
|
return;
|
|
233
255
|
}
|
|
234
256
|
|
|
235
|
-
const frame =
|
|
257
|
+
const frame = this.frameOf(detachedRpcKey(instanceId));
|
|
236
258
|
if (!frame) return;
|
|
237
259
|
const edge = this.resolveDockEdge(frame);
|
|
238
260
|
|
|
@@ -38,9 +38,7 @@ function playNotificationSound(sound: string | undefined): void {
|
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
function windowForRpcKey(backend: DesktopBackend, windowKey: string | undefined): BrowserWindow | null {
|
|
41
|
-
return windowKey
|
|
42
|
-
? backend.mainWindow
|
|
43
|
-
: backend.detachedWindows.getWindowForRpcKey(windowKey);
|
|
41
|
+
return backend.nativeWindow(windowKey);
|
|
44
42
|
}
|
|
45
43
|
|
|
46
44
|
/**
|
|
@@ -78,17 +76,9 @@ function controlWindow(
|
|
|
78
76
|
return true;
|
|
79
77
|
}
|
|
80
78
|
|
|
81
|
-
/** Exiting closes
|
|
79
|
+
/** Exiting closes every window and the services, then quits. */
|
|
82
80
|
function exitDesktopApp(backend: DesktopBackend): void {
|
|
83
|
-
backend.
|
|
84
|
-
backend.teardownServices();
|
|
85
|
-
const mainWindow = backend.mainWindow;
|
|
86
|
-
if (mainWindow) {
|
|
87
|
-
mainWindow.close();
|
|
88
|
-
backend.mainWindow = null;
|
|
89
|
-
return;
|
|
90
|
-
}
|
|
91
|
-
Utils.quit();
|
|
81
|
+
backend.quit();
|
|
92
82
|
}
|
|
93
83
|
|
|
94
84
|
function normalizeWindowResizeEdge(edge: unknown): DesktopWindowResizeEdge {
|
|
@@ -155,7 +145,7 @@ export async function handleDesktopHostRequest(
|
|
|
155
145
|
return null;
|
|
156
146
|
case "host.focusWindow": {
|
|
157
147
|
const windowKey = backend.rpcs.getRpcWindowKey(rpc);
|
|
158
|
-
|
|
148
|
+
backend.focusWindow(windowKey);
|
|
159
149
|
return null;
|
|
160
150
|
}
|
|
161
151
|
case "host.copyPngImage": {
|
|
@@ -31,13 +31,15 @@ import { markStartupComplete } from "../../../../utils/main-thread-stall";
|
|
|
31
31
|
interface DesktopWindowTarget {
|
|
32
32
|
kind: "main" | "detached";
|
|
33
33
|
paneId?: string;
|
|
34
|
+
/** A full window's id: the main window's, or an extra window's. */
|
|
35
|
+
windowId?: string;
|
|
34
36
|
}
|
|
35
37
|
|
|
36
38
|
function normalizeInitWindowTarget(
|
|
37
39
|
rpcKey: string | undefined,
|
|
38
40
|
payload: DesktopBackendRequestPayload<"init">,
|
|
39
41
|
): DesktopWindowTarget {
|
|
40
|
-
if (rpcKey === MAIN_WINDOW_RPC_KEY) return { kind: "main" };
|
|
42
|
+
if (rpcKey === MAIN_WINDOW_RPC_KEY) return { kind: "main", windowId: MAIN_WINDOW_RPC_KEY };
|
|
41
43
|
|
|
42
44
|
const detachedPaneId = paneIdFromDetachedRpcKey(rpcKey);
|
|
43
45
|
if (detachedPaneId) {
|
|
@@ -46,6 +48,8 @@ function normalizeInitWindowTarget(
|
|
|
46
48
|
paneId: detachedPaneId,
|
|
47
49
|
};
|
|
48
50
|
}
|
|
51
|
+
// Every other window the backend opens is a full window with its own tabs.
|
|
52
|
+
if (rpcKey) return { kind: "main", windowId: rpcKey };
|
|
49
53
|
|
|
50
54
|
const kind = payload.kind === "detached" ? "detached" : "main";
|
|
51
55
|
return {
|
|
@@ -75,13 +79,21 @@ function buildInitializationPayload(
|
|
|
75
79
|
config: AppConfig,
|
|
76
80
|
services: AppServices,
|
|
77
81
|
windowTarget: DesktopWindowTarget,
|
|
82
|
+
windowKey: string | undefined,
|
|
78
83
|
): ElectrobunBackendInit {
|
|
84
|
+
const mainWindow = windowTarget.windowId === MAIN_WINDOW_RPC_KEY;
|
|
79
85
|
// The main window says once what the launch's seed could not install.
|
|
80
|
-
const pluginSeedNotice =
|
|
86
|
+
const pluginSeedNotice = mainWindow ? takePluginSeedNotice() : null;
|
|
87
|
+
// Each full window draws its own tabs; a popped-out pane's draws the main
|
|
88
|
+
// window's. Numbered like every state sent, so the window's first sync is
|
|
89
|
+
// merged against it.
|
|
90
|
+
const projected = backend.workspace?.getWindowSnapshot(windowTarget.windowId ?? MAIN_WINDOW_RPC_KEY) ?? null;
|
|
91
|
+
const desktopSnapshot = projected ? backend.stateBroadcaster.stamp(projected) : null;
|
|
92
|
+
if (desktopSnapshot && windowKey) backend.workspace?.noteDelivered(windowKey, desktopSnapshot.stateSeq!, desktopSnapshot);
|
|
81
93
|
return {
|
|
82
|
-
config,
|
|
94
|
+
config: desktopSnapshot?.config ?? config,
|
|
83
95
|
sessionSnapshot: backend.getSessionSnapshot(),
|
|
84
|
-
desktopSnapshot
|
|
96
|
+
desktopSnapshot,
|
|
85
97
|
desktopThemePreview: backend.stateBroadcaster.currentThemePreview,
|
|
86
98
|
pluginState: loadDesktopPluginState(services.pluginRegistry),
|
|
87
99
|
savedResources: loadSavedResources(services, config),
|
|
@@ -90,6 +102,8 @@ function buildInitializationPayload(
|
|
|
90
102
|
hostName: hostname(),
|
|
91
103
|
windowKind: windowTarget.kind,
|
|
92
104
|
paneId: windowTarget.paneId,
|
|
105
|
+
...(windowTarget.windowId ? { windowId: windowTarget.windowId, windows: backend.windowInfos() } : {}),
|
|
106
|
+
...(mainWindow ? { otherWindowTabs: backend.otherWindowTabsForInit() } : {}),
|
|
93
107
|
...(pluginSeedNotice ? { pluginSeedNotice } : {}),
|
|
94
108
|
telemetry: {
|
|
95
109
|
installId: readOrCreateInstallId(config.dataDir),
|
|
@@ -185,23 +199,28 @@ export async function initializeDesktopBackend(
|
|
|
185
199
|
rpc: DesktopRpc,
|
|
186
200
|
payload: DesktopBackendRequestPayload<"init">,
|
|
187
201
|
): Promise<ElectrobunBackendInit> {
|
|
188
|
-
const
|
|
202
|
+
const windowKey = backend.rpcs.getRpcWindowKey(rpc);
|
|
203
|
+
const windowTarget = normalizeInitWindowTarget(windowKey, payload);
|
|
189
204
|
backend.rpcs.markWindowRpcReady(rpc);
|
|
190
205
|
backend.stateBroadcaster.forgetWindowState(rpc);
|
|
206
|
+
// Its page loaded and runs: the next window waiting to open may.
|
|
207
|
+
if (windowKey) backend.windowHost?.windowDrawn(windowKey);
|
|
191
208
|
|
|
192
209
|
await startDesktopBackend(backend);
|
|
193
210
|
const config = backend.requireConfig();
|
|
194
211
|
const services = backend.requireServices();
|
|
195
212
|
if (!backend.workspace) {
|
|
196
|
-
backend.workspace = createDesktopWorkspace(config, backend.getSessionSnapshot());
|
|
197
|
-
backend.
|
|
213
|
+
backend.workspace = createDesktopWorkspace(config, backend.getSessionSnapshot(), backend.windowController?.screenSetup.windows);
|
|
214
|
+
backend.reconcileWindows();
|
|
198
215
|
}
|
|
199
|
-
|
|
216
|
+
// A window that loads again starts from this state: nothing sent before counts.
|
|
217
|
+
if (windowKey) backend.workspace.forgetWindow(windowKey);
|
|
218
|
+
const init = buildInitializationPayload(backend, config, services, windowTarget, windowKey);
|
|
200
219
|
// The main window has what it needs to draw: this process is up, and the
|
|
201
|
-
// popped-out windows open next.
|
|
202
|
-
if (windowTarget.
|
|
220
|
+
// popped-out panes and extra windows open next.
|
|
221
|
+
if (windowTarget.windowId === MAIN_WINDOW_RPC_KEY) {
|
|
203
222
|
markStartupComplete();
|
|
204
|
-
backend.
|
|
223
|
+
backend.openWindowsAfterMainWindow();
|
|
205
224
|
}
|
|
206
225
|
return init;
|
|
207
226
|
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { lstat, mkdir } from "fs/promises";
|
|
2
|
+
import { dirname, join, resolve } from "path";
|
|
3
|
+
import { logFailure } from "../../../../utils/log-failure";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Electrobun 2 keeps an install's records (its uninstaller and the manifest
|
|
7
|
+
* of what the app put where) in the app's folder under Application Support,
|
|
8
|
+
* and its launcher writes them at every start until they exist. It never
|
|
9
|
+
* makes that folder: on a Mac the app is copied out of the disk image or by
|
|
10
|
+
* Homebrew, and the folder only appears once an update downloads into it.
|
|
11
|
+
* Until then every start logged "Bootstrap install failed ... FileNotFound".
|
|
12
|
+
* So the app makes the folder and has its bundled uninstaller write the
|
|
13
|
+
* records right away, as the launcher would have.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
export interface InstallRecordsContext {
|
|
17
|
+
platform: string;
|
|
18
|
+
/** The running Bun: `<bundle>/Contents/MacOS/bun`. */
|
|
19
|
+
execPath: string;
|
|
20
|
+
/** Electrobun's folder for this install, `~/Library/Application Support/<identifier>/<channel>`. */
|
|
21
|
+
channelRoot: () => Promise<string>;
|
|
22
|
+
/** The build's channel; a dev build has no records. */
|
|
23
|
+
channel: () => Promise<string>;
|
|
24
|
+
run?: (command: string[]) => Promise<number>;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export type InstallRecordsResult = "none" | "written" | "failed";
|
|
28
|
+
|
|
29
|
+
const MANIFEST = ".electrobun-uninstall.json";
|
|
30
|
+
const MANAGER = "uninstall";
|
|
31
|
+
|
|
32
|
+
async function isFile(path: string): Promise<boolean> {
|
|
33
|
+
return lstat(path).then((stat) => stat.isFile(), () => false);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
async function runQuietly(command: string[]): Promise<number> {
|
|
37
|
+
const child = Bun.spawn(command, { stdio: ["ignore", "ignore", "pipe"] });
|
|
38
|
+
const [code, stderr] = await Promise.all([child.exited, new Response(child.stderr).text()]);
|
|
39
|
+
if (code !== 0 && stderr.trim()) console.error(`[desktop] ${stderr.trim()}`);
|
|
40
|
+
return code;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export async function ensureInstallRecords(context: InstallRecordsContext): Promise<InstallRecordsResult> {
|
|
44
|
+
if (context.platform !== "darwin") return "none";
|
|
45
|
+
try {
|
|
46
|
+
if ((await context.channel()) === "dev") return "none";
|
|
47
|
+
const root = await context.channelRoot();
|
|
48
|
+
if (await isFile(join(root, MANIFEST)) && await isFile(join(root, MANAGER))) return "none";
|
|
49
|
+
const bundledManager = resolve(dirname(context.execPath), "..", "Resources", MANAGER);
|
|
50
|
+
if (!await isFile(bundledManager)) return "none";
|
|
51
|
+
await mkdir(root, { recursive: true });
|
|
52
|
+
const code = await (context.run ?? runQuietly)([bundledManager, "--bootstrap-install", root, "--quiet"]);
|
|
53
|
+
if (code !== 0) throw new Error(`the uninstaller exited with ${code}`);
|
|
54
|
+
return "written";
|
|
55
|
+
} catch (error) {
|
|
56
|
+
logFailure("desktop-install-records", "Could not write the app's install records")(error);
|
|
57
|
+
return "failed";
|
|
58
|
+
}
|
|
59
|
+
}
|