gloomberb 0.20.3 → 0.20.4

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.
Files changed (154) hide show
  1. package/package.json +1 -1
  2. package/src/account/auth-dialog.tsx +17 -0
  3. package/src/api-client/data.ts +6 -0
  4. package/src/api-client/fx-interventions.ts +64 -0
  5. package/src/api-client/index.ts +1 -0
  6. package/src/api-client/release-summaries.ts +21 -0
  7. package/src/app/keybindings/actions.ts +2 -2
  8. package/src/app/pane-runtime/ticker-open-runtime.ts +245 -66
  9. package/src/cli/commands/market.ts +77 -1
  10. package/src/cli/commands/news-search.ts +1 -3
  11. package/src/cli/commands/plugins.ts +27 -5
  12. package/src/cli/commands/system.ts +19 -3
  13. package/src/cli/commands/ticker.ts +60 -19
  14. package/src/cli/index.ts +8 -8
  15. package/src/cli/pane-functions/function-help.ts +3 -3
  16. package/src/cli/report-tables.ts +18 -6
  17. package/src/cli/result.ts +15 -7
  18. package/src/cli/types.ts +2 -0
  19. package/src/components/chart/composite/axis-overlays.tsx +22 -0
  20. package/src/components/chart/composite/composite-chart.tsx +54 -13
  21. package/src/components/chart/composite/event-captions.ts +109 -0
  22. package/src/components/chart/composite/event-guides.ts +74 -0
  23. package/src/components/chart/composite/rasterizer.ts +2 -0
  24. package/src/components/chart/composite/text-renderer.ts +2 -0
  25. package/src/components/chart/composite/types.ts +31 -0
  26. package/src/components/command-bar/layout-items/focused-pane.ts +5 -5
  27. package/src/components/command-bar/routes/root/provider-search.ts +5 -4
  28. package/src/components/command-bar/routes/ticker-search/results.ts +51 -0
  29. package/src/components/command-bar/routes/ticker-search/route.ts +3 -2
  30. package/src/components/layout/detached-pane-shell.tsx +1 -1
  31. package/src/components/layout/floating-pane.tsx +5 -1
  32. package/src/components/layout/pane/footer/index.tsx +21 -14
  33. package/src/components/layout/pane/footer/model.ts +6 -0
  34. package/src/components/layout/shell/action-menu-overlay.tsx +10 -5
  35. package/src/components/layout/shell/active-drag.ts +149 -105
  36. package/src/components/layout/shell/drag/drop-zones.ts +162 -0
  37. package/src/components/layout/shell/drag/index.ts +47 -218
  38. package/src/components/layout/shell/drag/live.ts +10 -3
  39. package/src/components/layout/shell/drag/overlays.tsx +182 -5
  40. package/src/components/layout/shell/drag/runtime.ts +29 -6
  41. package/src/components/layout/shell/drag/shared-edges.ts +156 -0
  42. package/src/components/layout/shell/index.tsx +11 -6
  43. package/src/components/layout/shell/menu.ts +11 -2
  44. package/src/components/layout/shell/native/pointer-runtime.ts +25 -0
  45. package/src/components/layout/shell/native/window-state.ts +2 -2
  46. package/src/components/layout/shell/pane/layers.tsx +71 -7
  47. package/src/components/layout/shell/terminal-pointer-runtime.ts +18 -9
  48. package/src/components/layout/shell/window-mode/index.ts +8 -10
  49. package/src/components/layout/window-edit/mode.ts +39 -7
  50. package/src/components/layout/window-edit/presentation.ts +1 -1
  51. package/src/components/onboarding/onboarding-keyboard.ts +4 -0
  52. package/src/components/onboarding/onboarding-wizard.tsx +8 -3
  53. package/src/components/ui/button.tsx +2 -0
  54. package/src/components/ui/choice-dialog.tsx +1 -0
  55. package/src/components/ui/data-table/index.tsx +4 -3
  56. package/src/components/ui/list-view.tsx +7 -12
  57. package/src/components/ui/loading.tsx +10 -3
  58. package/src/components/ui/menu.tsx +6 -2
  59. package/src/components/ui/quote.ts +14 -1
  60. package/src/data/config/layout.ts +5 -2
  61. package/src/docs/snapshot.json +29 -5
  62. package/src/i18n/es.ts +9 -8
  63. package/src/i18n/ja.ts +9 -8
  64. package/src/i18n/ko.ts +9 -8
  65. package/src/i18n/zh-cn.ts +9 -8
  66. package/src/i18n/zh-tw.ts +9 -8
  67. package/src/layout/pane-manager/floating-actions.ts +17 -0
  68. package/src/layout/pane-manager/floating-stack.ts +187 -0
  69. package/src/layout/pane-manager/floating.ts +4 -2
  70. package/src/layout/pane-manager/gridlock.ts +5 -1
  71. package/src/layout/pane-manager/index.ts +11 -0
  72. package/src/layout/pane-manager/layout-state.ts +10 -3
  73. package/src/market-data/futures-board.ts +46 -1
  74. package/src/market-data/futures-contract.ts +12 -3
  75. package/src/market-data/fx-interventions.ts +270 -0
  76. package/src/news/news-model.ts +44 -2
  77. package/src/plugins/builtin/alerts/cli.ts +4 -4
  78. package/src/plugins/builtin/alerts/format.ts +1 -2
  79. package/src/plugins/builtin/alerts/headless.ts +1 -2
  80. package/src/plugins/builtin/alerts/move-checks.ts +12 -6
  81. package/src/plugins/builtin/alerts/move.ts +30 -9
  82. package/src/plugins/builtin/alerts/pane.tsx +0 -2
  83. package/src/plugins/builtin/alerts/storage.ts +4 -2
  84. package/src/plugins/builtin/alerts/types.ts +12 -0
  85. package/src/plugins/builtin/changelog/index.tsx +292 -101
  86. package/src/plugins/builtin/changelog/versions.ts +293 -0
  87. package/src/plugins/builtin/chart-composer/intervention-events.ts +105 -0
  88. package/src/plugins/builtin/chart-composer/pane.tsx +21 -7
  89. package/src/plugins/builtin/chat/message/render-state.ts +2 -5
  90. package/src/plugins/builtin/cloud/askg/attached-pane.tsx +10 -5
  91. package/src/plugins/builtin/cloud/askg/controller.ts +141 -5
  92. package/src/plugins/builtin/cloud/askg/executor.ts +113 -4
  93. package/src/plugins/builtin/cloud/askg/manifest.ts +28 -13
  94. package/src/plugins/builtin/cloud/askg/model.ts +14 -4
  95. package/src/plugins/builtin/cloud/askg/pane.tsx +70 -46
  96. package/src/plugins/builtin/cloud/askg/turn-parts.tsx +70 -0
  97. package/src/plugins/builtin/cloud/terminal-relay/engine.ts +50 -130
  98. package/src/plugins/builtin/cloud/terminal-relay/policy.ts +327 -7
  99. package/src/plugins/builtin/cloud/terminal-relay/prompts.tsx +2 -1
  100. package/src/plugins/builtin/cloud/terminal-relay/redact.ts +47 -6
  101. package/src/plugins/builtin/commodities-energy/index.tsx +1 -3
  102. package/src/plugins/builtin/commodities-energy/view-state.ts +3 -0
  103. package/src/plugins/builtin/cot/headless.ts +14 -2
  104. package/src/plugins/builtin/earnings/index.tsx +2 -2
  105. package/src/plugins/builtin/futures/index.tsx +25 -4
  106. package/src/plugins/builtin/futures/model.ts +28 -32
  107. package/src/plugins/builtin/futures/series.ts +4 -3
  108. package/src/plugins/builtin/futures/table.tsx +16 -9
  109. package/src/plugins/builtin/futures/use-board-terms.ts +3 -3
  110. package/src/plugins/builtin/help/index.tsx +3 -3
  111. package/src/plugins/builtin/help/keybindings-editor.tsx +18 -4
  112. package/src/plugins/builtin/layout-manager/index.tsx +8 -8
  113. package/src/plugins/builtin/news/headless.ts +2 -2
  114. package/src/plugins/builtin/news/index.tsx +3 -3
  115. package/src/plugins/builtin/perps/markets-section.tsx +5 -2
  116. package/src/plugins/builtin/plugin-marketplace/pane.tsx +11 -11
  117. package/src/plugins/builtin/portfolio-list/summary/index.tsx +3 -1
  118. package/src/plugins/builtin/research/event-model.ts +9 -1
  119. package/src/plugins/builtin/research/event-sources.ts +22 -0
  120. package/src/plugins/builtin/research/headless.ts +3 -3
  121. package/src/plugins/builtin/shared/cloud-upgrade.ts +27 -3
  122. package/src/plugins/builtin/ticker-detail/overview/components.tsx +54 -5
  123. package/src/plugins/builtin/ticker-detail/overview-tab.tsx +28 -13
  124. package/src/plugins/builtin/ticker-detail/pane.tsx +7 -2
  125. package/src/plugins/installer.ts +45 -0
  126. package/src/remote/resources.ts +12 -1
  127. package/src/remote/schema.ts +1 -0
  128. package/src/remote/semantic-helpers.ts +29 -1
  129. package/src/remote/semantic-tree.tsx +32 -15
  130. package/src/renderers/cloudflare/worker.ts +16 -1
  131. package/src/renderers/dom/styles.css +40 -6
  132. package/src/renderers/share/layout-view.tsx +1 -1
  133. package/src/sources/gloomberb-cloud/news.ts +35 -12
  134. package/src/state/opening-ticker-panes.ts +47 -0
  135. package/src/test-support/cli-context.ts +2 -0
  136. package/src/test-support/preload.ts +4 -1
  137. package/src/tickers/instrument-kind.ts +23 -3
  138. package/src/types/config.ts +5 -0
  139. package/src/types/context-menu.ts +2 -0
  140. package/src/types/plugin-commands.ts +140 -0
  141. package/src/types/plugin-context.ts +125 -0
  142. package/src/types/plugin-contributions.ts +55 -0
  143. package/src/types/plugin-definition.ts +234 -0
  144. package/src/types/plugin-notifications.ts +38 -0
  145. package/src/types/plugin-pane-settings.ts +114 -0
  146. package/src/types/plugin-pane-templates.ts +160 -0
  147. package/src/types/plugin-panes.ts +221 -0
  148. package/src/types/plugin-reports.ts +35 -0
  149. package/src/types/plugin-shared.ts +14 -0
  150. package/src/types/plugin-state.ts +71 -0
  151. package/src/types/plugin.ts +14 -1169
  152. package/src/ui/index.tsx +14 -3
  153. package/src/updater/github-releases.ts +23 -0
  154. package/src/utils/cli-output.ts +22 -9
