gloomberb 0.19.4 → 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 +3 -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/command-utils.ts +4 -0
- package/src/cli/commands/market.ts +264 -33
- package/src/cli/commands/search.ts +22 -4
- package/src/cli/commands/ticker.ts +84 -39
- package/src/cli/currency-name-hint.ts +60 -0
- package/src/cli/glossary.ts +3 -3
- package/src/cli/history-rows.ts +18 -1
- package/src/cli/known-gaps.ts +25 -2
- package/src/cli/listing-arg.ts +12 -0
- package/src/cli/not-a-ticker.ts +5 -3
- package/src/cli/pane-functions/capabilities.ts +2 -0
- package/src/cli/pane-functions/catalog.ts +31 -5
- package/src/cli/pane-functions/function-help.ts +8 -5
- package/src/cli/pane-functions/headless.ts +11 -6
- package/src/cli/pane-functions/market-session.ts +6 -7
- package/src/cli/pane-functions/resolver.ts +75 -2
- package/src/cli/quote-answer.ts +9 -0
- package/src/cli/series-search.ts +4 -5
- 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-bitmap.ts +28 -2
- 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 +30 -7
- 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/active-drag.ts +38 -7
- package/src/components/layout/shell/drag/magnets.ts +106 -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/layout/window-controls.tsx +96 -35
- package/src/components/layout/window-fullscreen.ts +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/quote-flash.ts +36 -32
- 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/coordinator/events.ts +17 -1
- package/src/market-data/frame-scheduler.ts +47 -10
- package/src/market-data/frame-wake.ts +74 -0
- package/src/market-data/futures-board.ts +7 -6
- package/src/market-data/futures-contract.ts +14 -3
- package/src/market-data/hooks.tsx +12 -3
- package/src/market-data/market/freshness.ts +18 -0
- package/src/market-data/market/status.ts +15 -2
- package/src/market-data/performance.ts +78 -9
- package/src/market-data/request-types.ts +6 -3
- package/src/plugins/builtin/alerts/cli.ts +2 -1
- package/src/plugins/builtin/analytics/risk-evidence.ts +1 -0
- package/src/plugins/builtin/attention/evidence.ts +1 -1
- package/src/plugins/builtin/awards/client.ts +1 -1
- package/src/plugins/builtin/awards/evidence.ts +1 -1
- package/src/plugins/builtin/awards/pane.tsx +2 -1
- 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/math.ts +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/broker-manager/footer.ts +3 -2
- package/src/plugins/builtin/broker-manager/index.tsx +2 -1
- package/src/plugins/builtin/broker-manager/keyboard.ts +2 -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/catalysts/evidence.ts +1 -1
- package/src/plugins/builtin/catalysts/pane.tsx +2 -1
- package/src/plugins/builtin/cds/headless.ts +1 -0
- package/src/plugins/builtin/cds/index.tsx +1 -1
- package/src/plugins/builtin/chart-composer/headless.ts +40 -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/cloud-tweets/table.tsx +3 -2
- package/src/plugins/builtin/comment-letters/client.ts +2 -1
- package/src/plugins/builtin/company-kpis/client.ts +1 -1
- package/src/plugins/builtin/company-kpis/pane.tsx +2 -1
- package/src/plugins/builtin/company-kpis/screenshot-evidence.ts +3 -2
- package/src/plugins/builtin/correlation/headless.ts +3 -2
- package/src/plugins/builtin/cot/headless.ts +9 -3
- package/src/plugins/builtin/cot/model.ts +44 -3
- package/src/plugins/builtin/credit-documents/client.ts +1 -1
- package/src/plugins/builtin/credit-documents/evidence.ts +1 -1
- package/src/plugins/builtin/credit-documents/pane.tsx +2 -1
- 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-calls/pane.tsx +1 -1
- package/src/plugins/builtin/earnings-ripple/index.tsx +6 -1
- package/src/plugins/builtin/earnings-ripple/pane.tsx +1 -1
- package/src/plugins/builtin/econ/calendar-model.ts +30 -6
- package/src/plugins/builtin/econ/fred-catalog.ts +5 -5
- package/src/plugins/builtin/econ/print-watch.ts +3 -1
- 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/series.ts +16 -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/fx-matrix/headless.ts +4 -2
- package/src/plugins/builtin/fx-matrix/index.tsx +37 -3
- package/src/plugins/builtin/fx-matrix/pairs.ts +15 -0
- package/src/plugins/builtin/gpu/headless.ts +2 -1
- package/src/plugins/builtin/help/function-card.tsx +2 -1
- package/src/plugins/builtin/help/index.tsx +2 -1
- package/src/plugins/builtin/insider/display.ts +45 -6
- package/src/plugins/builtin/ipo-calendar/model.ts +2 -0
- package/src/plugins/builtin/iv-history/client.ts +2 -1
- package/src/plugins/builtin/iv-history/headless.ts +2 -1
- package/src/plugins/builtin/jobs/pages.ts +4 -4
- package/src/plugins/builtin/kelly-sizer/headless.ts +2 -1
- 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-heatmap/index.tsx +2 -1
- package/src/plugins/builtin/market-movers/index.tsx +4 -3
- package/src/plugins/builtin/members/client.ts +1 -1
- package/src/plugins/builtin/mna/distress/client.ts +1 -0
- package/src/plugins/builtin/mna/distress/headless.ts +1 -0
- package/src/plugins/builtin/mna/pane.tsx +4 -1
- package/src/plugins/builtin/options/market-reference.ts +1 -1
- package/src/plugins/builtin/options/open-interest-as-of.ts +3 -1
- package/src/plugins/builtin/options/view.tsx +2 -1
- package/src/plugins/builtin/options-calculator/evidence.ts +1 -1
- package/src/plugins/builtin/options-scenario/csp-screen-pane.tsx +1 -1
- package/src/plugins/builtin/options-scenario/csp-screen.ts +8 -4
- package/src/plugins/builtin/options-scenario/csp.ts +28 -9
- package/src/plugins/builtin/options-scenario/evidence.ts +5 -4
- package/src/plugins/builtin/options-scenario/pane.tsx +2 -1
- package/src/plugins/builtin/perps/client.ts +1 -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 +4 -2
- package/src/plugins/builtin/portfolio-list/pane/index.tsx +7 -3
- package/src/plugins/builtin/portfolio-list/use-throttled-memo.ts +10 -19
- package/src/plugins/builtin/rate-path/headless.ts +24 -10
- package/src/plugins/builtin/research/analyst-model.ts +1 -0
- package/src/plugins/builtin/research/equity-diagnostic-pane.tsx +2 -1
- package/src/plugins/builtin/research/event-model.ts +10 -3
- package/src/plugins/builtin/research/events-headless.ts +20 -2
- package/src/plugins/builtin/research/index.tsx +1 -0
- package/src/plugins/builtin/research/relative-valuation-currency.ts +1 -1
- package/src/plugins/builtin/research/relative-valuation-peers.ts +2 -1
- package/src/plugins/builtin/research-search/command-bar-search.ts +3 -1
- package/src/plugins/builtin/research-search/snippet.ts +1 -0
- package/src/plugins/builtin/revenue-breakdown/client.ts +3 -2
- package/src/plugins/builtin/seasonality/headless.ts +2 -1
- package/src/plugins/builtin/sec/command-bar-search.ts +3 -2
- package/src/plugins/builtin/sec/fund-facts.ts +17 -1
- package/src/plugins/builtin/sec/index.tsx +8 -5
- package/src/plugins/builtin/sec/row-summaries.ts +28 -12
- 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-client.ts +2 -1
- package/src/plugins/builtin/short-interest/watch-model.ts +1 -1
- package/src/plugins/builtin/social-mentions/client.ts +2 -1
- package/src/plugins/builtin/supply-chain/client.ts +1 -1
- package/src/plugins/builtin/supply-chain/evidence.ts +1 -1
- package/src/plugins/builtin/supply-chain/graph-pane.tsx +2 -1
- package/src/plugins/builtin/supply-chain/pane.tsx +2 -1
- package/src/plugins/builtin/ticker-detail/adr-pair/headless.ts +1 -1
- package/src/plugins/builtin/ticker-detail/adr-pair/model.ts +24 -4
- package/src/plugins/builtin/ticker-detail/adr-pair/tab.tsx +1 -1
- package/src/plugins/builtin/time-sales/client.ts +1 -0
- 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/vol-surface/client.ts +2 -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 +9 -2
- 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/portfolio/column-values.ts +76 -10
- 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/dom/host/box.tsx +204 -176
- package/src/renderers/dom/host/style.ts +49 -20
- package/src/renderers/dom/host/text.tsx +3 -2
- 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 +322 -19
- package/src/renderers/electrobun/bun/desktop/detached-windows.ts +83 -61
- package/src/renderers/electrobun/bun/desktop/host-requests.ts +29 -15
- package/src/renderers/electrobun/bun/desktop/initialization.ts +30 -11
- package/src/renderers/electrobun/bun/desktop/relaunch.ts +9 -1
- 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/windows-script.ts +9 -6
- 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/bun/window/windows-native.ts +26 -1
- package/src/renderers/electrobun/shared/protocol.ts +50 -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/renderers/electrobun/view/ui-host.tsx +7 -0
- package/src/renderers/electrobun/view/window-fullscreen.ts +10 -3
- package/src/series/fred-argument.ts +17 -0
- package/src/sources/provider-router/financial-routes.ts +7 -1
- package/src/sources/provider-router/index.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/price-units.ts +11 -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/host.tsx +2 -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/currency-names.ts +20 -0
- package/src/utils/currency-pair.ts +6 -0
- package/src/utils/exchange-rate-snapshot.ts +20 -2
- package/src/utils/format.ts +7 -2
- package/src/utils/futures-generic.ts +12 -0
- package/src/utils/fx-market-hours.ts +43 -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,8 +1,28 @@
|
|
|
1
1
|
import type { AppSessionSnapshot } from "../../../../../core/state/session-persistence";
|
|
2
|
-
import { clonePaneStateMap,
|
|
3
|
-
import { cloneLayout, findPaneInstance, type AppConfig, type LayoutConfig } from "../../../../../types/config";
|
|
4
|
-
import type { DesktopSharedStateSnapshot } from "../../../../../types/desktop-window";
|
|
2
|
+
import { clonePaneStateMap, type PaneRuntimeState } from "../../../../../core/state/app/state";
|
|
3
|
+
import { cloneLayout, findPaneInstance, type AppConfig, type LayoutConfig, type SavedLayout } from "../../../../../types/config";
|
|
4
|
+
import type { DesktopSharedStateSnapshot, OtherWindowTab } from "../../../../../types/desktop-window";
|
|
5
5
|
import { detachPaneToFrame, dockPane, insertAtRootEdge, removePane } from "../../../../../layout/pane-manager";
|
|
6
|
+
import { MAIN_WINDOW_ID, type ExtraWindowRecord } from "../../../../desktop/screen-setup";
|
|
7
|
+
import {
|
|
8
|
+
activateLayout,
|
|
9
|
+
addWindow,
|
|
10
|
+
closeWindow,
|
|
11
|
+
createWindowLayouts,
|
|
12
|
+
extraWindowRecords,
|
|
13
|
+
layoutMoveBlock,
|
|
14
|
+
locatePane,
|
|
15
|
+
mergeWindowSnapshot,
|
|
16
|
+
moveLayoutToWindow,
|
|
17
|
+
movePaneToWindow,
|
|
18
|
+
otherWindowTabs,
|
|
19
|
+
paneMoveBlock,
|
|
20
|
+
projectWindow,
|
|
21
|
+
replaceSharedConfig,
|
|
22
|
+
windowOfLayout,
|
|
23
|
+
windowTabs,
|
|
24
|
+
type WindowLayouts,
|
|
25
|
+
} from "../../../../desktop/window-layouts";
|
|
6
26
|
import type { WindowFrame } from "../../window/frame";
|
|
7
27
|
|
|
8
28
|
function cloneSavedLayouts(config: AppConfig): AppConfig["layouts"] {
|
|
@@ -13,6 +33,19 @@ function cloneSavedLayouts(config: AppConfig): AppConfig["layouts"] {
|
|
|
13
33
|
}));
|
|
14
34
|
}
|
|
15
35
|
|
|
36
|
+
function cloneSnapshot(snapshot: DesktopSharedStateSnapshot): DesktopSharedStateSnapshot {
|
|
37
|
+
return {
|
|
38
|
+
...snapshot,
|
|
39
|
+
config: {
|
|
40
|
+
...snapshot.config,
|
|
41
|
+
layout: cloneLayout(snapshot.config.layout),
|
|
42
|
+
layouts: cloneSavedLayouts(snapshot.config),
|
|
43
|
+
},
|
|
44
|
+
paneState: clonePaneStateMap(snapshot.paneState),
|
|
45
|
+
brokerSyncErrors: { ...snapshot.brokerSyncErrors },
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
|
|
16
49
|
function filterPaneState(
|
|
17
50
|
layout: AppConfig["layout"],
|
|
18
51
|
paneState: Record<string, PaneRuntimeState>,
|
|
@@ -50,6 +83,23 @@ function keepDetachedFrames(layout: LayoutConfig, current: LayoutConfig): Layout
|
|
|
50
83
|
), layout);
|
|
51
84
|
}
|
|
52
85
|
|
|
86
|
+
/** The same, for the main window's live layout and its saved copy. */
|
|
87
|
+
function keepMainDetachedFrames(state: WindowLayouts, current: LayoutConfig): WindowLayouts {
|
|
88
|
+
if (current.detached.length === 0) return state;
|
|
89
|
+
const layout = keepDetachedFrames(state.config.layout, current);
|
|
90
|
+
if (layout === state.config.layout) return state;
|
|
91
|
+
return {
|
|
92
|
+
...state,
|
|
93
|
+
config: {
|
|
94
|
+
...state.config,
|
|
95
|
+
layout,
|
|
96
|
+
layouts: state.config.layouts.map((entry, index) => (
|
|
97
|
+
index === state.config.activeLayoutIndex ? { ...entry, layout: cloneLayout(layout) } : entry
|
|
98
|
+
)),
|
|
99
|
+
},
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
|
|
53
103
|
/**
|
|
54
104
|
* A popped-out window cannot open, move or close panes, and its copy of the
|
|
55
105
|
* layout is refreshed only when its own pane changes. So a whole-config save
|
|
@@ -81,10 +131,48 @@ function rememberDetachedFrame(layout: LayoutConfig, paneId: string): LayoutConf
|
|
|
81
131
|
};
|
|
82
132
|
}
|
|
83
133
|
|
|
134
|
+
/**
|
|
135
|
+
* How many states sent to a window are kept for its next sync to be merged
|
|
136
|
+
* against: a window takes each state as it comes, so its sync names one of
|
|
137
|
+
* the last few (frame saves, the quickest series, are debounced). They are
|
|
138
|
+
* not copies: the workspace never changes a state in place, it builds a new one.
|
|
139
|
+
*/
|
|
140
|
+
const SENT_HISTORY = 8;
|
|
141
|
+
|
|
84
142
|
export interface DesktopWorkspace {
|
|
143
|
+
/** The shared state: every tab, with the main window's active layout, pane state and focus. What is saved. */
|
|
85
144
|
getSnapshot(): DesktopSharedStateSnapshot;
|
|
86
|
-
|
|
145
|
+
/** What a full window draws: its own tabs and state. A popped-out pane's window gets the main window's. */
|
|
146
|
+
getWindowSnapshot(windowId: string): DesktopSharedStateSnapshot | null;
|
|
147
|
+
/**
|
|
148
|
+
* The same, not copied: it shares objects with the workspace, so it is
|
|
149
|
+
* only read, to compare, send or keep as a merge base, never changed.
|
|
150
|
+
*/
|
|
151
|
+
peekWindowSnapshot(windowId: string): DesktopSharedStateSnapshot | null;
|
|
152
|
+
/** The full windows, the main one first. */
|
|
153
|
+
windowIds(): string[];
|
|
154
|
+
extraWindows(): ExtraWindowRecord[];
|
|
155
|
+
/** Where a pane is: its tab and the window showing it. */
|
|
156
|
+
locatePane(paneId: string): { layoutId: string; windowId: string } | null;
|
|
157
|
+
windowOfLayout(layoutId: string): string | null;
|
|
158
|
+
/** Names of each full window's tabs, for menus that offer to move something there. */
|
|
159
|
+
windowTabNames(windowId: string): { active: string; count: number } | null;
|
|
160
|
+
/**
|
|
161
|
+
* The tabs the windows besides the main one hold, at their places, for the
|
|
162
|
+
* main window's cloud sync; empty with one window. Read to tell the main
|
|
163
|
+
* window, and kept as what it was told.
|
|
164
|
+
*/
|
|
165
|
+
otherWindowTabs(): OtherWindowTab[];
|
|
166
|
+
/** A state `windowId` was sent, under the number it carried; its next sync may be built on it. Only with more than one window. */
|
|
167
|
+
noteDelivered(windowId: string, seq: number, snapshot: DesktopSharedStateSnapshot): void;
|
|
168
|
+
/** A window started over (a load or reload): nothing sent to it before counts. */
|
|
169
|
+
forgetWindow(windowId: string): void;
|
|
170
|
+
syncMainState(snapshot: DesktopSharedStateSnapshot, baseSeq?: number | null): DesktopSharedStateSnapshot;
|
|
171
|
+
/** A full window's whole state, merged over what it was built on: `baseSeq` names a state it was sent, else its own last. */
|
|
172
|
+
syncWindowState(windowId: string, snapshot: DesktopSharedStateSnapshot, baseSeq?: number | null): DesktopSharedStateSnapshot;
|
|
87
173
|
replaceConfig(config: AppConfig, options?: { layoutChanged?: boolean }): DesktopSharedStateSnapshot;
|
|
174
|
+
/** A whole-config save from a full window: only what it changed since it last synced counts. */
|
|
175
|
+
replaceConfigFromWindow(windowId: string, config: AppConfig): DesktopSharedStateSnapshot;
|
|
88
176
|
/** A whole-config save from the popped-out window for `paneId`: the open tab's panes count only for that pane. */
|
|
89
177
|
replaceConfigFromDetachedPane(paneId: string, config: AppConfig): DesktopSharedStateSnapshot;
|
|
90
178
|
replaceDetachedPaneState(paneId: string, paneState: PaneRuntimeState): DesktopSharedStateSnapshot;
|
|
@@ -101,11 +189,24 @@ export interface DesktopWorkspace {
|
|
|
101
189
|
edge?: "left" | "right" | "top" | "bottom",
|
|
102
190
|
): DesktopSharedStateSnapshot;
|
|
103
191
|
closeDetachedPane(paneId: string): DesktopSharedStateSnapshot;
|
|
192
|
+
/**
|
|
193
|
+
* Opens a full window on `layoutId` (moved from where it is), or on a new
|
|
194
|
+
* tab, empty or holding `paneId` (moved from where it is). One change: null,
|
|
195
|
+
* and no window, when what it would hold cannot move.
|
|
196
|
+
*/
|
|
197
|
+
openWindow(windowId: string, holding?: { layoutId?: string; paneId?: string }): DesktopSharedStateSnapshot | null;
|
|
198
|
+
/** Closes a full window; its tabs go back to the main window. */
|
|
199
|
+
closeWindow(windowId: string): DesktopSharedStateSnapshot;
|
|
200
|
+
moveLayoutToWindow(layoutId: string, windowId: string): DesktopSharedStateSnapshot | null;
|
|
201
|
+
movePaneToWindow(paneId: string, windowId: string): DesktopSharedStateSnapshot | null;
|
|
202
|
+
/** Shows one of a window's tabs there. */
|
|
203
|
+
activateLayout(windowId: string, layoutId: string): DesktopSharedStateSnapshot;
|
|
104
204
|
}
|
|
105
205
|
|
|
106
206
|
export function createDesktopWorkspace(
|
|
107
207
|
config: AppConfig,
|
|
108
208
|
sessionSnapshot: AppSessionSnapshot | null,
|
|
209
|
+
extraWindowsKept: readonly ExtraWindowRecord[] = [],
|
|
109
210
|
): DesktopWorkspace {
|
|
110
211
|
const savedPaneState = config.layouts[config.activeLayoutIndex]?.paneState ?? {};
|
|
111
212
|
const initialPaneState = filterPaneState(config.layout, clonePaneStateMap({
|
|
@@ -115,142 +216,242 @@ export function createDesktopWorkspace(
|
|
|
115
216
|
const initialFocusedPaneId = config.layouts[config.activeLayoutIndex]?.focusedPaneId
|
|
116
217
|
?? sessionSnapshot?.focusedPaneId
|
|
117
218
|
?? null;
|
|
118
|
-
let
|
|
119
|
-
config: syncConfigActiveLayoutState(config, initialPaneState, initialFocusedPaneId),
|
|
219
|
+
let state = createWindowLayouts(config, {
|
|
120
220
|
paneState: initialPaneState,
|
|
121
221
|
focusedPaneId: initialFocusedPaneId,
|
|
122
222
|
statusBarVisible: sessionSnapshot?.statusBarVisible !== false,
|
|
123
|
-
|
|
223
|
+
}, extraWindowsKept);
|
|
224
|
+
/** The last revision each window sent, which the states it is sent carry. */
|
|
225
|
+
const revisions = new Map<string, number>([[MAIN_WINDOW_ID, 0]]);
|
|
226
|
+
let layoutChanged: boolean | undefined;
|
|
227
|
+
const sent = new Map<string, Map<number, DesktopSharedStateSnapshot>>();
|
|
228
|
+
/** What each window last sent: what its next sync is built on unless it took a newer state since. */
|
|
229
|
+
const received = new Map<string, DesktopSharedStateSnapshot>();
|
|
230
|
+
/**
|
|
231
|
+
* The other windows' tabs as the main window was last told them. A config
|
|
232
|
+
* it saves after a cloud pull carries them; one counts as changed only
|
|
233
|
+
* where it differs from these, so an edit made since in its own window stays.
|
|
234
|
+
*/
|
|
235
|
+
let otherTabsTold: SavedLayout[] = [];
|
|
236
|
+
|
|
237
|
+
const mainView = () => state.views[MAIN_WINDOW_ID]!;
|
|
238
|
+
|
|
239
|
+
const getSnapshot = (): DesktopSharedStateSnapshot => cloneSnapshot({
|
|
240
|
+
config: state.config,
|
|
241
|
+
paneState: mainView().paneState,
|
|
242
|
+
focusedPaneId: mainView().focusedPaneId,
|
|
243
|
+
statusBarVisible: mainView().statusBarVisible,
|
|
244
|
+
brokerSyncErrors: state.brokerSyncErrors,
|
|
245
|
+
mainStateRevision: revisions.get(MAIN_WINDOW_ID) ?? 0,
|
|
246
|
+
layoutChanged,
|
|
247
|
+
});
|
|
248
|
+
|
|
249
|
+
const peekWindowSnapshot = (windowId: string): DesktopSharedStateSnapshot | null => {
|
|
250
|
+
const shown = state.views[windowId] ? windowId : MAIN_WINDOW_ID;
|
|
251
|
+
const projection = projectWindow(state, shown);
|
|
252
|
+
return projection && { ...projection, mainStateRevision: revisions.get(shown) ?? 0, layoutChanged };
|
|
253
|
+
};
|
|
254
|
+
|
|
255
|
+
const getWindowSnapshot = (windowId: string): DesktopSharedStateSnapshot | null => {
|
|
256
|
+
const projection = peekWindowSnapshot(windowId);
|
|
257
|
+
return projection && cloneSnapshot(projection);
|
|
124
258
|
};
|
|
125
259
|
|
|
260
|
+
/** Takes a whole config the backend built from the shared state, keeping the main window's pane state. */
|
|
126
261
|
const updateConfig = (nextConfig: AppConfig, options?: { layoutChanged?: boolean }) => {
|
|
127
|
-
const
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
config: {
|
|
135
|
-
...syncedConfig,
|
|
136
|
-
layout: cloneLayout(syncedConfig.layout),
|
|
137
|
-
layouts: cloneSavedLayouts(syncedConfig),
|
|
262
|
+
const view = mainView();
|
|
263
|
+
state = replaceSharedConfig(state, nextConfig, view);
|
|
264
|
+
state = {
|
|
265
|
+
...state,
|
|
266
|
+
views: {
|
|
267
|
+
...state.views,
|
|
268
|
+
[MAIN_WINDOW_ID]: { ...mainView(), paneState: filterPaneState(state.config.layout, mainView().paneState) },
|
|
138
269
|
},
|
|
139
|
-
paneState: filterPaneState(syncedConfig.layout, sharedState.paneState),
|
|
140
|
-
layoutChanged: options?.layoutChanged,
|
|
141
270
|
};
|
|
271
|
+
layoutChanged = options?.layoutChanged;
|
|
142
272
|
return getSnapshot();
|
|
143
273
|
};
|
|
144
274
|
|
|
145
|
-
const
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
275
|
+
const baseFor = (windowId: string, baseSeq: number | null | undefined): DesktopSharedStateSnapshot | null => {
|
|
276
|
+
if (typeof baseSeq === "number") return sent.get(windowId)?.get(baseSeq) ?? null;
|
|
277
|
+
return received.get(windowId) ?? null;
|
|
278
|
+
};
|
|
279
|
+
|
|
280
|
+
const syncWindowState = (
|
|
281
|
+
windowId: string,
|
|
282
|
+
snapshot: DesktopSharedStateSnapshot,
|
|
283
|
+
baseSeq?: number | null,
|
|
284
|
+
): DesktopSharedStateSnapshot => {
|
|
285
|
+
const currentRevision = revisions.get(windowId) ?? 0;
|
|
286
|
+
if (typeof snapshot.mainStateRevision === "number" && snapshot.mainStateRevision <= currentRevision) {
|
|
287
|
+
return getSnapshot();
|
|
288
|
+
}
|
|
289
|
+
if (!state.views[windowId]) return getSnapshot();
|
|
290
|
+
const base = baseFor(windowId, baseSeq);
|
|
291
|
+
const detachedBefore = state.config.layout;
|
|
292
|
+
state = mergeWindowSnapshot(state, windowId, base, snapshot);
|
|
293
|
+
if (windowId === MAIN_WINDOW_ID) state = keepMainDetachedFrames(state, detachedBefore);
|
|
294
|
+
revisions.set(windowId, snapshot.mainStateRevision ?? currentRevision);
|
|
295
|
+
received.set(windowId, snapshot);
|
|
296
|
+
// The states it was sent before the one it built on will not be built on again.
|
|
297
|
+
const history = sent.get(windowId);
|
|
298
|
+
if (history && typeof baseSeq === "number") {
|
|
299
|
+
for (const seq of history.keys()) if (seq < baseSeq) history.delete(seq);
|
|
300
|
+
}
|
|
301
|
+
layoutChanged = snapshot.layoutChanged;
|
|
302
|
+
return getSnapshot();
|
|
303
|
+
};
|
|
158
304
|
|
|
159
305
|
return {
|
|
160
306
|
getSnapshot,
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
307
|
+
getWindowSnapshot,
|
|
308
|
+
peekWindowSnapshot,
|
|
309
|
+
windowIds: () => [...state.windowIds],
|
|
310
|
+
extraWindows: () => extraWindowRecords(state),
|
|
311
|
+
locatePane: (paneId) => locatePane(state, paneId),
|
|
312
|
+
windowOfLayout: (layoutId) => windowOfLayout(state, layoutId),
|
|
313
|
+
otherWindowTabs() {
|
|
314
|
+
const tabs = otherWindowTabs(state);
|
|
315
|
+
otherTabsTold = tabs.map(({ tab }) => tab);
|
|
316
|
+
return tabs;
|
|
317
|
+
},
|
|
318
|
+
windowTabNames(windowId) {
|
|
319
|
+
const view = state.views[windowId];
|
|
320
|
+
if (!view) return null;
|
|
321
|
+
const tabs = windowTabs(state, windowId);
|
|
322
|
+
return { active: tabs.find((tab) => tab.id === view.activeLayoutId)?.name ?? "", count: tabs.length };
|
|
323
|
+
},
|
|
324
|
+
noteDelivered(windowId, seq, snapshot) {
|
|
325
|
+
let history = sent.get(windowId);
|
|
326
|
+
if (!history) {
|
|
327
|
+
history = new Map();
|
|
328
|
+
sent.set(windowId, history);
|
|
168
329
|
}
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
);
|
|
174
|
-
|
|
175
|
-
config: {
|
|
176
|
-
...syncedConfig,
|
|
177
|
-
layout: cloneLayout(syncedConfig.layout),
|
|
178
|
-
layouts: cloneSavedLayouts(syncedConfig),
|
|
179
|
-
},
|
|
180
|
-
paneState: filterPaneState(syncedConfig.layout, clonePaneStateMap(snapshot.paneState)),
|
|
181
|
-
focusedPaneId: snapshot.focusedPaneId,
|
|
182
|
-
statusBarVisible: snapshot.statusBarVisible,
|
|
183
|
-
brokerSyncErrors: { ...snapshot.brokerSyncErrors },
|
|
184
|
-
mainStateRevision: snapshot.mainStateRevision ?? currentRevision,
|
|
185
|
-
layoutChanged: snapshot.layoutChanged,
|
|
186
|
-
};
|
|
187
|
-
return getSnapshot();
|
|
330
|
+
history.set(seq, snapshot);
|
|
331
|
+
while (history.size > SENT_HISTORY) history.delete(history.keys().next().value!);
|
|
332
|
+
},
|
|
333
|
+
forgetWindow(windowId) {
|
|
334
|
+
sent.delete(windowId);
|
|
335
|
+
received.delete(windowId);
|
|
188
336
|
},
|
|
189
|
-
|
|
190
|
-
|
|
337
|
+
syncMainState: (snapshot, baseSeq) => syncWindowState(MAIN_WINDOW_ID, snapshot, baseSeq),
|
|
338
|
+
syncWindowState,
|
|
339
|
+
replaceConfig(nextConfig: AppConfig, options) {
|
|
340
|
+
return updateConfig({ ...nextConfig, layout: keepDetachedFrames(nextConfig.layout, state.config.layout) }, options);
|
|
191
341
|
},
|
|
192
|
-
|
|
193
|
-
const
|
|
342
|
+
replaceConfigFromWindow(windowId, nextConfig) {
|
|
343
|
+
const view = state.views[windowId];
|
|
344
|
+
if (!view) return getSnapshot();
|
|
345
|
+
let base = received.get(windowId) ?? null;
|
|
346
|
+
if (windowId === MAIN_WINDOW_ID && otherTabsTold.length > 0) {
|
|
347
|
+
const own = base ?? projectWindow(state, MAIN_WINDOW_ID)!;
|
|
348
|
+
base = { ...own, config: { ...own.config, layouts: [...own.config.layouts, ...otherTabsTold] } };
|
|
349
|
+
}
|
|
350
|
+
const detachedBefore = state.config.layout;
|
|
351
|
+
state = mergeWindowSnapshot(state, windowId, base, {
|
|
352
|
+
config: nextConfig,
|
|
353
|
+
paneState: base?.paneState ?? view.paneState,
|
|
354
|
+
focusedPaneId: base?.focusedPaneId ?? view.focusedPaneId,
|
|
355
|
+
statusBarVisible: base?.statusBarVisible ?? view.statusBarVisible,
|
|
356
|
+
brokerSyncErrors: base?.brokerSyncErrors ?? state.brokerSyncErrors,
|
|
357
|
+
});
|
|
358
|
+
if (windowId === MAIN_WINDOW_ID) state = keepMainDetachedFrames(state, detachedBefore);
|
|
359
|
+
layoutChanged = true;
|
|
360
|
+
return getSnapshot();
|
|
361
|
+
},
|
|
362
|
+
replaceConfigFromDetachedPane(paneId, nextConfig) {
|
|
363
|
+
const current = projectWindow(state, MAIN_WINDOW_ID)!;
|
|
194
364
|
// The Layouts pane can be popped out, so a save can carry a renamed,
|
|
195
365
|
// added or reordered tab, or a switch: the tab list and the active tab
|
|
196
366
|
// come from the save. The panes of the tab both windows are on do not.
|
|
197
|
-
const
|
|
198
|
-
const shown = current.layouts[current.activeLayoutIndex];
|
|
199
|
-
const sameTab = !!
|
|
200
|
-
?
|
|
201
|
-
:
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
367
|
+
const sentTab = nextConfig.layouts[nextConfig.activeLayoutIndex];
|
|
368
|
+
const shown = current.config.layouts[current.config.activeLayoutIndex];
|
|
369
|
+
const sameTab = !!sentTab && !!shown && (sentTab.id && shown.id
|
|
370
|
+
? sentTab.id === shown.id
|
|
371
|
+
: sentTab.name === shown.name || nextConfig.activeLayoutIndex === current.config.activeLayoutIndex);
|
|
372
|
+
const layout = sameTab
|
|
373
|
+
? takeOwnPaneInstance(current.config.layout, nextConfig.layout, paneId)
|
|
374
|
+
: nextConfig.layout;
|
|
375
|
+
const detachedBefore = state.config.layout;
|
|
376
|
+
state = mergeWindowSnapshot(state, MAIN_WINDOW_ID, current, {
|
|
377
|
+
...current,
|
|
378
|
+
config: { ...nextConfig, layout },
|
|
379
|
+
paneState: sameTab ? current.paneState : nextConfig.layouts[nextConfig.activeLayoutIndex]?.paneState ?? {},
|
|
380
|
+
});
|
|
381
|
+
state = keepMainDetachedFrames(state, detachedBefore);
|
|
382
|
+
layoutChanged = true;
|
|
383
|
+
return getSnapshot();
|
|
206
384
|
},
|
|
207
385
|
replaceDetachedPaneState(paneId, paneState) {
|
|
208
|
-
const
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
});
|
|
212
|
-
sharedState = {
|
|
213
|
-
...sharedState,
|
|
214
|
-
config: syncConfigActiveLayoutState(
|
|
215
|
-
sharedState.config,
|
|
216
|
-
nextPaneState,
|
|
217
|
-
sharedState.focusedPaneId,
|
|
218
|
-
),
|
|
219
|
-
paneState: nextPaneState,
|
|
220
|
-
};
|
|
386
|
+
const view = mainView();
|
|
387
|
+
const nextPaneState = filterPaneState(state.config.layout, { ...view.paneState, [paneId]: { ...paneState } });
|
|
388
|
+
state = replaceSharedConfig(state, state.config, { ...view, paneState: nextPaneState });
|
|
221
389
|
return getSnapshot();
|
|
222
390
|
},
|
|
223
391
|
updateDetachedFrame(paneId, frame) {
|
|
224
392
|
return updateConfig({
|
|
225
|
-
...
|
|
226
|
-
layout: setDetachedFrame(
|
|
393
|
+
...state.config,
|
|
394
|
+
layout: setDetachedFrame(state.config.layout, paneId, frame),
|
|
227
395
|
}, { layoutChanged: true });
|
|
228
396
|
},
|
|
229
397
|
popOutPane(paneId, frame) {
|
|
230
398
|
return updateConfig({
|
|
231
|
-
...
|
|
232
|
-
layout: detachPaneToFrame(
|
|
399
|
+
...state.config,
|
|
400
|
+
layout: detachPaneToFrame(state.config.layout, paneId, frame),
|
|
233
401
|
}, { layoutChanged: true });
|
|
234
402
|
},
|
|
235
403
|
dockDetachedPane(paneId, edge) {
|
|
236
404
|
// Only an edge drop passes an edge. That frame is in the dock zone, where
|
|
237
405
|
// a re-opened window would dock again, so it keeps the one it had.
|
|
238
|
-
const layout = edge ?
|
|
406
|
+
const layout = edge ? state.config.layout : rememberDetachedFrame(state.config.layout, paneId);
|
|
239
407
|
return updateConfig({
|
|
240
|
-
...
|
|
408
|
+
...state.config,
|
|
241
409
|
layout: edge ? insertAtRootEdge(layout, paneId, edge) : dockPane(layout, paneId),
|
|
242
410
|
}, { layoutChanged: true });
|
|
243
411
|
},
|
|
244
412
|
closeDetachedPane(paneId) {
|
|
245
|
-
const nextLayout = removePane(
|
|
246
|
-
sharedState = {
|
|
247
|
-
...sharedState,
|
|
248
|
-
paneState: filterPaneState(nextLayout, sharedState.paneState),
|
|
249
|
-
};
|
|
413
|
+
const nextLayout = removePane(state.config.layout, paneId);
|
|
250
414
|
return updateConfig({
|
|
251
|
-
...
|
|
415
|
+
...state.config,
|
|
252
416
|
layout: nextLayout,
|
|
253
417
|
}, { layoutChanged: true });
|
|
254
418
|
},
|
|
419
|
+
openWindow(windowId, { layoutId, paneId } = {}) {
|
|
420
|
+
if (layoutId && layoutMoveBlock(state, layoutId, MAIN_WINDOW_ID) === "missing") return null;
|
|
421
|
+
if (paneId && !locatePane(state, paneId)) return null;
|
|
422
|
+
let next = addWindow(state, windowId, layoutId ? { layoutId } : {});
|
|
423
|
+
if (next === state || !next.views[windowId]) return null;
|
|
424
|
+
if (paneId) {
|
|
425
|
+
if (paneMoveBlock(next, paneId, windowId)) return null;
|
|
426
|
+
next = movePaneToWindow(next, paneId, windowId);
|
|
427
|
+
}
|
|
428
|
+
state = next;
|
|
429
|
+
layoutChanged = true;
|
|
430
|
+
return getSnapshot();
|
|
431
|
+
},
|
|
432
|
+
closeWindow(windowId) {
|
|
433
|
+
state = closeWindow(state, windowId);
|
|
434
|
+
sent.delete(windowId);
|
|
435
|
+
received.delete(windowId);
|
|
436
|
+
revisions.delete(windowId);
|
|
437
|
+
layoutChanged = true;
|
|
438
|
+
return getSnapshot();
|
|
439
|
+
},
|
|
440
|
+
moveLayoutToWindow(layoutId, windowId) {
|
|
441
|
+
if (layoutMoveBlock(state, layoutId, windowId)) return null;
|
|
442
|
+
state = moveLayoutToWindow(state, layoutId, windowId);
|
|
443
|
+
layoutChanged = true;
|
|
444
|
+
return getSnapshot();
|
|
445
|
+
},
|
|
446
|
+
movePaneToWindow(paneId, windowId) {
|
|
447
|
+
if (paneMoveBlock(state, paneId, windowId)) return null;
|
|
448
|
+
state = movePaneToWindow(state, paneId, windowId);
|
|
449
|
+
layoutChanged = true;
|
|
450
|
+
return getSnapshot();
|
|
451
|
+
},
|
|
452
|
+
activateLayout(windowId, layoutId) {
|
|
453
|
+
state = activateLayout(state, windowId, layoutId);
|
|
454
|
+
return getSnapshot();
|
|
455
|
+
},
|
|
255
456
|
};
|
|
256
457
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { DesktopWorkspaceRequest } from "../../../shared/protocol";
|
|
2
|
+
import { MAIN_WINDOW_RPC_KEY } from "../../window/focus";
|
|
2
3
|
import type { DesktopBackend, DesktopRpc } from "../backend";
|
|
3
4
|
|
|
4
5
|
type DockEdge = "left" | "right" | "top" | "bottom";
|
|
@@ -20,22 +21,26 @@ export async function handleDesktopWorkspaceRequest(
|
|
|
20
21
|
backend: DesktopBackend,
|
|
21
22
|
rpc: DesktopRpc,
|
|
22
23
|
request: DesktopWorkspaceRequest,
|
|
23
|
-
): Promise<null> {
|
|
24
|
+
): Promise<null | boolean> {
|
|
24
25
|
const workspace = backend.requireWorkspace();
|
|
25
26
|
const { detachedWindows, stateBroadcaster } = backend;
|
|
26
27
|
switch (request.method) {
|
|
27
28
|
case "desktop.syncMainState": {
|
|
28
|
-
|
|
29
|
+
// Any full window sends its whole state; a popped-out pane's never does.
|
|
30
|
+
const windowId = backend.fullWindowKey(rpc);
|
|
31
|
+
if (!windowId) return null;
|
|
32
|
+
const snapshot = workspace.syncWindowState(windowId, request.payload.snapshot, request.payload.baseSeq);
|
|
29
33
|
backend.setConfig(snapshot.config);
|
|
30
|
-
|
|
31
|
-
// The
|
|
32
|
-
//
|
|
34
|
+
backend.reconcileWindows();
|
|
35
|
+
// The window holds what it sent. It gets the state back only when this
|
|
36
|
+
// process changed it: another window's edit, a popped-out window's
|
|
37
|
+
// frame, a stale revision.
|
|
33
38
|
stateBroadcaster.noteWindowState(rpc, request.payload.snapshot);
|
|
34
39
|
stateBroadcaster.sendDesktopState(snapshot);
|
|
35
40
|
return null;
|
|
36
41
|
}
|
|
37
42
|
case "desktop.setThemePreview":
|
|
38
|
-
stateBroadcaster.sendThemePreview(request.payload.preview ?? { theme: null });
|
|
43
|
+
stateBroadcaster.sendThemePreview(request.payload.preview ?? { theme: null }, rpc);
|
|
39
44
|
return null;
|
|
40
45
|
case "desktop.replaceDetachedPaneState": {
|
|
41
46
|
const paneId = requirePaneId(request.payload, request.method);
|
|
@@ -44,6 +49,8 @@ export async function handleDesktopWorkspaceRequest(
|
|
|
44
49
|
}
|
|
45
50
|
case "desktop.popOutPane": {
|
|
46
51
|
const paneId = requirePaneId(request.payload, request.method);
|
|
52
|
+
// Popped-out panes belong to the main window's tab; elsewhere a pane moves to a window instead.
|
|
53
|
+
if (backend.fullWindowKey(rpc) !== MAIN_WINDOW_RPC_KEY) return null;
|
|
47
54
|
const snapshot = workspace.popOutPane(paneId, detachedWindows.resolveFrame(paneId));
|
|
48
55
|
await backend.commitDesktopSnapshot(snapshot);
|
|
49
56
|
detachedWindows.focusDetachedPane(paneId);
|
|
@@ -66,6 +73,37 @@ export async function handleDesktopWorkspaceRequest(
|
|
|
66
73
|
detachedWindows.focusDetachedPane(paneId);
|
|
67
74
|
return null;
|
|
68
75
|
}
|
|
76
|
+
case "desktop.openWindow":
|
|
77
|
+
await backend.openExtraWindow();
|
|
78
|
+
return null;
|
|
79
|
+
case "desktop.moveLayoutToWindow": {
|
|
80
|
+
const { layoutId, windowId } = request.payload;
|
|
81
|
+
if (typeof layoutId !== "string") throw new Error(`${request.method} requires layoutId.`);
|
|
82
|
+
if (windowId === null) return (await backend.openExtraWindow({ layoutId })) !== null;
|
|
83
|
+
const snapshot = workspace.moveLayoutToWindow(layoutId, windowId);
|
|
84
|
+
if (!snapshot) return false;
|
|
85
|
+
await backend.commitDesktopSnapshot(snapshot);
|
|
86
|
+
backend.windowController?.focus(windowId);
|
|
87
|
+
return true;
|
|
88
|
+
}
|
|
89
|
+
case "desktop.movePaneToWindow": {
|
|
90
|
+
const paneId = requirePaneId(request.payload, request.method);
|
|
91
|
+
const target = request.payload.windowId;
|
|
92
|
+
// A new window opens holding the pane, or not at all.
|
|
93
|
+
if (target == null) return (await backend.openExtraWindow({ paneId })) !== null;
|
|
94
|
+
const snapshot = workspace.movePaneToWindow(paneId, target);
|
|
95
|
+
if (!snapshot) return false;
|
|
96
|
+
await backend.commitDesktopSnapshot(snapshot);
|
|
97
|
+
backend.windowController?.focus(target);
|
|
98
|
+
return true;
|
|
99
|
+
}
|
|
100
|
+
case "desktop.focusWindow":
|
|
101
|
+
backend.windowController?.focus(String(request.payload.windowId));
|
|
102
|
+
return null;
|
|
103
|
+
case "desktop.focusPane": {
|
|
104
|
+
const paneId = requirePaneId(request.payload, request.method);
|
|
105
|
+
return backend.focusPaneAnywhere(paneId);
|
|
106
|
+
}
|
|
69
107
|
default: {
|
|
70
108
|
const exhaustive: never = request;
|
|
71
109
|
throw new Error(`Unknown desktop method: ${String(exhaustive)}`);
|