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
|
@@ -26,7 +26,7 @@ import { hideDragShield, showDragShield } from "./drag-shield";
|
|
|
26
26
|
import { applyLiveFrame } from "./live-frame";
|
|
27
27
|
import { observeCellSize } from "./size-observer";
|
|
28
28
|
import { fitSurface, surfaceFollows, trackSurface } from "./surface-fit";
|
|
29
|
-
import { cleanDomProps, commonStyle } from "./style";
|
|
29
|
+
import { cleanDomProps, commonStyle, useStableStyle } from "./style";
|
|
30
30
|
|
|
31
31
|
/** Farther than this from the pointer, in px, a predicted point is noise. */
|
|
32
32
|
const MAX_PREDICTION_PX = 48;
|
|
@@ -74,6 +74,17 @@ function releasePointer(captured: { element: HTMLElement; pointerId: number } |
|
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
+
interface BoxHandlers {
|
|
78
|
+
cancelPendingFrame(): void;
|
|
79
|
+
handleMouseDown(event: MouseEvent): void;
|
|
80
|
+
handlePointerDown(event: PointerEvent): void;
|
|
81
|
+
handleMouseDownCapture(event: MouseEvent): void;
|
|
82
|
+
handleMouseOver(event: MouseEvent): void;
|
|
83
|
+
handleMouseOut(event: MouseEvent): void;
|
|
84
|
+
handleMouseMove(event: MouseEvent): void;
|
|
85
|
+
handleMouseUp(event: MouseEvent): void;
|
|
86
|
+
}
|
|
87
|
+
|
|
77
88
|
export const WebBox = forwardRef<HTMLDivElement, Record<string, unknown> & { children?: ReactNode }>(
|
|
78
89
|
function WebBox({ children, ...props }, ref: Ref<HTMLDivElement>) {
|
|
79
90
|
const elementRef = useRef<HTMLDivElement | null>(null);
|
|
@@ -101,62 +112,6 @@ export const WebBox = forwardRef<HTMLDivElement, Record<string, unknown> & { chi
|
|
|
101
112
|
return handle as unknown as HTMLDivElement;
|
|
102
113
|
}, []);
|
|
103
114
|
|
|
104
|
-
const cancelPendingFrame = () => {
|
|
105
|
-
if (frameRef.current !== null) {
|
|
106
|
-
cancelWebFrame(frameRef.current);
|
|
107
|
-
frameRef.current = null;
|
|
108
|
-
}
|
|
109
|
-
};
|
|
110
|
-
|
|
111
|
-
const flushPendingFrameMouseHandlers = () => {
|
|
112
|
-
const moveEvent = pendingMoveRef.current;
|
|
113
|
-
const dragEvent = pendingDragRef.current;
|
|
114
|
-
pendingMoveRef.current = null;
|
|
115
|
-
pendingDragRef.current = null;
|
|
116
|
-
|
|
117
|
-
if (moveEvent) {
|
|
118
|
-
callCellMouseHandler(propsRef.current.onMouseMove, moveEvent);
|
|
119
|
-
}
|
|
120
|
-
if (dragEvent) {
|
|
121
|
-
callCellMouseHandler(propsRef.current.onMouse, dragEvent);
|
|
122
|
-
callCellMouseHandler(propsRef.current.onMouseDrag, dragEvent);
|
|
123
|
-
}
|
|
124
|
-
};
|
|
125
|
-
|
|
126
|
-
const flushPendingFrameNow = () => {
|
|
127
|
-
cancelPendingFrame();
|
|
128
|
-
flushPendingFrameMouseHandlers();
|
|
129
|
-
};
|
|
130
|
-
|
|
131
|
-
const scheduleFrameMouseHandler = (
|
|
132
|
-
event: MouseLikeEvent,
|
|
133
|
-
type: "move" | "drag",
|
|
134
|
-
ahead: { clientX: number; clientY: number } | null = null,
|
|
135
|
-
) => {
|
|
136
|
-
// The DOM keeps firing mousemove while a button is held. A move means no
|
|
137
|
-
// button anywhere else in the app, so drags must not surface as moves.
|
|
138
|
-
if (type === "move" && draggingRef.current) return;
|
|
139
|
-
if (type === "move" && typeof propsRef.current.onMouseMove !== "function") return;
|
|
140
|
-
if (type === "drag"
|
|
141
|
-
&& typeof propsRef.current.onMouse !== "function"
|
|
142
|
-
&& typeof propsRef.current.onMouseDrag !== "function") {
|
|
143
|
-
return;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
const nextEvent = cellMouseEvent(event, type, ahead);
|
|
147
|
-
if (type === "move") {
|
|
148
|
-
pendingMoveRef.current = nextEvent;
|
|
149
|
-
} else {
|
|
150
|
-
pendingDragRef.current = nextEvent;
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
if (frameRef.current !== null) return;
|
|
154
|
-
frameRef.current = requestWebFrame(() => {
|
|
155
|
-
frameRef.current = null;
|
|
156
|
-
flushPendingFrameMouseHandlers();
|
|
157
|
-
});
|
|
158
|
-
};
|
|
159
|
-
|
|
160
115
|
const lastPointRef = useRef({ x: 0, y: 0 });
|
|
161
116
|
// The pointer that pressed this box, so a drag can capture it.
|
|
162
117
|
const pressedPointerRef = useRef<number | null>(null);
|
|
@@ -176,38 +131,186 @@ export const WebBox = forwardRef<HTMLDivElement, Record<string, unknown> & { chi
|
|
|
176
131
|
* took the pointer), so a move can put things back.
|
|
177
132
|
*/
|
|
178
133
|
const endDocumentDragRef = useRef<(event: globalThis.MouseEvent | null, outcome: "end" | "cancel") => void>(() => {});
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
134
|
+
const handlersRef = useRef<BoxHandlers | null>(null);
|
|
135
|
+
// Created once: they read the latest props through propsRef, so a re-render
|
|
136
|
+
// hands React the same listeners instead of a dozen new closures.
|
|
137
|
+
const handlers = handlersRef.current ??= (() => {
|
|
138
|
+
const cancelPendingFrame = () => {
|
|
139
|
+
if (frameRef.current !== null) {
|
|
140
|
+
cancelWebFrame(frameRef.current);
|
|
141
|
+
frameRef.current = null;
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
const flushPendingFrameMouseHandlers = () => {
|
|
146
|
+
const moveEvent = pendingMoveRef.current;
|
|
147
|
+
const dragEvent = pendingDragRef.current;
|
|
148
|
+
pendingMoveRef.current = null;
|
|
149
|
+
pendingDragRef.current = null;
|
|
150
|
+
|
|
151
|
+
if (moveEvent) {
|
|
152
|
+
callCellMouseHandler(propsRef.current.onMouseMove, moveEvent);
|
|
153
|
+
}
|
|
154
|
+
if (dragEvent) {
|
|
155
|
+
callCellMouseHandler(propsRef.current.onMouse, dragEvent);
|
|
156
|
+
callCellMouseHandler(propsRef.current.onMouseDrag, dragEvent);
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
const flushPendingFrameNow = () => {
|
|
161
|
+
cancelPendingFrame();
|
|
162
|
+
flushPendingFrameMouseHandlers();
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
const scheduleFrameMouseHandler = (
|
|
166
|
+
event: MouseLikeEvent,
|
|
167
|
+
type: "move" | "drag",
|
|
168
|
+
ahead: { clientX: number; clientY: number } | null = null,
|
|
169
|
+
) => {
|
|
170
|
+
// The DOM keeps firing mousemove while a button is held. A move means no
|
|
171
|
+
// button anywhere else in the app, so drags must not surface as moves.
|
|
172
|
+
if (type === "move" && draggingRef.current) return;
|
|
173
|
+
if (type === "move" && typeof propsRef.current.onMouseMove !== "function") return;
|
|
174
|
+
if (type === "drag"
|
|
175
|
+
&& typeof propsRef.current.onMouse !== "function"
|
|
176
|
+
&& typeof propsRef.current.onMouseDrag !== "function") {
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
const nextEvent = cellMouseEvent(event, type, ahead);
|
|
181
|
+
if (type === "move") {
|
|
182
|
+
pendingMoveRef.current = nextEvent;
|
|
183
|
+
} else {
|
|
184
|
+
pendingDragRef.current = nextEvent;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
if (frameRef.current !== null) return;
|
|
188
|
+
frameRef.current = requestWebFrame(() => {
|
|
189
|
+
frameRef.current = null;
|
|
190
|
+
flushPendingFrameMouseHandlers();
|
|
191
|
+
});
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
endDocumentDragRef.current = (event, outcome) => {
|
|
195
|
+
const session = dragSessionRef.current;
|
|
196
|
+
const wasDragging = draggingRef.current;
|
|
197
|
+
if (!session && !wasDragging) return;
|
|
198
|
+
draggingRef.current = false;
|
|
199
|
+
const shielded = session?.shielded === true;
|
|
200
|
+
dragSessionRef.current = null;
|
|
201
|
+
if (shielded) hideDragShield();
|
|
202
|
+
if (session) {
|
|
203
|
+
document.removeEventListener("pointermove", session.move);
|
|
204
|
+
document.removeEventListener("mousemove", session.move);
|
|
205
|
+
document.removeEventListener("mouseup", session.up);
|
|
206
|
+
document.removeEventListener("pointerup", session.up);
|
|
207
|
+
document.removeEventListener("pointercancel", session.cancel);
|
|
208
|
+
window.removeEventListener("blur", session.cancel);
|
|
209
|
+
releasePointer(session.captured);
|
|
210
|
+
}
|
|
211
|
+
if (!wasDragging) return;
|
|
212
|
+
const point = event ?? new MouseEvent("mouseup", {
|
|
213
|
+
clientX: lastPointRef.current.x,
|
|
214
|
+
clientY: lastPointRef.current.y,
|
|
215
|
+
button: 0,
|
|
216
|
+
bubbles: true,
|
|
217
|
+
});
|
|
218
|
+
flushPendingFrameNow();
|
|
219
|
+
callMouseHandler(propsRef.current.onMouse, point, "up");
|
|
220
|
+
callMouseHandler(propsRef.current.onMouseUp, point, "up");
|
|
221
|
+
callMouseHandler(propsRef.current.onMouseDragEnd, point, outcome === "cancel" ? "drag-cancel" : "drag-end");
|
|
222
|
+
};
|
|
223
|
+
|
|
224
|
+
const handleMouseDown = (event: MouseEvent) => {
|
|
225
|
+
const hasSyntheticDrag = typeof propsRef.current.onMouse === "function";
|
|
226
|
+
const hasDirectDrag = typeof propsRef.current.onMouseDrag === "function" || typeof propsRef.current.onMouseDragEnd === "function";
|
|
227
|
+
pendingMoveRef.current = null;
|
|
228
|
+
// A press that never saw mouseup (the window move took the pointer) is still tracked.
|
|
229
|
+
// Finish it before the new press, so its drag-end cannot clear the drag this press starts.
|
|
230
|
+
endDocumentDragRef.current(null, "end");
|
|
231
|
+
callMouseHandler(propsRef.current.onMouseDown, event, "down");
|
|
232
|
+
if (event.button !== 0 || (event.isPropagationStopped() && !hasDirectDrag)) return;
|
|
233
|
+
if (!hasSyntheticDrag && !hasDirectDrag) return;
|
|
234
|
+
callMouseHandler(propsRef.current.onMouse, event, "down");
|
|
235
|
+
draggingRef.current = true;
|
|
236
|
+
lastPointRef.current = { x: event.clientX, y: event.clientY };
|
|
237
|
+
const originX = event.clientX;
|
|
238
|
+
const originY = event.clientY;
|
|
239
|
+
const move = (moveEvent: globalThis.MouseEvent) => {
|
|
240
|
+
if (!draggingRef.current) return;
|
|
241
|
+
const current = dragSessionRef.current;
|
|
242
|
+
if (isPointerMove(moveEvent)) {
|
|
243
|
+
if (current) current.pointerMoves = true;
|
|
244
|
+
} else if (current?.pointerMoves) {
|
|
245
|
+
return;
|
|
246
|
+
}
|
|
247
|
+
lastPointRef.current = { x: moveEvent.clientX, y: moveEvent.clientY };
|
|
248
|
+
// The button is up and mouseup never arrived. End the drag instead of following the cursor.
|
|
249
|
+
if (moveEvent.buttons === 0) {
|
|
250
|
+
endDocumentDragRef.current(moveEvent, "end");
|
|
251
|
+
return;
|
|
252
|
+
}
|
|
253
|
+
const dx = moveEvent.clientX - originX;
|
|
254
|
+
const dy = moveEvent.clientY - originY;
|
|
255
|
+
if (current && !current.shielded) {
|
|
256
|
+
if (dx * dx + dy * dy < 9) return;
|
|
257
|
+
current.shielded = true;
|
|
258
|
+
showDragShield(elementRef.current);
|
|
259
|
+
// Captured once it is a drag (a click keeps its usual target), the
|
|
260
|
+
// moves skip hit testing and leave every other element's hover state
|
|
261
|
+
// alone: nothing under the pointer restyles or repaints while a pane,
|
|
262
|
+
// divider or chart is dragged across it. The document listeners still
|
|
263
|
+
// see every move.
|
|
264
|
+
if (!current.captured) current.captured = capturePointer(elementRef.current, pressedPointerRef.current);
|
|
265
|
+
}
|
|
266
|
+
scheduleFrameMouseHandler(moveEvent, "drag", predictedPoint(moveEvent));
|
|
267
|
+
};
|
|
268
|
+
const up = (upEvent: globalThis.MouseEvent) => {
|
|
269
|
+
endDocumentDragRef.current(upEvent, "end");
|
|
270
|
+
};
|
|
271
|
+
const cancel = () => {
|
|
272
|
+
endDocumentDragRef.current(null, "cancel");
|
|
273
|
+
};
|
|
274
|
+
dragSessionRef.current = { move, up, cancel, captured: null, pointerMoves: false, shielded: false };
|
|
275
|
+
document.addEventListener("pointermove", move);
|
|
276
|
+
document.addEventListener("mousemove", move);
|
|
277
|
+
document.addEventListener("mouseup", up);
|
|
278
|
+
document.addEventListener("pointerup", up);
|
|
279
|
+
document.addEventListener("pointercancel", cancel);
|
|
280
|
+
window.addEventListener("blur", cancel);
|
|
281
|
+
};
|
|
282
|
+
|
|
283
|
+
const handlePointerDown = (event: PointerEvent) => {
|
|
284
|
+
pressedPointerRef.current = event.pointerId;
|
|
285
|
+
};
|
|
286
|
+
|
|
287
|
+
const handleMouseDownCapture = (event: MouseEvent) => {
|
|
288
|
+
callMouseHandler(propsRef.current.onMouseDownCapture, event, "down");
|
|
289
|
+
};
|
|
290
|
+
|
|
291
|
+
const handleMouseOver = (event: MouseEvent) => {
|
|
292
|
+
callMouseHandler(propsRef.current.onMouseOver, event, "over");
|
|
293
|
+
};
|
|
294
|
+
|
|
295
|
+
const handleMouseOut = (event: MouseEvent) => {
|
|
296
|
+
pendingMoveRef.current = null;
|
|
297
|
+
callMouseHandler(propsRef.current.onMouseOut, event, "out");
|
|
298
|
+
};
|
|
299
|
+
|
|
300
|
+
return {
|
|
301
|
+
cancelPendingFrame,
|
|
302
|
+
handleMouseDown,
|
|
303
|
+
handlePointerDown,
|
|
304
|
+
handleMouseDownCapture,
|
|
305
|
+
handleMouseOver,
|
|
306
|
+
handleMouseOut,
|
|
307
|
+
handleMouseMove: (event: MouseEvent) => scheduleFrameMouseHandler(event, "move"),
|
|
308
|
+
handleMouseUp: (event: MouseEvent) => callMouseHandler(propsRef.current.onMouseUp, event, "up"),
|
|
309
|
+
};
|
|
310
|
+
})();
|
|
208
311
|
|
|
209
312
|
useEffect(() => () => {
|
|
210
|
-
cancelPendingFrame();
|
|
313
|
+
handlers.cancelPendingFrame();
|
|
211
314
|
pendingMoveRef.current = null;
|
|
212
315
|
pendingDragRef.current = null;
|
|
213
316
|
endDocumentDragRef.current(null, "end");
|
|
@@ -263,103 +366,28 @@ export const WebBox = forwardRef<HTMLDivElement, Record<string, unknown> & { chi
|
|
|
263
366
|
};
|
|
264
367
|
}, [handlesWheel, pinchAsWheel]);
|
|
265
368
|
|
|
266
|
-
const handleMouseDown = (event: MouseEvent) => {
|
|
267
|
-
const hasSyntheticDrag = typeof propsRef.current.onMouse === "function";
|
|
268
|
-
const hasDirectDrag = typeof propsRef.current.onMouseDrag === "function" || typeof propsRef.current.onMouseDragEnd === "function";
|
|
269
|
-
pendingMoveRef.current = null;
|
|
270
|
-
// A press that never saw mouseup (the window move took the pointer) is still tracked.
|
|
271
|
-
// Finish it before the new press, so its drag-end cannot clear the drag this press starts.
|
|
272
|
-
endDocumentDragRef.current(null, "end");
|
|
273
|
-
callMouseHandler(propsRef.current.onMouseDown, event, "down");
|
|
274
|
-
if (event.button !== 0 || (event.isPropagationStopped() && !hasDirectDrag)) return;
|
|
275
|
-
if (!hasSyntheticDrag && !hasDirectDrag) return;
|
|
276
|
-
callMouseHandler(propsRef.current.onMouse, event, "down");
|
|
277
|
-
draggingRef.current = true;
|
|
278
|
-
lastPointRef.current = { x: event.clientX, y: event.clientY };
|
|
279
|
-
const originX = event.clientX;
|
|
280
|
-
const originY = event.clientY;
|
|
281
|
-
const move = (moveEvent: globalThis.MouseEvent) => {
|
|
282
|
-
if (!draggingRef.current) return;
|
|
283
|
-
const current = dragSessionRef.current;
|
|
284
|
-
if (isPointerMove(moveEvent)) {
|
|
285
|
-
if (current) current.pointerMoves = true;
|
|
286
|
-
} else if (current?.pointerMoves) {
|
|
287
|
-
return;
|
|
288
|
-
}
|
|
289
|
-
lastPointRef.current = { x: moveEvent.clientX, y: moveEvent.clientY };
|
|
290
|
-
// The button is up and mouseup never arrived. End the drag instead of following the cursor.
|
|
291
|
-
if (moveEvent.buttons === 0) {
|
|
292
|
-
endDocumentDragRef.current(moveEvent, "end");
|
|
293
|
-
return;
|
|
294
|
-
}
|
|
295
|
-
const dx = moveEvent.clientX - originX;
|
|
296
|
-
const dy = moveEvent.clientY - originY;
|
|
297
|
-
if (current && !current.shielded) {
|
|
298
|
-
if (dx * dx + dy * dy < 9) return;
|
|
299
|
-
current.shielded = true;
|
|
300
|
-
showDragShield(elementRef.current);
|
|
301
|
-
// Captured once it is a drag (a click keeps its usual target), the
|
|
302
|
-
// moves skip hit testing and leave every other element's hover state
|
|
303
|
-
// alone: nothing under the pointer restyles or repaints while a pane,
|
|
304
|
-
// divider or chart is dragged across it. The document listeners still
|
|
305
|
-
// see every move.
|
|
306
|
-
if (!current.captured) current.captured = capturePointer(elementRef.current, pressedPointerRef.current);
|
|
307
|
-
}
|
|
308
|
-
scheduleFrameMouseHandler(moveEvent, "drag", predictedPoint(moveEvent));
|
|
309
|
-
};
|
|
310
|
-
const up = (upEvent: globalThis.MouseEvent) => {
|
|
311
|
-
endDocumentDragRef.current(upEvent, "end");
|
|
312
|
-
};
|
|
313
|
-
const cancel = () => {
|
|
314
|
-
endDocumentDragRef.current(null, "cancel");
|
|
315
|
-
};
|
|
316
|
-
dragSessionRef.current = { move, up, cancel, captured: null, pointerMoves: false, shielded: false };
|
|
317
|
-
document.addEventListener("pointermove", move);
|
|
318
|
-
document.addEventListener("mousemove", move);
|
|
319
|
-
document.addEventListener("mouseup", up);
|
|
320
|
-
document.addEventListener("pointerup", up);
|
|
321
|
-
document.addEventListener("pointercancel", cancel);
|
|
322
|
-
window.addEventListener("blur", cancel);
|
|
323
|
-
};
|
|
324
|
-
|
|
325
369
|
const handlesDrag = typeof props.onMouse === "function"
|
|
326
370
|
|| typeof props.onMouseDrag === "function"
|
|
327
371
|
|| typeof props.onMouseDragEnd === "function";
|
|
328
|
-
const
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
};
|
|
335
|
-
|
|
336
|
-
const handleMouseOver = (event: MouseEvent) => {
|
|
337
|
-
callMouseHandler(propsRef.current.onMouseOver, event, "over");
|
|
338
|
-
};
|
|
339
|
-
|
|
340
|
-
const handleMouseOut = (event: MouseEvent) => {
|
|
341
|
-
pendingMoveRef.current = null;
|
|
342
|
-
callMouseHandler(propsRef.current.onMouseOut, event, "out");
|
|
343
|
-
};
|
|
344
|
-
|
|
372
|
+
const style = useStableStyle({
|
|
373
|
+
...commonStyle(props),
|
|
374
|
+
"--gloom-box-hover-bg": hoverBackgroundColor,
|
|
375
|
+
...(props.style as CSSProperties | undefined),
|
|
376
|
+
...(props.visible === false ? { display: "none" } : undefined),
|
|
377
|
+
} as CSSProperties);
|
|
345
378
|
return (
|
|
346
379
|
<div
|
|
347
380
|
{...cleanDomProps(props)}
|
|
348
381
|
data-gloom-hover-bg={hoverBackgroundColor ? "true" : undefined}
|
|
349
382
|
ref={elementRef}
|
|
350
|
-
onMouseDownCapture={typeof props.onMouseDownCapture === "function" ? handleMouseDownCapture : undefined}
|
|
351
|
-
onPointerDown={handlesDrag ? handlePointerDown : undefined}
|
|
352
|
-
onMouseDown={handleMouseDown}
|
|
353
|
-
onMouseOver={handleMouseOver}
|
|
354
|
-
onMouseMove={
|
|
355
|
-
onMouseUp={
|
|
356
|
-
onMouseOut={handleMouseOut}
|
|
357
|
-
style={
|
|
358
|
-
...commonStyle(props),
|
|
359
|
-
"--gloom-box-hover-bg": hoverBackgroundColor,
|
|
360
|
-
...(props.style as CSSProperties | undefined),
|
|
361
|
-
...(props.visible === false ? { display: "none" } : undefined),
|
|
362
|
-
} as CSSProperties}
|
|
383
|
+
onMouseDownCapture={typeof props.onMouseDownCapture === "function" ? handlers.handleMouseDownCapture : undefined}
|
|
384
|
+
onPointerDown={handlesDrag ? handlers.handlePointerDown : undefined}
|
|
385
|
+
onMouseDown={handlers.handleMouseDown}
|
|
386
|
+
onMouseOver={handlers.handleMouseOver}
|
|
387
|
+
onMouseMove={handlers.handleMouseMove}
|
|
388
|
+
onMouseUp={handlers.handleMouseUp}
|
|
389
|
+
onMouseOut={handlers.handleMouseOut}
|
|
390
|
+
style={style}
|
|
363
391
|
>
|
|
364
392
|
{children as ReactNode}
|
|
365
393
|
</div>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { useRef, type CSSProperties } from "react";
|
|
2
2
|
import { TextAttributes, type TextProps } from "../../../ui/host";
|
|
3
3
|
import { WEB_CELL_HEIGHT, WEB_CELL_WIDTH } from "../../../theme/font-scale";
|
|
4
4
|
|
|
@@ -113,30 +113,59 @@ export function textStyle(props: TextProps): CSSProperties {
|
|
|
113
113
|
};
|
|
114
114
|
}
|
|
115
115
|
|
|
116
|
+
/** Kit props a host element takes that are not DOM attributes (`onMouse*` handlers are left out too). */
|
|
117
|
+
const NON_DOM_PROPS: ReadonlySet<string> = new Set([
|
|
118
|
+
"fg", "bg", "backgroundColor", "flexDirection", "flexGrow", "flexShrink", "flexBasis", "flexWrap",
|
|
119
|
+
"alignItems", "justifyContent",
|
|
120
|
+
"padding", "paddingX", "paddingY", "paddingLeft", "paddingRight", "paddingTop", "paddingBottom",
|
|
121
|
+
"margin", "marginX", "marginY", "marginLeft", "marginRight", "marginTop", "marginBottom",
|
|
122
|
+
"bold", "underline", "inverse", "dim", "italic", "strikethrough", "attributes", "content", "position", "left", "right", "top", "bottom",
|
|
123
|
+
"zIndex", "width", "height", "minWidth", "minHeight", "maxWidth", "maxHeight", "gap", "columnGap", "rowGap",
|
|
124
|
+
"border", "borderStyle", "borderColor", "overflow", "selectable", "visible", "name", "color",
|
|
125
|
+
"focused", "focusedBackgroundColor", "textColor", "focusedTextColor", "placeholderColor",
|
|
126
|
+
"cursorColor", "selectionBg", "selectionFg", "showCursor", "keyBindings", "wrapText", "wrapMode",
|
|
127
|
+
"initialValue", "value", "onInput", "onChange", "onSubmit", "onEscape", "onCursorChange", "onMouse",
|
|
128
|
+
"scrollX", "scrollY", "focusable", "bitmap", "bitmaps", "crosshair", "vectors", "text", "font",
|
|
129
|
+
"hoverBackgroundColor", "joinPastedLines", "stickyScroll", "stickyStart", "onStickyPinChange", "pinchAsWheel",
|
|
130
|
+
]);
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* The props a host element passes on to its DOM node, in their order. Built in
|
|
134
|
+
* one pass: every box and text run calls this on every render.
|
|
135
|
+
*/
|
|
116
136
|
export function cleanDomProps(props: Record<string, unknown>): Record<string, unknown> {
|
|
117
|
-
const next = {
|
|
118
|
-
for (const key of
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
"padding", "paddingX", "paddingY", "paddingLeft", "paddingRight", "paddingTop", "paddingBottom",
|
|
122
|
-
"margin", "marginX", "marginY", "marginLeft", "marginRight", "marginTop", "marginBottom",
|
|
123
|
-
"bold", "underline", "inverse", "dim", "italic", "strikethrough", "attributes", "content", "position", "left", "right", "top", "bottom",
|
|
124
|
-
"zIndex", "width", "height", "minWidth", "minHeight", "maxWidth", "maxHeight", "gap", "columnGap", "rowGap",
|
|
125
|
-
"border", "borderStyle", "borderColor", "overflow", "selectable", "visible", "name", "color",
|
|
126
|
-
"focused", "focusedBackgroundColor", "textColor", "focusedTextColor", "placeholderColor",
|
|
127
|
-
"cursorColor", "selectionBg", "selectionFg", "showCursor", "keyBindings", "wrapText", "wrapMode",
|
|
128
|
-
"initialValue", "value", "onInput", "onChange", "onSubmit", "onEscape", "onCursorChange", "onMouse",
|
|
129
|
-
"scrollX", "scrollY", "focusable", "bitmap", "bitmaps", "crosshair", "vectors", "text", "font",
|
|
130
|
-
"hoverBackgroundColor", "joinPastedLines", "stickyScroll", "stickyStart", "onStickyPinChange", "pinchAsWheel",
|
|
131
|
-
]) {
|
|
132
|
-
delete next[key];
|
|
133
|
-
}
|
|
134
|
-
for (const key of Object.keys(next)) {
|
|
135
|
-
if (key.startsWith("onMouse")) delete next[key];
|
|
137
|
+
const next: Record<string, unknown> = {};
|
|
138
|
+
for (const key of Object.keys(props)) {
|
|
139
|
+
if (NON_DOM_PROPS.has(key) || key.startsWith("onMouse")) continue;
|
|
140
|
+
next[key] = props[key];
|
|
136
141
|
}
|
|
137
142
|
return next;
|
|
138
143
|
}
|
|
139
144
|
|
|
145
|
+
/**
|
|
146
|
+
* `style` as it was last rendered while nothing in it changed, so React skips
|
|
147
|
+
* the element's inline style on a re-render instead of comparing every
|
|
148
|
+
* property again (and reading `element.style`). A host box re-renders with
|
|
149
|
+
* each render of its parent, and most leave its style as it was.
|
|
150
|
+
*/
|
|
151
|
+
export function useStableStyle<T extends object>(style: T): T {
|
|
152
|
+
const previousRef = useRef<{ style: T; keys: string[] } | null>(null);
|
|
153
|
+
const previous = previousRef.current;
|
|
154
|
+
if (previous && sameStyle(previous.style as Record<string, unknown>, previous.keys, style as Record<string, unknown>)) return previous.style;
|
|
155
|
+
previousRef.current = { style, keys: Object.keys(style) };
|
|
156
|
+
return style;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/** The same keys with the same values, so React would write nothing. Read in order, which a rebuilt style keeps. */
|
|
160
|
+
function sameStyle(left: Record<string, unknown>, leftKeys: readonly string[], right: Record<string, unknown>): boolean {
|
|
161
|
+
let index = 0;
|
|
162
|
+
for (const key in right) {
|
|
163
|
+
if (leftKeys[index] !== key || left[key] !== right[key]) return false;
|
|
164
|
+
index += 1;
|
|
165
|
+
}
|
|
166
|
+
return index === leftKeys.length;
|
|
167
|
+
}
|
|
168
|
+
|
|
140
169
|
function allowsZeroMinSize(props: Record<string, unknown>, axis: "inline" | "block"): boolean {
|
|
141
170
|
if (props.overflow === "hidden" || props.overflow === "clip") return true;
|
|
142
171
|
if (typeof props.flexShrink === "number" && props.flexShrink > 0) return true;
|
|
@@ -11,7 +11,7 @@ import { renderAsciiText } from "../../../ui/ascii-font";
|
|
|
11
11
|
import { webAsciiTextLines, webAsciiTextWordmarkVariant } from "./ascii-text";
|
|
12
12
|
import { BlockGlyphCanvas } from "./block-glyph-canvas";
|
|
13
13
|
import { mouseHandlers } from "./mouse";
|
|
14
|
-
import { cleanDomProps, commonStyle, selectionStyle, textStyle } from "./style";
|
|
14
|
+
import { cleanDomProps, commonStyle, selectionStyle, textStyle, useStableStyle } from "./style";
|
|
15
15
|
|
|
16
16
|
// Read per render: the cell width tracks the configured font size.
|
|
17
17
|
function wordmarkCharWidthPx(): number {
|
|
@@ -60,11 +60,12 @@ function renderTextContent(children: ReactNode, content: TextProps["content"], b
|
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
export function WebText({ children, ...props }: TextProps) {
|
|
63
|
+
const style = useStableStyle({ ...textStyle(props), ...(props.style as CSSProperties | undefined) });
|
|
63
64
|
return (
|
|
64
65
|
<span
|
|
65
66
|
{...cleanDomProps(props)}
|
|
66
67
|
{...mouseHandlers(props)}
|
|
67
|
-
style={
|
|
68
|
+
style={style}
|
|
68
69
|
>
|
|
69
70
|
{renderTextContent(children, props.content, props)}
|
|
70
71
|
</span>
|
|
@@ -9,7 +9,8 @@ const GITHUB_ISSUE_URL = "https://github.com/gloom-sh/gloomberb/issues/new/choos
|
|
|
9
9
|
|
|
10
10
|
export type ElectrobunApplicationMenuCommand =
|
|
11
11
|
| DesktopApplicationMenuCommand
|
|
12
|
-
| { type: "open-devtools" }
|
|
12
|
+
| { type: "open-devtools" }
|
|
13
|
+
| { type: "new-window" };
|
|
13
14
|
|
|
14
15
|
function commandItem(
|
|
15
16
|
label: string,
|
|
@@ -49,6 +50,8 @@ function buildApplicationMenu(keybindings: ResolvedKeybindings): ApplicationMenu
|
|
|
49
50
|
{
|
|
50
51
|
label: "File",
|
|
51
52
|
submenu: [
|
|
53
|
+
commandItem("New Window", { type: "new-window" }),
|
|
54
|
+
{ type: "divider" },
|
|
52
55
|
openCommandBar("Search Ticker...", "DES ", accelerator("ticker-search")),
|
|
53
56
|
{ type: "divider" },
|
|
54
57
|
commandItem("New Portfolio...", { type: "open-builtin-workflow", actionId: "new-portfolio" }),
|
|
@@ -13,7 +13,7 @@ import type {
|
|
|
13
13
|
} from "../../shared/protocol";
|
|
14
14
|
import { encodeRpcValue } from "../../shared/rpc-codec";
|
|
15
15
|
import { desktopBootFramePath, removeDesktopBootFrame } from "../window/boot-frame";
|
|
16
|
-
import { paneIdFromDetachedRpcKey } from "../window/focus";
|
|
16
|
+
import { MAIN_WINDOW_RPC_KEY, paneIdFromDetachedRpcKey } from "../window/focus";
|
|
17
17
|
import type { DesktopBackend, DesktopRpc } from "./backend";
|
|
18
18
|
import { createElectrobunDesktopUpdater } from "./update";
|
|
19
19
|
|
|
@@ -29,9 +29,13 @@ function sendUpdateProgress(rpc: DesktopRpc, progress: UpdateProgress): void {
|
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
/**
|
|
32
|
+
/**
|
|
33
|
+
* Every window but the main one closes, and the workspace and services go,
|
|
34
|
+
* before the data they read is replaced. Extra windows open again with the
|
|
35
|
+
* next session where their tabs are still there.
|
|
36
|
+
*/
|
|
33
37
|
function closeDesktopSession(backend: DesktopBackend): void {
|
|
34
|
-
backend.
|
|
38
|
+
backend.closeAllWindows();
|
|
35
39
|
backend.workspace = null;
|
|
36
40
|
backend.teardownServices();
|
|
37
41
|
}
|
|
@@ -68,11 +72,13 @@ export async function handleDesktopBackendRequest(
|
|
|
68
72
|
case "config.save": {
|
|
69
73
|
const desktopWorkspace = backend.workspace;
|
|
70
74
|
if (desktopWorkspace) {
|
|
71
|
-
//
|
|
72
|
-
|
|
75
|
+
// A popped-out window's save counts only for its own pane; a full
|
|
76
|
+
// window's for what it changed, among its own tabs.
|
|
77
|
+
const senderKey = backend.rpcs.getRpcWindowKey(rpc);
|
|
78
|
+
const senderDetachedPaneId = paneIdFromDetachedRpcKey(senderKey);
|
|
73
79
|
await backend.commitDesktopSnapshot(senderDetachedPaneId
|
|
74
80
|
? desktopWorkspace.replaceConfigFromDetachedPane(senderDetachedPaneId, request.payload.config)
|
|
75
|
-
: desktopWorkspace.
|
|
81
|
+
: desktopWorkspace.replaceConfigFromWindow(senderKey ?? MAIN_WINDOW_RPC_KEY, request.payload.config));
|
|
76
82
|
return null;
|
|
77
83
|
}
|
|
78
84
|
backend.setConfig(request.payload.config);
|
|
@@ -86,9 +92,14 @@ export async function handleDesktopBackendRequest(
|
|
|
86
92
|
removeDesktopBootFrame(desktopBootFramePath());
|
|
87
93
|
await resetAllData(request.payload.dataDir);
|
|
88
94
|
return null;
|
|
89
|
-
case "config.export":
|
|
90
|
-
|
|
95
|
+
case "config.export": {
|
|
96
|
+
// With more than one window, each has only its own tabs: the export is
|
|
97
|
+
// the whole config, every window's tabs included.
|
|
98
|
+
const workspace = backend.workspace;
|
|
99
|
+
const config = workspace && workspace.windowIds().length > 1 ? workspace.getSnapshot().config : request.payload.config;
|
|
100
|
+
await exportConfig(config, request.payload.destPath);
|
|
91
101
|
return null;
|
|
102
|
+
}
|
|
92
103
|
case "config.import": {
|
|
93
104
|
closeDesktopSession(backend);
|
|
94
105
|
await backend.startServices(await importConfig(request.payload.dataDir, request.payload.srcPath));
|