@@ -0,0 +1,162 @@
1
+ import type { LayoutBounds } from "../../../../layout/pane-manager";
2
+ import { pointInRect } from "./index";
3
+
4
+ /**
5
+ * Where a pane on the move can land, as targets in sight, the same on the
6
+ * desktop, the web and in the terminal. Over any pane, in the layout or
7
+ * floating, a small target shows on that pane: its centre stacks the moving
8
+ * pane there as a tab, its four sides split that pane on that side. Thin
9
+ * strips along the window's outer edges put it along that whole edge of the
10
+ * layout. Anywhere else it floats where it is let go. Nothing waits on time:
11
+ * the target under the pointer is what a release does.
12
+ */
13
+
14
+ export type DropZoneSide = "center" | "left" | "right" | "top" | "bottom";
15
+ export type DropStripEdge = "left" | "right" | "top" | "bottom";
16
+
17
+ /** A pane a moving pane is over: the one its target is drawn on. */
18
+ export interface DropZoneHost {
19
+ /** The pane the target acts on: a stack's shown tab, or another tab of the moving pane's own stack. */
20
+ id: string;
21
+ rect: LayoutBounds;
22
+ /** In the layout (a split or tab there); otherwise a floating window. */
23
+ docked: boolean;
24
+ }
25
+
26
+ /** What the pointer is over, and so what a release does. */
27
+ export interface DropZoneState {
28
+ host: DropZoneHost | null;
29
+ /** The square of the host's target under the pointer, if any. */
30
+ side: DropZoneSide | null;
31
+ /** The strip along the window's edge under the pointer, if any. */
32
+ edge: DropStripEdge | null;
33
+ }
34
+
35
+ /** The size of the targets, in shell cells. */
36
+ export interface DropZoneMetrics {
37
+ /** One square of a pane's target. */
38
+ square: { width: number; height: number };
39
+ /** Between two squares. */
40
+ gap: { x: number; y: number };
41
+ /** How far a strip reaches in from the window's edge. */
42
+ strip: { x: number; y: number };
43
+ /** The terminal: squares sit on whole cells. */
44
+ wholeCells: boolean;
45
+ }
46
+
47
+ /** Desktop and web, in px: a square of the target, the gap between two, a strip's depth. */
48
+ const SQUARE_PX = 36;
49
+ const GAP_PX = 6;
50
+ const STRIP_PX = 12;
51
+
52
+ /** The desktop's targets for cells of `cell` px. */
53
+ export function desktopDropZoneMetrics(cell: { width: number; height: number }): DropZoneMetrics {
54
+ return {
55
+ square: { width: SQUARE_PX / cell.width, height: SQUARE_PX / cell.height },
56
+ gap: { x: GAP_PX / cell.width, y: GAP_PX / cell.height },
57
+ strip: { x: STRIP_PX / cell.width, y: STRIP_PX / cell.height },
58
+ wholeCells: false,
59
+ };
60
+ }
61
+
62
+ /**
63
+ * The terminal's: a square is three cells by one row (a cell is about half
64
+ * as wide as it is tall), a cell apart across and touching up and down; a
65
+ * strip is the outermost cell.
66
+ */
67
+ export const TERMINAL_DROP_ZONE_METRICS: DropZoneMetrics = {
68
+ square: { width: 3, height: 1 },
69
+ gap: { x: 1, y: 0 },
70
+ strip: { x: 1, y: 1 },
71
+ wholeCells: true,
72
+ };
73
+
74
+ const SIDES: readonly DropZoneSide[] = ["center", "left", "right", "top", "bottom"];
75
+
76
+ /** Each square of the target drawn on a pane at `rect`, around its middle. */
77
+ export function dropZoneSquares(rect: LayoutBounds, metrics: DropZoneMetrics): Record<DropZoneSide, LayoutBounds> {
78
+ const { width, height } = metrics.square;
79
+ const stepX = width + metrics.gap.x;
80
+ const stepY = height + metrics.gap.y;
81
+ const place = (value: number) => (metrics.wholeCells ? Math.floor(value) : value);
82
+ const cx = place(rect.x + (rect.width - width) / 2);
83
+ const cy = place(rect.y + (rect.height - height) / 2);
84
+ const at = (dx: number, dy: number) => ({ x: cx + dx * stepX, y: cy + dy * stepY, width, height });
85
+ return {
86
+ center: at(0, 0),
87
+ left: at(-1, 0),
88
+ right: at(1, 0),
89
+ top: at(0, -1),
90
+ bottom: at(0, 1),
91
+ };
92
+ }
93
+
94
+ /** The strip along each edge of `area`. */
95
+ export function dropStrips(area: LayoutBounds, metrics: DropZoneMetrics): Record<DropStripEdge, LayoutBounds> {
96
+ const { x: across, y: down } = metrics.strip;
97
+ return {
98
+ left: { x: area.x, y: area.y, width: across, height: area.height },
99
+ right: { x: area.x + area.width - across, y: area.y, width: across, height: area.height },
100
+ top: { x: area.x, y: area.y, width: area.width, height: down },
101
+ bottom: { x: area.x, y: area.y + area.height - down, width: area.width, height: down },
102
+ };
103
+ }
104
+
105
+ const NO_DROP_ZONE: DropZoneState = { host: null, side: null, edge: null };
106
+
107
+ /**
108
+ * What the pointer at (`x`, `y`), in shell cells, is over. A strip first: the
109
+ * pointer past the window's edge (over the header or the status bar) is in
110
+ * its strip, and in a corner the nearer edge wins. Then the first of `hosts`
111
+ * (front to back) under the pointer, and the square of its target there.
112
+ */
113
+ export function resolveDropZone({
114
+ x,
115
+ y,
116
+ hosts,
117
+ area,
118
+ metrics,
119
+ }: {
120
+ x: number;
121
+ y: number;
122
+ hosts: readonly DropZoneHost[];
123
+ area: LayoutBounds;
124
+ metrics: DropZoneMetrics;
125
+ }): DropZoneState {
126
+ // How far into each strip the pointer is, in strip depths: under 1 is in it.
127
+ const { strip } = metrics;
128
+ const depths: Array<[DropStripEdge, number]> = [
129
+ ["left", (x - area.x) / strip.x],
130
+ ["right", (area.x + area.width - x) / strip.x],
131
+ ["top", (y - area.y) / strip.y],
132
+ ["bottom", (area.y + area.height - y) / strip.y],
133
+ ];
134
+ let edge: DropStripEdge | null = null;
135
+ let nearest = 1;
136
+ for (const [candidate, depth] of depths) {
137
+ // The terminal's pointer is a cell: its far side is a cell on.
138
+ const reach = metrics.wholeCells && (candidate === "right" || candidate === "bottom") ? depth - 1 : depth;
139
+ if (reach < nearest) {
140
+ edge = candidate;
141
+ nearest = reach;
142
+ }
143
+ }
144
+ if (edge) return { host: null, side: null, edge };
145
+ const host = hosts.find((candidate) => pointInRect(candidate.rect, x, y)) ?? null;
146
+ if (!host) return NO_DROP_ZONE;
147
+ const squares = dropZoneSquares(host.rect, metrics);
148
+ const side = SIDES.find((candidate) => pointInRect(squares[candidate], x, y)) ?? null;
149
+ return { host, side, edge: null };
150
+ }
151
+
152
+ function sameBounds(a: LayoutBounds, b: LayoutBounds): boolean {
153
+ return a.x === b.x && a.y === b.y && a.width === b.width && a.height === b.height;
154
+ }
155
+
156
+ export function sameDropZone(a: DropZoneState | null, b: DropZoneState | null): boolean {
157
+ if (a === b) return true;
158
+ if (!a || !b) return false;
159
+ if (a.side !== b.side || a.edge !== b.edge) return false;
160
+ if (!a.host || !b.host) return a.host === b.host;
161
+ return a.host.id === b.host.id && a.host.docked === b.host.docked && sameBounds(a.host.rect, b.host.rect);
162
+ }
@@ -3,7 +3,11 @@ import {
3
3
  MIN_FLOAT_WIDTH,
4
4
  applyDrop,
5
5
  floatAtRect,
6
- type DockLeafLayout,
6
+ floatingStackMembers,
7
+ splitFloating,
8
+ stackFloatingOnto,
9
+ unstackFloating,
10
+ type FloatingSplitSide,
7
11
  type DropTarget,
8
12
  type FloatingRect,
9
13
  type LayoutBounds,
@@ -12,36 +16,35 @@ import type { DesktopDockPreviewState } from "../../../../types/desktop-window";
12
16
  import type { LayoutConfig } from "../../../../types/config";
13
17
  import { PANE_HEADER_ACTION, PANE_HEADER_CLOSE, PANE_HEADER_HELP, PANE_HEADER_RESTORE } from "../../pane/header";
14
18
 
15
- export type SnapGuidePosition =
16
- | "left"
17
- | "right"
18
- | "top"
19
- | "bottom"
20
- | "top-left"
21
- | "top-right"
22
- | "bottom-left"
23
- | "bottom-right";
24
-
25
- export interface SnapGuide {
26
- position: SnapGuidePosition;
27
- triggerRect: LayoutBounds;
28
- previewRect: FloatingRect;
29
- }
19
+ /** A release onto a floating window: a tab of it, or half of its rect beside it. */
20
+ type FloatDrop =
21
+ | { type: "tab"; targetId: string }
22
+ | { type: "split"; targetId: string; side: FloatingSplitSide };
30
23
 
24
+ /** Where a release lands a pane on the move, outlined while it would. */
31
25
  export type DragPreview =
32
26
  | {
27
+ /** A place in the layout: a split, a tab, or along a whole edge. */
33
28
  kind: "dock";
34
29
  target: DropTarget;
35
30
  rect: LayoutBounds;
36
31
  }
37
32
  | {
38
- kind: "snap";
39
- position: SnapGuidePosition;
40
- rect: FloatingRect;
33
+ /** On a floating window: a tab of it, or half of it. */
34
+ kind: "float";
35
+ drop: FloatDrop;
36
+ rect: LayoutBounds;
41
37
  };
42
38
 
39
+ /**
40
+ * What a pane move takes: a pane in the layout (drawn as an outline until it
41
+ * lands), a floating window with every tab of its stack, or one tab pulled
42
+ * out of a floating stack (an outline too, the stack staying where it is).
43
+ */
44
+ export type PaneDragMode = "docked" | "floating" | "tab";
45
+
43
46
  export interface PaneDragRectState {
44
- mode: "docked" | "floating";
47
+ mode: PaneDragMode;
45
48
  startX: number;
46
49
  startY: number;
47
50
  origRect: FloatingRect;
@@ -120,7 +123,7 @@ export function constrainFloatingRectToBounds(
120
123
  * hold it in: a docked pane at its floating size, held where it was pressed
121
124
  * (as far into it as it reaches); a floating one moved by the pointer.
122
125
  */
123
- export function freePaneDragRect(
126
+ function freePaneDragRect(
124
127
  drag: PaneDragRectState,
125
128
  baseRect: FloatingRect,
126
129
  pointerX: number,
@@ -128,7 +131,7 @@ export function freePaneDragRect(
128
131
  totalWidth: number,
129
132
  totalHeight: number,
130
133
  ): FloatingRect {
131
- if (drag.mode === "docked") {
134
+ if (drag.mode !== "floating") {
132
135
  const fittedRect = constrainFloatingRectToBounds(baseRect, totalWidth, totalHeight);
133
136
  const pointerOffsetX = Math.max(0, Math.min(fittedRect.width - 1, drag.startX - drag.origRect.x));
134
137
  const pointerOffsetY = Math.max(0, Math.min(fittedRect.height - 1, drag.startY - drag.origRect.y));
@@ -182,122 +185,6 @@ export function resolveFloatResizeRect(
182
185
  return constrainFloatingRectToBounds({ x, y, width, height, zIndex: origRect.zIndex }, totalWidth, totalHeight);
183
186
  }
184
187
 
185
- /** A distance on each axis, in cells. */
186
- export interface AxisDistance {
187
- x: number;
188
- y: number;
189
- }
190
-
191
- const JOIN_SIDES = [
192
- ["left", "x"],
193
- ["right", "x"],
194
- ["top", "y"],
195
- ["bottom", "y"],
196
- ] as const;
197
-
198
- type JoinSide = (typeof JOIN_SIDES)[number][0];
199
-
200
- /** Where a pane on the move could land on release, if anywhere but where it is drawn. */
201
- export interface PaneDropTargets {
202
- /** Over another spot's title bar: a tab there, what a release makes until a join has held. */
203
- tab: Extract<DropTarget, { kind: "tab" }> | null;
204
- /** An edge held flush: a join on that side, once it has held (JOIN_DWELL_MS), over the tab too. */
205
- join: Extract<DropTarget, { kind: "leaf" }> | null;
206
- }
207
-
208
- const NO_DROP: PaneDropTargets = { tab: null, join: null };
209
-
210
- /**
211
- * Where a pane on the move could land on release. Over another spot's title
212
- * bar it becomes a tab there. Its edge pushed flush against the same edge of
213
- * the spot under the pointer, where that spot meets another (never the dock's
214
- * own edge, so a window parked at the screen's edge or corner stays
215
- * floating), it joins the dock on that side: where it is drawn and where the
216
- * pointer puts it, that edge is within `flush` of the spot's. The pointer may
217
- * be on that spot's title bar: a pane is held by its own, so it is there for
218
- * every join above a spot and for a side join with the two title bars level.
219
- * An axis the pane spans from edge to edge of the spot gives it no side to
220
- * join on there, so a pane laid squarely on a spot of its size is a tab. The
221
- * caller arms a join only once it has held (see JOIN_DWELL_MS); until then a
222
- * release on the title bar makes the tab. `join` false (Alt) leaves the
223
- * edges out.
224
- */
225
- export function resolvePaneDropTarget({
226
- x,
227
- y,
228
- rect,
229
- free,
230
- leaves,
231
- paneId,
232
- area,
233
- flush,
234
- headerRows,
235
- join,
236
- }: {
237
- /** The pointer, in shell cells. */
238
- x: number;
239
- y: number;
240
- /** Where the moving pane is drawn, its edges caught by the magnets. */
241
- rect: LayoutBounds;
242
- /** Where the pointer alone puts it, past the screen's edges if it goes there. */
243
- free: LayoutBounds;
244
- leaves: readonly DockLeafLayout[];
245
- paneId: string;
246
- /** The dock area. */
247
- area: LayoutBounds;
248
- /** How close its edge comes to a spot's edge to count as flush (the magnets' catch). */
249
- flush: AxisDistance;
250
- /** A docked pane's title bar, in rows. */
251
- headerRows: number;
252
- join: boolean;
253
- }): PaneDropTargets {
254
- if (!pointInRect(area, x, y)) return NO_DROP;
255
- const leaf = leaves.find((entry) => pointInRect(entry.rect, x, y));
256
- if (!leaf) return NO_DROP;
257
- // Its own spot: alone there, nothing to land on; a tab of a stack can
258
- // leave it for a side of the stack, but is a tab of it already, and its
259
- // title bar is where the tab is pulled out from.
260
- const own = leaf.instanceId === paneId || (leaf.stack?.includes(paneId) ?? false);
261
- const targetId = leaf.instanceId !== paneId ? leaf.instanceId : leaf.stack?.find((id) => id !== paneId);
262
- if (!targetId) return NO_DROP;
263
- const onTitleBar = y < leaf.rect.y + headerRows;
264
- if (onTitleBar && own) return NO_DROP;
265
- const tab = onTitleBar ? { kind: "tab" as const, targetId } : null;
266
- if (!join) return { tab, join: null };
267
- const edgeOf = (box: LayoutBounds, side: JoinSide) => (
268
- side === "left" ? box.x : side === "right" ? box.x + box.width : side === "top" ? box.y : box.y + box.height
269
- );
270
- // How far the edge on `side` is from the spot's, in catches, where it is
271
- // drawn; null unless it is flush there and where the pointer puts it.
272
- const closenessAt = (side: JoinSide, axis: keyof AxisDistance) => {
273
- const line = edgeOf(leaf.rect, side);
274
- if (Math.abs(edgeOf(free, side) - line) > flush[axis]) return null;
275
- const closeness = Math.abs(edgeOf(rect, side) - line) / Math.max(flush[axis], 1e-6);
276
- return closeness <= 1 ? closeness : null;
277
- };
278
- const spans = {
279
- x: closenessAt("left", "x") !== null && closenessAt("right", "x") !== null,
280
- y: closenessAt("top", "y") !== null && closenessAt("bottom", "y") !== null,
281
- };
282
- // The closest edge wins; level with another, the first of left, right, top, bottom.
283
- let best: { side: JoinSide; closeness: number } | null = null;
284
- for (const [side, axis] of JOIN_SIDES) {
285
- if (spans[axis]) continue;
286
- // The dock's own edge is the screen's: parking there is not joining.
287
- if (Math.abs(edgeOf(leaf.rect, side) - edgeOf(area, side)) <= flush[axis]) continue;
288
- const closeness = closenessAt(side, axis);
289
- if (closeness !== null && (!best || closeness < best.closeness)) best = { side, closeness };
290
- }
291
- return { tab, join: best ? { kind: "leaf", targetId, position: best.side } : null };
292
- }
293
-
294
- /**
295
- * How long an edge holds flush before the join arms and its preview shows, so
296
- * a window moved past a docked pane's edge, or briefly lined up with it, does
297
- * not dock on release.
298
- */
299
- export const JOIN_DWELL_MS = 350;
300
-
301
188
  export function resolveDividerPreviewRect(
302
189
  axis: "horizontal" | "vertical",
303
190
  bounds: LayoutBounds,
@@ -336,90 +223,32 @@ export function finalizePaneDragRelease(
336
223
  paneId: string,
337
224
  previewRect: FloatingRect,
338
225
  dockPreview: DragPreview | null,
226
+ mode: PaneDragMode = "floating",
339
227
  ): LayoutConfig {
228
+ // A floating stack moved by its title bar lands whole: its other tabs follow as tabs of the one moved.
229
+ const others = mode === "floating"
230
+ ? floatingStackMembers(layout.floating, paneId).map((entry) => entry.instanceId).filter((id) => id !== paneId)
231
+ : [];
340
232
  if (dockPreview?.kind === "dock") {
341
- return applyDrop(layout, paneId, dockPreview.target);
233
+ let next = applyDrop(layout, paneId, dockPreview.target);
234
+ for (const id of others) next = applyDrop(next, id, { kind: "tab", targetId: paneId });
235
+ return next;
342
236
  }
343
- if (dockPreview?.kind === "snap") {
344
- return floatAtRect(layout, paneId, dockPreview.rect);
237
+ if (dockPreview?.kind === "float") {
238
+ const { drop } = dockPreview;
239
+ if (drop.type === "tab") {
240
+ let next = layout;
241
+ for (const id of others) next = stackFloatingOnto(next, id, drop.targetId);
242
+ return stackFloatingOnto(next, paneId, drop.targetId);
243
+ }
244
+ let next = splitFloating(layout, paneId, drop.targetId, drop.side);
245
+ for (const id of others) next = stackFloatingOnto(next, id, paneId);
246
+ return next;
345
247
  }
346
- return floatAtRect(layout, paneId, previewRect);
347
- }
348
-
349
- export function makeSnapGuides(width: number, height: number): SnapGuide[] {
350
- const halfWidth = Math.max(1, Math.floor(width / 2));
351
- const halfHeight = Math.max(1, Math.floor(height / 2));
352
- const cornerWidth = Math.max(8, Math.min(16, Math.floor(width * 0.2)));
353
- const cornerHeight = Math.max(4, Math.min(8, Math.floor(height * 0.22)));
354
- const edgeWidth = Math.max(6, Math.min(10, Math.floor(width * 0.1)));
355
- const topBottomEdgeHeight = Math.max(2, Math.min(4, Math.floor(height * 0.1)));
356
-
357
- return [
358
- {
359
- position: "top-left",
360
- triggerRect: { x: 0, y: 0, width: cornerWidth, height: cornerHeight },
361
- previewRect: { x: 0, y: 0, width: halfWidth, height: halfHeight },
362
- },
363
- {
364
- position: "top-right",
365
- triggerRect: { x: Math.max(0, width - cornerWidth), y: 0, width: cornerWidth, height: cornerHeight },
366
- previewRect: { x: Math.max(0, width - halfWidth), y: 0, width: halfWidth, height: halfHeight },
367
- },
368
- {
369
- position: "bottom-left",
370
- triggerRect: { x: 0, y: Math.max(0, height - cornerHeight), width: cornerWidth, height: cornerHeight },
371
- previewRect: { x: 0, y: Math.max(0, height - halfHeight), width: halfWidth, height: halfHeight },
372
- },
373
- {
374
- position: "bottom-right",
375
- triggerRect: {
376
- x: Math.max(0, width - cornerWidth),
377
- y: Math.max(0, height - cornerHeight),
378
- width: cornerWidth,
379
- height: cornerHeight,
380
- },
381
- previewRect: {
382
- x: Math.max(0, width - halfWidth),
383
- y: Math.max(0, height - halfHeight),
384
- width: halfWidth,
385
- height: halfHeight,
386
- },
387
- },
388
- {
389
- position: "left",
390
- triggerRect: { x: 0, y: cornerHeight, width: edgeWidth, height: Math.max(1, height - (cornerHeight * 2)) },
391
- previewRect: { x: 0, y: 0, width: halfWidth, height },
392
- },
393
- {
394
- position: "right",
395
- triggerRect: {
396
- x: Math.max(0, width - edgeWidth),
397
- y: cornerHeight,
398
- width: edgeWidth,
399
- height: Math.max(1, height - (cornerHeight * 2)),
400
- },
401
- previewRect: { x: Math.max(0, width - halfWidth), y: 0, width: halfWidth, height },
402
- },
403
- {
404
- position: "top",
405
- triggerRect: { x: cornerWidth, y: 0, width: Math.max(1, width - (cornerWidth * 2)), height: topBottomEdgeHeight },
406
- previewRect: { x: 0, y: 0, width, height: halfHeight },
407
- },
408
- {
409
- position: "bottom",
410
- triggerRect: {
411
- x: cornerWidth,
412
- y: Math.max(0, height - topBottomEdgeHeight),
413
- width: Math.max(1, width - (cornerWidth * 2)),
414
- height: topBottomEdgeHeight,
415
- },
416
- previewRect: { x: 0, y: Math.max(0, height - halfHeight), width, height: halfHeight },
417
- },
418
- ];
419
- }
420
-
421
- export function resolveSnapGuide(x: number, y: number, guides: SnapGuide[]): SnapGuide | null {
422
- return guides.find((guide) => pointInRect(guide.triggerRect, x, y)) ?? null;
248
+ // Anywhere else it floats where it is drawn: a tab pulled out of a
249
+ // floating stack on its own, a stack moved by its title bar whole.
250
+ const from = mode === "tab" ? unstackFloating(layout, paneId) : layout;
251
+ return floatAtRect(from, paneId, previewRect);
423
252
  }
424
253
 
425
254
  export function resolveHeaderHitAreas(
@@ -2,7 +2,8 @@ import { startTransition, useCallback, useLayoutEffect, useRef, useState, useSyn
2
2
  import type { FloatingRect, LayoutBounds } from "../../../../layout/pane-manager";
3
3
  import type { BoxRenderable, LiveBoxFrame } from "../../../../ui";
4
4
  import type { DividerPreviewState } from "../native/window-state";
5
- import { sameRect, type DragPreview } from "./index";
5
+ import { sameRect, type DragPreview, type PaneDragMode } from "./index";
6
+ import type { DropZoneState } from "./drop-zones";
6
7
 
7
8
  /** Desktop divider drag: where the panes and dividers under the split are this frame. */
8
9
  export interface LiveDockGeometry {
@@ -19,16 +20,20 @@ export interface LiveDockGeometry {
19
20
  */
20
21
  export interface LiveDragGeometry {
21
22
  /** The pane being moved, from mouse down to release. */
22
- paneDrag: { paneId: string; mode: "docked" | "floating" } | null;
23
+ paneDrag: { paneId: string; mode: PaneDragMode } | null;
23
24
  /** The floating pane being resized, from mouse down to release. */
24
25
  paneResize: { paneId: string } | null;
25
26
  /** The floating rect being moved or resized, already kept inside the shell. */
26
27
  floating: { paneId: string; rect: FloatingRect } | null;
28
+ /** The floating windows a resize moves with it, snapped edge to edge with it, by pane. */
29
+ partners: ReadonlyMap<string, FloatingRect> | null;
27
30
  divider: DividerPreviewState | null;
28
31
  /** Desktop divider drag: the panes and dividers it resizes, where the pointer has them. */
29
32
  dock: LiveDockGeometry | null;
30
- /** Where the release would dock or snap. */
33
+ /** Where the release would land the pane, if anywhere but where it is drawn. */
31
34
  dockPreview: DragPreview | null;
35
+ /** The drop targets the pane on the move is over: what a release there does. */
36
+ zones: DropZoneState | null;
32
37
  }
33
38
 
34
39
  /**
@@ -56,9 +61,11 @@ export const IDLE_DRAG: LiveDragGeometry = {
56
61
  paneDrag: null,
57
62
  paneResize: null,
58
63
  floating: null,
64
+ partners: null,
59
65
  divider: null,
60
66
  dock: null,
61
67
  dockPreview: null,
68
+ zones: null,
62
69
  };
63
70
 
64
71
  export function createLiveDragStore(): LiveDragStore {