pi-stereo-view 0.1.24 → 0.1.25
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/CHANGELOG.md +6 -0
- package/package.json +1 -1
- package/src/mouse-dispatch.ts +20 -0
- package/src/native.ts +11 -6
- package/src/surface.ts +3 -9
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
+
## 0.1.25 - 2026-11-23
|
|
6
|
+
|
|
7
|
+
### Fixed
|
|
8
|
+
|
|
9
|
+
- Clicking or dragging in split history on Pi-Bolt no longer turns off split view with `this.ownChildren is not a function`. Thanks to [@Unk-now](https://github.com/Unk-now) for the report ([#133](https://github.com/alexshpunt/pi-stereo-view/issues/133)).
|
|
10
|
+
|
|
5
11
|
## 0.1.24 - 2026-11-22
|
|
6
12
|
|
|
7
13
|
### Added
|
package/package.json
CHANGED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Component, Container, TuiMouseEvent } from "@earendil-works/pi-tui";
|
|
2
|
+
|
|
3
|
+
export type Dispatched = NonNullable<ReturnType<Container["handleMouse"]>>;
|
|
4
|
+
|
|
5
|
+
/** Forward a local event to a real component, preserving Pi's capture and focus targets. */
|
|
6
|
+
export function dispatchMouseEvent(component: Component, event: TuiMouseEvent): Dispatched | undefined {
|
|
7
|
+
const result = component.handleMouse?.(event);
|
|
8
|
+
if (!result) return undefined;
|
|
9
|
+
if ("target" in result) {
|
|
10
|
+
const forwarded = result as Dispatched;
|
|
11
|
+
return forwarded.focus && component.handleInput ? { ...forwarded, focusTarget: component } : forwarded;
|
|
12
|
+
}
|
|
13
|
+
if (!result.handled && !result.capture && !result.focus) return undefined;
|
|
14
|
+
return {
|
|
15
|
+
...result, handled: true, ...(result.focus ? { focusTarget: component } : {}),
|
|
16
|
+
target: {
|
|
17
|
+
component, originX: event.screenX - event.x, originY: event.screenY - event.y, width: event.width, height: event.height,
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
}
|
package/src/native.ts
CHANGED
|
@@ -13,6 +13,7 @@ import { NestedTree, type NativeTreeBody } from "./nested-tree.ts";
|
|
|
13
13
|
import { pushShellInputs, sameValues } from "./render-cache.ts";
|
|
14
14
|
import { decorateLine, decorateLines, type TurnColor, type TurnLayers, type TurnMix } from "./turns.ts";
|
|
15
15
|
import type { TurnStripe, GoTo } from "./preferences.ts";
|
|
16
|
+
import { dispatchMouseEvent } from "./mouse-dispatch.ts";
|
|
16
17
|
export type { Pane } from "./content.ts";
|
|
17
18
|
|
|
18
19
|
/** Turn marks, hover and Go to, shared by both panels through the split layout. */
|
|
@@ -387,7 +388,7 @@ export class NativeDocument extends Container {
|
|
|
387
388
|
if (event.x < this.inset && event.type !== "move") return undefined;
|
|
388
389
|
event = { ...event, x: event.x - this.inset, width: Math.max(0, event.width - this.inset) };
|
|
389
390
|
}
|
|
390
|
-
// Find the entry under the pointer
|
|
391
|
+
// Find the painted entry under the pointer without asking Pi to lay it out again.
|
|
391
392
|
let low = 0;
|
|
392
393
|
let high = built.order.length - 1;
|
|
393
394
|
while (low < high) {
|
|
@@ -403,11 +404,15 @@ export class NativeDocument extends Container {
|
|
|
403
404
|
this.turns?.hover(turn);
|
|
404
405
|
}
|
|
405
406
|
if (!segment || segment.estimate || row >= segment.lines.length) return undefined;
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
407
|
+
let childY = 0;
|
|
408
|
+
for (let index = 0; index < segment.components.length; index++) {
|
|
409
|
+
const height = segment.heights[index];
|
|
410
|
+
if (row < childY + height) {
|
|
411
|
+
return dispatchMouseEvent(segment.components[index], { ...event, y: row - childY, height });
|
|
412
|
+
}
|
|
413
|
+
childY += height;
|
|
414
|
+
}
|
|
415
|
+
return undefined;
|
|
411
416
|
}
|
|
412
417
|
/**
|
|
413
418
|
* The turn color behind a block's clock, when clock marks are on. Blocks render inside this document's render, so the turns it
|
package/src/surface.ts
CHANGED
|
@@ -2,6 +2,7 @@ import {
|
|
|
2
2
|
Container, CURSOR_MARKER, getOsc8LinkAtColumn, ScrollView, sliceByColumn, stripTerminalSequences, truncateToWidth, visibleWidth,
|
|
3
3
|
type Component, type TUI, type TuiMouseEvent, type TuiMouseEventResult,
|
|
4
4
|
} from "@earendil-works/pi-tui";
|
|
5
|
+
import { dispatchMouseEvent, type Dispatched } from "./mouse-dispatch.ts";
|
|
5
6
|
|
|
6
7
|
// Pi exports stacks and scroll views but not its layout engine. Stacks describe themselves through this symbol.
|
|
7
8
|
const LAYOUT_NODE = Symbol.for("@earendil-works/pi-tui/layout-node");
|
|
@@ -33,7 +34,6 @@ interface Geometry { column: number; trackTop: number; trackHeight: number; thum
|
|
|
33
34
|
interface Frame { width: number; height: number; root: Box; lines: string[]; scrolls: Map<ScrollView, Box>; indicator?: { row: number; column: number; width: number } }
|
|
34
35
|
interface Point { row: number; col: number; view: ScrollView; boundary?: boolean }
|
|
35
36
|
interface Range { start: Point; end: Point }
|
|
36
|
-
type Dispatched = TuiMouseEventResult & { handled: true; target: { component: Component; originX: number; originY: number; width: number; height: number }; focusTarget?: Component };
|
|
37
37
|
/** Read-only and opaque scroll-follow hooks offered by projected documents. */
|
|
38
38
|
interface ScrollContent { takeScrollShift?(): number }
|
|
39
39
|
|
|
@@ -495,14 +495,8 @@ export class SplitSurface extends Container {
|
|
|
495
495
|
if (layoutNode(component) && component.handleMouse === Container.prototype.handleMouse) continue;
|
|
496
496
|
visited.add(component);
|
|
497
497
|
const local = { ...event, x: event.x - box.rect.x, y: event.y - box.rect.y, width: box.rect.width, height: box.rect.height };
|
|
498
|
-
const result = component
|
|
499
|
-
if (
|
|
500
|
-
if (result.target) return result as Dispatched;
|
|
501
|
-
if (!result.handled && !result.capture && !result.focus) continue;
|
|
502
|
-
return {
|
|
503
|
-
...result, handled: true, ...(result.focus ? { focusTarget: component } : {}),
|
|
504
|
-
target: { component, originX: event.screenX - local.x, originY: event.screenY - local.y, width: local.width, height: local.height },
|
|
505
|
-
};
|
|
498
|
+
const result = dispatchMouseEvent(component, local);
|
|
499
|
+
if (result) return result;
|
|
506
500
|
}
|
|
507
501
|
return undefined;
|
|
508
502
|
}
|