@opentui/core 0.7.0 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/NativeScene.d.ts +9 -3
  2. package/Renderable.d.ts +20 -2
  3. package/animation/Timeline.d.ts +9 -0
  4. package/buffer.d.ts +6 -2
  5. package/{chunk-bun-zevtbcf6.js → chunk-bun-6kxdhkdc.js} +407 -259
  6. package/chunk-bun-6kxdhkdc.js.map +70 -0
  7. package/{chunk-bun-qkpm62w1.js → chunk-bun-x6cz4jyg.js} +263 -21
  8. package/chunk-bun-x6cz4jyg.js.map +35 -0
  9. package/{chunk-node-7bcmqh18.js → chunk-node-q5ccgbk5.js} +407 -259
  10. package/{chunk-bun-zevtbcf6.js.map → chunk-node-q5ccgbk5.js.map} +15 -15
  11. package/{chunk-node-mzgnr3sw.js → chunk-node-y0w0hq5m.js} +263 -21
  12. package/chunk-node-y0w0hq5m.js.map +34 -0
  13. package/edit-buffer.d.ts +4 -0
  14. package/index.bun.js +788 -473
  15. package/index.bun.js.map +11 -10
  16. package/index.d.ts +1 -1
  17. package/index.node.js +788 -473
  18. package/index.node.js.map +11 -9
  19. package/lib/extmarks.d.ts +3 -1
  20. package/lib/stdin-parser-native.d.ts +2 -0
  21. package/lib/stdin-parser.d.ts +2 -0
  22. package/lib/terminal-capability-detection.d.ts +6 -1
  23. package/native-abi.generated.d.ts +307 -3
  24. package/package.json +9 -9
  25. package/renderables/FrameBuffer.d.ts +1 -0
  26. package/renderables/ScrollBar.d.ts +6 -0
  27. package/renderables/ScrollBox.d.ts +83 -43
  28. package/renderables/ScrollBoxParts.d.ts +165 -0
  29. package/renderables/index.d.ts +1 -1
  30. package/renderer-theme-mode.d.ts +1 -6
  31. package/renderer.d.ts +22 -3
  32. package/testing/test-renderer.d.ts +2 -0
  33. package/testing.bun.js +7 -6
  34. package/testing.bun.js.map +3 -3
  35. package/testing.js +7 -6
  36. package/testing.js.map +3 -3
  37. package/types.d.ts +11 -0
  38. package/yoga.bun.js +1 -1
  39. package/yoga.internal.d.ts +3 -3
  40. package/yoga.js +1 -1
  41. package/zig-structs.d.ts +1 -0
  42. package/zig.d.ts +78 -8
  43. package/chunk-bun-qkpm62w1.js.map +0 -35
  44. package/chunk-node-7bcmqh18.js.map +0 -70
  45. package/chunk-node-mzgnr3sw.js.map +0 -34
@@ -1,19 +1,14 @@
1
1
  import { type KeyEvent } from "../lib/index.js";
2
2
  import { type ScrollAcceleration } from "../lib/scroll-acceleration.js";
3
- import type { BaseRenderable, NativeRenderableIntegration, Renderable, RenderableOptions } from "../Renderable.js";
3
+ import type { NativeRenderableIntegration, Renderable } from "../Renderable.js";
4
4
  import type { MouseEvent } from "../renderer.js";
5
5
  import type { RenderContext } from "../types.js";
6
+ import type { NativeScene } from "../NativeScene.js";
7
+ import { type NativeSceneRect, type NativeSceneScrollState } from "../zig.js";
6
8
  import { BoxRenderable, type BoxOptions } from "./Box.js";
7
- import type { VNode } from "./composition/vnode.js";
8
- import { ScrollBarRenderable, type ScrollBarOptions, type ScrollUnit } from "./ScrollBar.js";
9
- export declare class ContentRenderable extends BoxRenderable {
10
- static readonly nativeIntegration: NativeRenderableIntegration;
11
- private viewport;
12
- private _viewportCulling;
13
- constructor(ctx: RenderContext, viewport: BoxRenderable, viewportCulling: boolean, options: RenderableOptions<BoxRenderable>);
14
- get viewportCulling(): boolean;
15
- set viewportCulling(value: boolean);
16
- }
9
+ import type { ScrollBarOptions, ScrollUnit } from "./ScrollBar.js";
10
+ import { ScrollBoxBar, ScrollBoxContent, ScrollBoxViewport, ScrollBoxWrapper, type SceneStyleNode } from "./ScrollBoxParts.js";
11
+ export { ScrollBoxBar, ScrollBoxContent, ScrollBoxViewport, ScrollBoxWrapper } from "./ScrollBoxParts.js";
17
12
  export interface ScrollBoxOptions extends BoxOptions<ScrollBoxRenderable> {
18
13
  rootOptions?: BoxOptions;
19
14
  wrapperOptions?: BoxOptions;
@@ -29,15 +24,16 @@ export interface ScrollBoxOptions extends BoxOptions<ScrollBoxRenderable> {
29
24
  scrollAcceleration?: ScrollAcceleration;
30
25
  viewportCulling?: boolean;
31
26
  }
27
+ /** A box whose scroll offset, range, sticky edge and scrollbars are native state of its scene node. The
28
+ * `wrapper`, `viewport`, `content` and scrollbar fields are facades over that state, not renderables; the
29
+ * box's children are the scrolled content. */
32
30
  export declare class ScrollBoxRenderable extends BoxRenderable {
33
31
  static readonly nativeIntegration: NativeRenderableIntegration;
34
- static idCounter: number;
35
- private internalId;
36
- readonly wrapper: BoxRenderable;
37
- readonly viewport: BoxRenderable;
38
- readonly content: ContentRenderable;
39
- readonly horizontalScrollBar: ScrollBarRenderable;
40
- readonly verticalScrollBar: ScrollBarRenderable;
32
+ readonly wrapper: ScrollBoxWrapper;
33
+ readonly viewport: ScrollBoxViewport;
34
+ readonly content: ScrollBoxContent;
35
+ readonly horizontalScrollBar: ScrollBoxBar;
36
+ readonly verticalScrollBar: ScrollBoxBar;
41
37
  protected static readonly defaultFocusable = true;
42
38
  private selectionListener?;
43
39
  private autoScrollMouseX;
@@ -54,49 +50,98 @@ export declare class ScrollBoxRenderable extends BoxRenderable {
54
50
  private scrollAccumulatorX;
55
51
  private scrollAccumulatorY;
56
52
  private _stickyScroll;
57
- private _stickyScrollTop;
58
- private _stickyScrollBottom;
59
- private _stickyScrollLeft;
60
- private _stickyScrollRight;
61
53
  private _stickyStart?;
62
- private _hasManualScroll;
63
- private _isApplyingStickyScroll;
64
54
  private scrollAccel;
55
+ private readonly axes;
56
+ private _viewportCulling;
57
+ private state;
58
+ private stateRevision?;
59
+ private scrollHook;
60
+ private configured;
61
+ private barPress?;
62
+ private layoutCallbacks;
63
+ private anchorToken?;
65
64
  get stickyScroll(): boolean;
66
65
  set stickyScroll(value: boolean);
67
66
  get stickyStart(): "bottom" | "top" | "left" | "right" | undefined;
68
67
  set stickyStart(value: "bottom" | "top" | "left" | "right" | undefined);
68
+ /** Native validates the options; a rejected write keeps the accepted values. */
69
+ private setScrollOption;
70
+ /** Whether the box scrolls sideways; on an axis that does not scroll, the content is at most as wide as the viewport. */
71
+ get scrollX(): boolean;
72
+ set scrollX(value: boolean);
73
+ get scrollY(): boolean;
74
+ set scrollY(value: boolean);
69
75
  get scrollTop(): number;
70
76
  set scrollTop(value: number);
71
77
  get scrollLeft(): number;
72
78
  set scrollLeft(value: number);
73
79
  get scrollWidth(): number;
74
80
  get scrollHeight(): number;
75
- private updateStickyState;
76
- private syncManualScrollState;
77
- private applyStickyStart;
78
81
  constructor(ctx: RenderContext, options: ScrollBoxOptions);
82
+ /** @internal */
83
+ _applyScrollOptions(): void;
84
+ /** @internal */
85
+ _applyScrollArrows(axis: number): void;
86
+ /** @internal Writes a style of the hidden content node. */
87
+ _setContentStyle(apply: (scene: NativeScene, node: SceneStyleNode) => void): void;
88
+ /** @internal The scroll state of the last prepared frame or explicit scroll. */
89
+ _scrollState(): NativeSceneScrollState;
90
+ /** @internal The box's inner rect without the vertical bar's gutter, as today's wrapper box. */
91
+ _wrapperRect(): NativeSceneRect;
92
+ /** @internal An explicit scroll on one axis; `"change"` reaches listeners at once. With `reapply` it applies again
93
+ * after the next frame's layout. */
94
+ _scrollAxis(axis: number, value: number, relative: boolean, reapply?: boolean): void;
95
+ private commitScroll;
96
+ /** `moved` holds bit 1 for x and bit 2 for y, as native's change bits. */
97
+ private notifyOffsets;
98
+ private listening;
99
+ /** @internal Ask for SCROLL requests only while a part has a listener; `adding` counts one about to be added.
100
+ * Native reports changes from the moment the request is turned on. */
101
+ _refreshScrollHook(adding?: boolean): void;
102
+ /** A SCROLL request: offsets first, as a sticky follow inside a resize hook did, then sizes, then the callbacks
103
+ * waiting for layout. */
104
+ private notifyScroll;
105
+ /** Runs `callback` once in the next frame, after its layout and before it paints: layout reads in it are current,
106
+ * and a scroll it makes shows in that frame. Asked during a frame, it runs in the frame after. It waits while the box
107
+ * is hidden; destroying the box drops it. */
108
+ afterLayout(callback: () => void): void;
109
+ /** Keeps `node`, a descendant, at its place in the viewport through layout changes, over sticky follow, until the
110
+ * returned function runs or the node leaves the box. A scroll moves the place it keeps; a scroll to the end or a later
111
+ * anchor ends it. Release takes effect at once: to keep the place through a change made just before, release in
112
+ * `afterLayout`. */
113
+ anchor(node: Renderable): () => void;
114
+ get primaryAxis(): "row" | "column";
79
115
  protected onUpdate(deltaTime: number): void;
80
116
  scrollBy(delta: number | {
81
117
  x: number;
82
118
  y: number;
83
119
  }, unit?: ScrollUnit): void;
84
- scrollChildIntoView(childId: string): void;
120
+ /** Scrolls a descendant (by id, or the node) into view now, and again after the next frame's layout. `"nearest"`
121
+ * moves the least; `"start"` and `"end"` put that edge of the node at the viewport's, `inset` cells inside. */
122
+ scrollChildIntoView(child: string | Renderable, options?: {
123
+ align?: "nearest" | "start" | "end";
124
+ inset?: number;
125
+ }): void;
126
+ /** Scrolls now, and again after the next frame's layout, so a position past the current range lands there once the
127
+ * content grows, and one at or past the end (`scrollHeight`, `Infinity`) stays at the end. */
85
128
  scrollTo(position: number | {
86
129
  x: number;
87
130
  y: number;
88
131
  }): void;
89
- private isAtStickyPosition;
90
- private isAtStickyReengagePoint;
91
- add(obj: Renderable | VNode<any, any[]>, index?: number): number;
92
- insertBefore(obj: Renderable | VNode<any, any[]> | unknown, anchor?: Renderable | unknown): number;
93
- remove(child: BaseRenderable): void;
94
- getChildren(): Renderable[];
95
- getRenderable(id: string): Renderable | undefined;
96
132
  /** Takes a wheel step when the box can still move that way. Acceleration and the fractional remainder belong to the
97
133
  * box that takes the step; a reversal or an edge clamp drops the remainder. */
98
134
  private scrollByWheel;
99
135
  protected onMouseEvent(event: MouseEvent): void;
136
+ /** Bar cells hit the box: a press on an arrow scrolls and repeats, one on the track jumps there, and a drag that
137
+ * started on the track or thumb moves the thumb with the pointer. */
138
+ private handleBarMouse;
139
+ private pressArrow;
140
+ /** Thumb geometry is in half cells along the track, as the native slider's. */
141
+ private thumbPointer;
142
+ private pressTrack;
143
+ private dragThumb;
144
+ private endBarPress;
100
145
  handleKeyPress(key: KeyEvent): boolean;
101
146
  private resetScrollAccumulators;
102
147
  startAutoScroll(mouseX: number, mouseY: number): void;
@@ -106,14 +151,6 @@ export declare class ScrollBoxRenderable extends BoxRenderable {
106
151
  private getAutoScrollDirectionX;
107
152
  private getAutoScrollDirectionY;
108
153
  private getAutoScrollSpeed;
109
- private recalculateBarProps;
110
- set padding(value: number | `${number}%` | null | undefined);
111
- set paddingX(value: number | `${number}%` | null | undefined);
112
- set paddingY(value: number | `${number}%` | null | undefined);
113
- set paddingTop(value: number | `${number}%` | null | undefined);
114
- set paddingRight(value: number | `${number}%` | null | undefined);
115
- set paddingBottom(value: number | `${number}%` | null | undefined);
116
- set paddingLeft(value: number | `${number}%` | null | undefined);
117
154
  set rootOptions(options: ScrollBoxOptions["rootOptions"]);
118
155
  set wrapperOptions(options: ScrollBoxOptions["wrapperOptions"]);
119
156
  set viewportOptions(options: ScrollBoxOptions["viewportOptions"]);
@@ -125,5 +162,8 @@ export declare class ScrollBoxRenderable extends BoxRenderable {
125
162
  set scrollAcceleration(value: ScrollAcceleration);
126
163
  get viewportCulling(): boolean;
127
164
  set viewportCulling(value: boolean);
165
+ get overflow(): "hidden";
166
+ /** The box clips like its viewport; other values are ignored. */
167
+ set overflow(_value: unknown);
128
168
  protected destroySelf(): void;
129
169
  }
@@ -0,0 +1,165 @@
1
+ import { EventEmitter } from "events";
2
+ import type { KeyEvent } from "../lib/KeyHandler.js";
3
+ import { RGBA, type ColorInput } from "../lib/RGBA.js";
4
+ import type { BaseRenderable, Renderable } from "../Renderable.js";
5
+ import type { NativeScene } from "../NativeScene.js";
6
+ import { type NativeSceneRect, type NativeSceneScrollBarOptions, type SceneNodeHandle } from "../zig.js";
7
+ import type { BoxOptions } from "./Box.js";
8
+ import type { VNode } from "./composition/vnode.js";
9
+ import { type ArrowOptions, type ScrollUnit } from "./ScrollBar.js";
10
+ import type { ScrollBoxRenderable } from "./ScrollBox.js";
11
+ export type SceneStyleNode = {
12
+ _getSceneHandle(owner: NativeScene): SceneNodeHandle;
13
+ };
14
+ /** A ScrollBox part: plain geometry and events over the box's native scroll state, not a renderable. */
15
+ declare abstract class ScrollBoxPart extends EventEmitter {
16
+ protected readonly box: ScrollBoxRenderable;
17
+ /** `event` is the notification this part emits, if any. */
18
+ constructor(box: ScrollBoxRenderable, event?: string);
19
+ protected abstract rect(): NativeSceneRect;
20
+ /** A part lives as long as its box. */
21
+ get isDestroyed(): boolean;
22
+ get x(): number;
23
+ get y(): number;
24
+ get screenX(): number;
25
+ get screenY(): number;
26
+ get width(): number;
27
+ get height(): number;
28
+ /** @internal Whether a listener needs the box's SCROLL request. */
29
+ abstract _listening(): boolean;
30
+ removeAllListeners(event?: string | symbol): this;
31
+ /** @internal Apply the option keys a part keeps, in order; the others are ignored. */
32
+ _assign(options: object | undefined, keys: readonly string[]): void;
33
+ }
34
+ /** A fill color, as `backgroundColor` on today's part boxes; transparent paints nothing. */
35
+ declare abstract class ScrollBoxFilledPart extends ScrollBoxPart {
36
+ private _backgroundColor?;
37
+ get backgroundColor(): RGBA;
38
+ set backgroundColor(value: ColorInput | null | undefined);
39
+ /** @internal */
40
+ _fill(): RGBA | undefined;
41
+ }
42
+ /** A part whose size changes reach `"resize"` listeners and `onSizeChange`. */
43
+ declare abstract class ScrollBoxSizedPart extends ScrollBoxFilledPart {
44
+ private _onSizeChange?;
45
+ constructor(box: ScrollBoxRenderable);
46
+ get onSizeChange(): (() => void) | undefined;
47
+ set onSizeChange(handler: (() => void) | null | undefined);
48
+ _listening(): boolean;
49
+ /** @internal */
50
+ _emitResize(): void;
51
+ }
52
+ /** The box's inner rect minus the vertical bar's gutter. */
53
+ export declare class ScrollBoxWrapper extends ScrollBoxFilledPart {
54
+ static readonly keys: readonly ["backgroundColor"];
55
+ _listening(): boolean;
56
+ protected rect(): NativeSceneRect;
57
+ }
58
+ /** The hidden viewport node: the culling window and the children's clip, with the viewport padding in cells. */
59
+ export declare class ScrollBoxViewport extends ScrollBoxSizedPart {
60
+ static readonly keys: string[];
61
+ private readonly paddings;
62
+ constructor(box: ScrollBoxRenderable);
63
+ protected rect(): NativeSceneRect;
64
+ private setPadding;
65
+ /** @internal Left, top, right, bottom, resolved like Yoga edges: an edge, then its axis, then all. */
66
+ _edges(): number[];
67
+ }
68
+ export interface ScrollBoxViewport {
69
+ padding: number | null | undefined;
70
+ paddingX: number | null | undefined;
71
+ paddingY: number | null | undefined;
72
+ get paddingLeft(): number;
73
+ set paddingLeft(value: number | null | undefined);
74
+ get paddingTop(): number;
75
+ set paddingTop(value: number | null | undefined);
76
+ get paddingRight(): number;
77
+ set paddingRight(value: number | null | undefined);
78
+ get paddingBottom(): number;
79
+ set paddingBottom(value: number | null | undefined);
80
+ }
81
+ /** The hidden content node: the box's children lay out in it, and it moves with the offset. */
82
+ export declare class ScrollBoxContent extends ScrollBoxSizedPart {
83
+ static readonly keys: string[];
84
+ private readonly styles;
85
+ constructor(box: ScrollBoxRenderable);
86
+ protected rect(): NativeSceneRect;
87
+ private setStyle;
88
+ /** @internal Whether children lay out in a row, by the direction native was given. */
89
+ get _row(): boolean;
90
+ get viewportCulling(): boolean;
91
+ set viewportCulling(value: boolean);
92
+ add(obj: Renderable | VNode<any, any[]>, index?: number): number;
93
+ insertBefore(obj: Renderable | VNode<any, any[]> | unknown, anchor?: Renderable | unknown): number;
94
+ remove(child: BaseRenderable): void;
95
+ getChildren(): Renderable[];
96
+ getChildrenCount(): number;
97
+ getRenderable(id: string): Renderable | undefined;
98
+ findDescendantById(id: string): Renderable | undefined;
99
+ }
100
+ /** A scrollbar: its track, thumb and arrows paint natively from the box's scroll state. */
101
+ export declare class ScrollBoxBar extends ScrollBoxPart {
102
+ static readonly keys: readonly ["visible", "showArrows", "arrowOptions", "trackOptions", "onChange", "width", "height", "paddingLeft", "paddingTop", "position", "scrollStep"];
103
+ readonly orientation: "vertical" | "horizontal";
104
+ scrollStep: number | undefined | null;
105
+ private readonly axis;
106
+ private policy;
107
+ private _showArrows;
108
+ private _arrowOptions;
109
+ private trackForeground;
110
+ private trackBackground;
111
+ private thickness;
112
+ private gap;
113
+ private overlay;
114
+ private _onChange?;
115
+ constructor(box: ScrollBoxRenderable, orientation: "vertical" | "horizontal");
116
+ protected rect(): NativeSceneRect;
117
+ _listening(): boolean;
118
+ /** @internal */
119
+ _native(): NativeSceneScrollBarOptions;
120
+ /** @internal The start and end arrows as native arrow options. */
121
+ _arrows(): {
122
+ attributes: number;
123
+ foregroundColor: RGBA;
124
+ backgroundColor: RGBA;
125
+ text?: string;
126
+ }[];
127
+ /** @internal */
128
+ _emitChange(position: number): void;
129
+ get visible(): boolean;
130
+ /** True and false hold the bar shown or hidden; a nullish write lets it follow the range again. */
131
+ set visible(value: boolean | null | undefined);
132
+ resetVisibilityControl(): void;
133
+ get onChange(): ((position: number) => void) | undefined;
134
+ set onChange(handler: ((position: number) => void) | null | undefined);
135
+ get showArrows(): boolean;
136
+ set showArrows(value: boolean | null | undefined);
137
+ set arrowOptions(options: Omit<ArrowOptions, "direction"> | null | undefined);
138
+ set trackOptions(options: {
139
+ foregroundColor?: ColorInput;
140
+ backgroundColor?: ColorInput;
141
+ } | null | undefined);
142
+ get width(): number;
143
+ set width(value: number | string | null | undefined);
144
+ get height(): number;
145
+ set height(value: number | string | null | undefined);
146
+ set paddingLeft(value: number | null | undefined);
147
+ set paddingTop(value: number | null | undefined);
148
+ /** An absolute bar overlays the content's edge instead of taking a gutter. */
149
+ set position(value: "absolute" | "relative" | null | undefined);
150
+ private setOption;
151
+ get scrollSize(): number;
152
+ get viewportSize(): number;
153
+ get scrollPosition(): number;
154
+ set scrollPosition(value: number);
155
+ scrollBy(delta: number, unit?: ScrollUnit): void;
156
+ handleKeyPress(key: KeyEvent): boolean;
157
+ }
158
+ type Edges = "" | "X" | "Y" | "Top" | "Right" | "Bottom" | "Left";
159
+ type ContentLayoutKey = "flexDirection" | "flexWrap" | "alignItems" | "justifyContent" | "alignSelf" | "flexGrow" | "flexShrink" | "flexBasis" | `${"min" | "max"}${"Width" | "Height"}` | `${"padding" | "margin"}${Edges}` | "gap" | "rowGap" | "columnGap";
160
+ export interface ScrollBoxContent extends ContentLayout {
161
+ }
162
+ type ContentLayout = {
163
+ [K in ContentLayoutKey]?: BoxOptions[K] | null;
164
+ };
165
+ export {};
@@ -13,7 +13,7 @@ export * from "./Image.js";
13
13
  export * from "./LineNumberRenderable.js";
14
14
  export * from "./Markdown.js";
15
15
  export * from "./ScrollBar.js";
16
- export { ScrollBoxRenderable, type ScrollBoxOptions } from "./ScrollBox.js";
16
+ export { ScrollBoxRenderable, ScrollBoxBar, ScrollBoxContent, ScrollBoxViewport, ScrollBoxWrapper, type ScrollBoxOptions, } from "./ScrollBox.js";
17
17
  export * from "./Select.js";
18
18
  export * from "./Slider.js";
19
19
  export * from "./TextTable.js";
@@ -8,22 +8,17 @@ export declare class RendererThemeMode {
8
8
  private readonly clock;
9
9
  private static readonly QUERY_TIMEOUT_MS;
10
10
  private _themeMode;
11
- private themeQueryPending;
12
- private themeOscForeground;
13
- private themeOscBackground;
14
11
  private themeRefreshTimeoutId;
15
12
  private waiters;
16
13
  constructor(host: RendererThemeModeHost, clock: Clock);
17
14
  get themeMode(): ThemeMode | null;
18
15
  waitForThemeMode(timeoutMs: number, isDestroyed: boolean): Promise<ThemeMode | null>;
19
- cancelRefresh(): void;
20
16
  dispose(): void;
21
17
  handleSequence(sequence: string): {
22
18
  handled: boolean;
23
19
  changedMode: ThemeMode | null;
24
20
  };
25
- private clearThemeRefreshTimeout;
26
- private completeThemeQuery;
21
+ cancelRefresh(): void;
27
22
  private requestThemeOscColors;
28
23
  private applyThemeMode;
29
24
  }
package/renderer.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import { Renderable, RootRenderable } from "./Renderable.js";
2
- import { DebugOverlayCorner, type CursorStyleOptions, type MousePointerStyle, type ProgramStatus, type RenderContext, type TerminalCapabilities, type ThemeMode, type SelectionBehavior, type WidthMethod } from "./types.js";
2
+ import { DebugOverlayCorner, type AnimationTickCallback, type AnimationTickOptions, type CursorStyleOptions, type MousePointerStyle, type ProgramStatus, type RenderContext, type TerminalCapabilities, type ThemeMode, type SelectionBehavior, type WidthMethod } from "./types.js";
3
3
  import { RGBA, type ColorInput } from "./lib/RGBA.js";
4
4
  import { OptimizedBuffer } from "./buffer.js";
5
- import { type NativeBufferedOutput, type NativeRenderStats } from "./zig.js";
5
+ import { type NativeBufferedOutput, type NativeRenderStats, type SynchronizedOutput } from "./zig.js";
6
6
  import { NativeSession } from "./NativeSession.js";
7
7
  import { NativeScene } from "./NativeScene.js";
8
8
  import { TerminalConsole, type ConsoleOptions } from "./console.js";
@@ -31,6 +31,7 @@ export interface CliRendererConfig {
31
31
  width?: number;
32
32
  height?: number;
33
33
  remote?: boolean;
34
+ synchronizedOutput?: SynchronizedOutput;
34
35
  kittyImageTransport?: KittyImageTransport;
35
36
  bufferedOutput?: NativeBufferedOutput;
36
37
  exitOnCtrlC?: boolean;
@@ -242,6 +243,7 @@ export declare class CliRenderer extends EventEmitter implements RenderContext {
242
243
  private nativeResizeWait;
243
244
  private nativeKittyKeyboardFlags;
244
245
  private kittyTransportMode;
246
+ private readonly synchronizedOutput?;
245
247
  private kittyTransportTimer;
246
248
  private _lastSceneTimeMs;
247
249
  get lastSceneTimeMs(): number;
@@ -277,6 +279,9 @@ export declare class CliRenderer extends EventEmitter implements RenderContext {
277
279
  private backgroundColor;
278
280
  private waitingForPixelResolution;
279
281
  private pixelResolutionRequeryPending;
282
+ private unansweredPixelQueries;
283
+ private replyBatches;
284
+ private replySentinel;
280
285
  readonly clock: Clock;
281
286
  private rendering;
282
287
  private renderingCompletion;
@@ -290,6 +295,8 @@ export declare class CliRenderer extends EventEmitter implements RenderContext {
290
295
  private minTargetFrameTime;
291
296
  private immediateRerenderRequested;
292
297
  private liveRequestCounter;
298
+ private animationTickers;
299
+ private animationTimer;
293
300
  private _controlState;
294
301
  private frameCallbacks;
295
302
  private renderStats;
@@ -309,7 +316,6 @@ export declare class CliRenderer extends EventEmitter implements RenderContext {
309
316
  private cancelReadyFrame;
310
317
  private resizeTimeoutId;
311
318
  private pendingResizeSawDifferentSize;
312
- private capabilityTimeoutId;
313
319
  private terminalKeepAliveTimer;
314
320
  private xtVersionWaiters;
315
321
  private splitStartupSeedTimeoutId;
@@ -518,6 +524,13 @@ export declare class CliRenderer extends EventEmitter implements RenderContext {
518
524
  enableKittyKeyboard(flags?: number): void;
519
525
  disableKittyKeyboard(): void;
520
526
  setupTerminal(): Promise<void>;
527
+ private get startupRepliesPending();
528
+ /** Call when the Session has accepted the batch's packet. */
529
+ private admitReplyBatch;
530
+ /** Call once the batch's output has drained, so output backpressure cannot cause a miss. */
531
+ private armReplyBackstop;
532
+ private endReplyBatch;
533
+ private syncReplyContext;
521
534
  private trackNativeTerminalTransition;
522
535
  private stdinListener;
523
536
  addInputHandler(handler: (sequence: string) => boolean): void;
@@ -605,6 +618,12 @@ export declare class CliRenderer extends EventEmitter implements RenderContext {
605
618
  private get canRender();
606
619
  requestAnimationFrame(callback: FrameRequestCallback): number;
607
620
  cancelAnimationFrame(handle: number): void;
621
+ /** Calls `callback` `fps` times a second on a clock that all subscribers share. Due times are multiples of
622
+ * 1000 / fps, so equal rates tick together; one timer requests a frame at the earliest due time, and every frame,
623
+ * whatever its cause, runs each tick that is due within its tolerance. Returns the unsubscribe function. */
624
+ onAnimationTick(fps: number, callback: AnimationTickCallback, options?: AnimationTickOptions): () => void;
625
+ private scheduleAnimationTick;
626
+ private runAnimationTicks;
608
627
  private yieldFrame;
609
628
  private queueFrame;
610
629
  requestLive(): void;
@@ -10,6 +10,8 @@ export interface TestRendererOptions extends CliRendererConfig {
10
10
  otherModifiersMode?: boolean;
11
11
  /** Every frame rebuilds its native preparation and paint lists instead of reusing the last frame's (`OT_SCENE_DEBUG_FULL_FRAME`). Output is unchanged. */
12
12
  nativeSceneFullFrame?: boolean;
13
+ /** Each frame that retained paint skips or repaints partly is checked against the presented frame and against a full repaint into a scratch buffer (`OT_SCENE_DEBUG_VERIFY`); a mismatch throws. Captures do not disturb retention. On by default. */
14
+ nativeSceneVerify?: boolean;
13
15
  }
14
16
  export type TestRenderer = CliRenderer;
15
17
  export type MockInput = ReturnType<typeof createMockKeys>;
package/testing.bun.js CHANGED
@@ -4,10 +4,10 @@ import {
4
4
  TreeSitterClient2,
5
5
  ANSI,
6
6
  CliRenderer2
7
- } from "./chunk-bun-zevtbcf6.js";
7
+ } from "./chunk-bun-6kxdhkdc.js";
8
8
  import {
9
9
  nativeConstants
10
- } from "./chunk-bun-qkpm62w1.js";
10
+ } from "./chunk-bun-x6cz4jyg.js";
11
11
 
12
12
  // src/testing/mock-keys.ts
13
13
  import { Buffer as Buffer2 } from "buffer";
@@ -580,7 +580,7 @@ function waitForNextFrameOrIdle(renderer) {
580
580
  }
581
581
  async function createTestRenderer(options) {
582
582
  const useKittyKeyboard = options.kittyKeyboard ? { events: true } : options.useKittyKeyboard;
583
- const { nativeSceneFullFrame, ...rendererOptions } = options;
583
+ const { nativeSceneFullFrame, nativeSceneVerify = true, ...rendererOptions } = options;
584
584
  const renderer = await setupTestRenderer({
585
585
  ...rendererOptions,
586
586
  useKittyKeyboard,
@@ -589,9 +589,10 @@ async function createTestRenderer(options) {
589
589
  consoleMode: options.consoleMode ?? "disabled",
590
590
  externalOutputMode: options.externalOutputMode ?? "passthrough"
591
591
  });
592
- if (nativeSceneFullFrame) {
592
+ const debugFlags = (nativeSceneFullFrame ? nativeConstants.OT_SCENE_DEBUG_FULL_FRAME : 0) | (nativeSceneVerify ? nativeConstants.OT_SCENE_DEBUG_VERIFY : 0);
593
+ if (debugFlags !== 0) {
593
594
  const session = renderer["nativeSession"];
594
- renderer["lib"].sceneSetDebugFlags(session.context, session.session, nativeConstants.OT_SCENE_DEBUG_FULL_FRAME);
595
+ renderer["lib"].sceneSetDebugFlags(session.context, session.session, debugFlags);
595
596
  }
596
597
  const externalOutput = new TestExternalOutputRecorder(renderer);
597
598
  const mockInput = createMockKeys(renderer, {
@@ -1021,5 +1022,5 @@ export {
1021
1022
  setRendererCapabilities
1022
1023
  };
1023
1024
 
1024
- //# debugId=4DB770C05E8D36D564756E2164756E21
1025
+ //# debugId=B9DEB437B63DC16764756E2164756E21
1025
1026
  //# sourceMappingURL=testing.bun.js.map