@opentui/core 0.7.0 → 0.8.1
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/NativeScene.d.ts +18 -4
- package/NativeSession.d.ts +22 -2
- package/Renderable.d.ts +20 -2
- package/animation/Timeline.d.ts +9 -0
- package/buffer.d.ts +8 -2
- package/{chunk-bun-zevtbcf6.js → chunk-bun-ved2tpxm.js} +834 -320
- package/chunk-bun-ved2tpxm.js.map +70 -0
- package/{chunk-bun-qkpm62w1.js → chunk-bun-wdetc10w.js} +483 -29
- package/chunk-bun-wdetc10w.js.map +35 -0
- package/{chunk-node-mzgnr3sw.js → chunk-node-m8mjyx7h.js} +483 -29
- package/chunk-node-m8mjyx7h.js.map +34 -0
- package/{chunk-node-7bcmqh18.js → chunk-node-tpjmjvn7.js} +834 -320
- package/chunk-node-tpjmjvn7.js.map +70 -0
- package/edit-buffer.d.ts +4 -0
- package/index.bun.js +1453 -859
- package/index.bun.js.map +15 -13
- package/index.d.ts +1 -1
- package/index.node.js +1453 -859
- package/index.node.js.map +16 -12
- package/lib/extmarks.d.ts +3 -1
- package/lib/stdin-parser-native.d.ts +2 -0
- package/lib/stdin-parser.d.ts +2 -0
- package/lib/terminal-capability-detection.d.ts +6 -1
- package/native-abi.generated.d.ts +478 -6
- package/package.json +9 -9
- package/renderables/FrameBuffer.d.ts +1 -0
- package/renderables/Image.d.ts +13 -1
- package/renderables/LineNumberRenderable.d.ts +1 -1
- package/renderables/Markdown.d.ts +1 -1
- package/renderables/ScrollBar.d.ts +6 -0
- package/renderables/ScrollBox.d.ts +84 -44
- package/renderables/ScrollBoxParts.d.ts +165 -0
- package/renderables/Select.d.ts +0 -2
- package/renderables/TabSelect.d.ts +0 -3
- package/renderables/TextTable.d.ts +1 -8
- package/renderables/Video.d.ts +126 -0
- package/renderables/index.d.ts +2 -1
- package/renderer-theme-mode.d.ts +1 -6
- package/renderer.d.ts +44 -5
- package/testing/test-renderer.d.ts +2 -0
- package/testing.bun.js +7 -6
- package/testing.bun.js.map +3 -3
- package/testing.js +7 -6
- package/testing.js.map +3 -3
- package/types.d.ts +11 -0
- package/yoga.bun.js +1 -1
- package/yoga.internal.d.ts +3 -3
- package/yoga.js +1 -1
- package/zig-structs.d.ts +1 -0
- package/zig.d.ts +132 -10
- package/chunk-bun-qkpm62w1.js.map +0 -35
- package/chunk-bun-zevtbcf6.js.map +0 -70
- package/chunk-node-7bcmqh18.js.map +0 -70
- package/chunk-node-mzgnr3sw.js.map +0 -34
package/NativeScene.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { NativeSession } from "./NativeSession.js";
|
|
2
2
|
import type { Renderable, RenderableOptions } from "./Renderable.js";
|
|
3
3
|
import type { ImageFit } from "./renderables/Image.js";
|
|
4
|
-
import type { NativeImage } from "./image.js";
|
|
4
|
+
import type { ExtractOptions, NativeImage } from "./image.js";
|
|
5
5
|
import { OptimizedBuffer } from "./buffer.js";
|
|
6
6
|
import type { ImageRenderProtocol } from "./types.js";
|
|
7
7
|
import { type CliRenderer } from "./renderer.js";
|
|
@@ -9,7 +9,7 @@ import type { StyledText } from "./lib/styled-text.js";
|
|
|
9
9
|
import type { RGBA } from "./lib/RGBA.js";
|
|
10
10
|
import type { LocalSelectionBounds } from "./lib/selection.js";
|
|
11
11
|
import { type Value, type MeasureFunction } from "./yoga.js";
|
|
12
|
-
import { NativeSessionRenderStatus, type NativeSceneFrameOptions, type NativeSceneFrameRequest, type NativeSceneLayout, type NativeScenePaint, type NativeScenePaintUpdate, type NativeSceneBoxDetails, type NativeSceneTextOptions, type NativeSceneSliderOptions, type NativeSceneArrowOptions, type NativeSceneEditorOptions, type ContextEditorViewHandle, type ContextTextBufferViewHandle, type SceneNodeHandle } from "./zig.js";
|
|
12
|
+
import { NativeSessionRenderStatus, type NativeSceneFrameOptions, type NativeSceneFrameRequest, type NativeSceneLayout, type NativeScenePaint, type NativeScenePaintUpdate, type NativeSceneBoxDetails, type NativeSceneTextOptions, type NativeSceneSliderOptions, type NativeSceneArrowOptions, type NativeSceneScrollOptions, type NativeSceneScrollState, type NativeSceneEditorOptions, type ContextEditorViewHandle, type ContextTextBufferViewHandle, type SceneNodeHandle, type NativeContextHandle, type RenderLib } from "./zig.js";
|
|
13
13
|
type PaintOptions = () => Pick<NativeSceneFrameOptions, "background" | "useMouse" | "excludedHitNum" | "preserveUnwritten">;
|
|
14
14
|
declare class NativeLifecyclePasses extends Set<Renderable> {
|
|
15
15
|
private order;
|
|
@@ -119,6 +119,20 @@ export declare class NativeScene {
|
|
|
119
119
|
/** @internal Standard arrow paint commits before its wrapper projection. */
|
|
120
120
|
setArrow(renderable: Renderable, options: NativeSceneArrowOptions): void;
|
|
121
121
|
setImage(renderable: Renderable, image: NativeImage | null, fit: ImageFit, protocol: ImageRenderProtocol, buffer: OptimizedBuffer | null): void;
|
|
122
|
+
setVideo(renderable: Renderable, fit: ImageFit, buffer: OptimizedBuffer | null): void;
|
|
123
|
+
setCrop(renderable: Renderable, crop: ExtractOptions | undefined): void;
|
|
124
|
+
/** @internal Video control and state calls address the node after staged writes. */
|
|
125
|
+
videoNode(renderable: Renderable): {
|
|
126
|
+
lib: RenderLib;
|
|
127
|
+
context: NativeContextHandle;
|
|
128
|
+
node: SceneNodeHandle;
|
|
129
|
+
};
|
|
130
|
+
/** @internal A scroll write moves the box's children, so it bumps the layout revision like a frame step. */
|
|
131
|
+
setScroll(renderable: Renderable, options: NativeSceneScrollOptions): void;
|
|
132
|
+
setScrollArrow(renderable: Renderable, axis: number, end: number, options: Omit<NativeSceneArrowOptions, "direction">): void;
|
|
133
|
+
scrollTo(renderable: Renderable, x: number, y: number, relativeX: boolean, relativeY: boolean, reapply?: boolean): NativeSceneScrollState;
|
|
134
|
+
scrollRequest(renderable: Renderable, kind: "into-view" | "anchor" | "layout", target: Renderable | null, align?: "nearest" | "start" | "end", inset?: number): NativeSceneScrollState;
|
|
135
|
+
getScroll(renderable: Renderable): NativeSceneScrollState;
|
|
122
136
|
setEditorView(renderable: Renderable, view: ContextEditorViewHandle): void;
|
|
123
137
|
setSurface(renderable: Renderable, buffer: OptimizedBuffer | null): void;
|
|
124
138
|
setTextView(renderable: Renderable, view: ContextTextBufferViewHandle | null): void;
|
|
@@ -126,8 +140,8 @@ export declare class NativeScene {
|
|
|
126
140
|
setEditorOptions(renderable: Renderable, options: NativeSceneEditorOptions): void;
|
|
127
141
|
/** @internal Query native text metrics only when requested, never during JS frame traversal. */
|
|
128
142
|
getText(renderable: Renderable): string;
|
|
129
|
-
/** @internal Inherited Text drawing records or draws at the caller's position. */
|
|
130
|
-
|
|
143
|
+
/** @internal Inherited Text and Box drawing records or draws the native body at the caller's position. */
|
|
144
|
+
drawBody(renderable: Renderable, buffer: OptimizedBuffer, x: number, y: number): void;
|
|
131
145
|
setTextSelection(renderable: Renderable, operation: "set" | "update" | "reset", bounds: LocalSelectionBounds | null, bg?: RGBA, fg?: RGBA): boolean;
|
|
132
146
|
getTextSelection(renderable: Renderable): {
|
|
133
147
|
start: number;
|
package/NativeSession.d.ts
CHANGED
|
@@ -13,7 +13,9 @@ export interface NativeSessionDriverOptions {
|
|
|
13
13
|
output?: NativeSessionOptions;
|
|
14
14
|
/** Copy-buffer size for custom Writable destinations. Native stdout needs no buffer. */
|
|
15
15
|
outputBufferSize?: number;
|
|
16
|
-
/**
|
|
16
|
+
/** Graceful close drops the queued output, restores and rejects as late once this long passes without written
|
|
17
|
+
* bytes and no write in progress, or ten times this long in all; a write in progress finishes first. Another
|
|
18
|
+
* interval without written bytes then cancels it unrestored. */
|
|
17
19
|
closeTimeoutMs?: number;
|
|
18
20
|
scheduler?: NativeSessionScheduler;
|
|
19
21
|
}
|
|
@@ -42,13 +44,21 @@ export declare class NativeSession {
|
|
|
42
44
|
private readonly closeWait;
|
|
43
45
|
private idleWait;
|
|
44
46
|
private presentationWait;
|
|
47
|
+
/** @internal Image uploads that later frames still send, read when the last waited frame presented. */
|
|
48
|
+
imageUploadsPending: number;
|
|
45
49
|
private transition;
|
|
46
50
|
private scheduled;
|
|
47
51
|
private output;
|
|
52
|
+
/** The stdout writer's copy in flight: when it started, and how many polls found it busy. */
|
|
53
|
+
private stdoutPost;
|
|
54
|
+
/** fd 1 output goes through the native writer thread until it reports unsupported. */
|
|
55
|
+
private stdoutWriter;
|
|
48
56
|
private blocked;
|
|
49
57
|
private sinkErrorSeen;
|
|
50
58
|
private detached;
|
|
51
59
|
private closeDeadlineNs;
|
|
60
|
+
private closeCapNs;
|
|
61
|
+
private closeLate;
|
|
52
62
|
private closeRequested;
|
|
53
63
|
private closeInterruption;
|
|
54
64
|
private stopped;
|
|
@@ -67,6 +77,8 @@ export declare class NativeSession {
|
|
|
67
77
|
get disposed(): boolean;
|
|
68
78
|
get contextDisposed(): boolean;
|
|
69
79
|
get error(): Error | null;
|
|
80
|
+
/** The Session takes native work: it has not failed and is not closing or exiting. */
|
|
81
|
+
get open(): boolean;
|
|
70
82
|
usesOutput(sink: Writable): boolean;
|
|
71
83
|
/** The optional attachment cleanup is installed only after checked native acceptance. */
|
|
72
84
|
attachRenderer(options: NativeSessionRendererOptions, beforeDispose?: () => void): void;
|
|
@@ -108,7 +120,7 @@ export declare class NativeSession {
|
|
|
108
120
|
close(): Promise<void>;
|
|
109
121
|
/** @internal Bound required snapshot flushing by the same graceful-close deadline. */
|
|
110
122
|
armCloseTimeout(): void;
|
|
111
|
-
/** Identifies this driver's close interruption, not transport or restoration success. */
|
|
123
|
+
/** Identifies this driver's close interruption or late close, not transport or restoration success. */
|
|
112
124
|
isCloseInterruption(error: unknown): boolean;
|
|
113
125
|
/**
|
|
114
126
|
* Cancels immediately without claiming restoration. Release external Context
|
|
@@ -120,6 +132,9 @@ export declare class NativeSession {
|
|
|
120
132
|
* Only real stdout supports direct synchronous delivery. In-flight writes cannot
|
|
121
133
|
* be replayed, and arbitrary borrowed sinks cannot finish asynchronously at exit. */
|
|
122
134
|
restoreOnExit(): boolean;
|
|
135
|
+
/** One exit copy through the writer. False: no writer, or it never picked the copy up and
|
|
136
|
+
* gave it back; the synchronous drain takes over. */
|
|
137
|
+
private exitThroughWriter;
|
|
123
138
|
private checkOpen;
|
|
124
139
|
private changeTerminal;
|
|
125
140
|
private onError;
|
|
@@ -129,6 +144,11 @@ export declare class NativeSession {
|
|
|
129
144
|
private schedule;
|
|
130
145
|
private turn;
|
|
131
146
|
private writeOutput;
|
|
147
|
+
/** Collects the writer's finished copy and, when `start`, hands over the next. */
|
|
148
|
+
private postStdout;
|
|
149
|
+
/** The next poll of a copy in flight: the next turn (0n) for its first 64 polls within 0.5 ms, then an eighth of
|
|
150
|
+
* its age, from 1 to 50 ms. */
|
|
151
|
+
private pollDeadline;
|
|
132
152
|
private writeSink;
|
|
133
153
|
private completePresentation;
|
|
134
154
|
private detach;
|
package/Renderable.d.ts
CHANGED
|
@@ -71,6 +71,8 @@ export interface RenderableOptions<T extends BaseRenderable = BaseRenderable> ex
|
|
|
71
71
|
visible?: boolean;
|
|
72
72
|
buffered?: boolean;
|
|
73
73
|
live?: boolean;
|
|
74
|
+
/** Ticks `onAnimationTick` at this rate on the renderer's shared animation clock while the node is visible. */
|
|
75
|
+
animationFps?: number;
|
|
74
76
|
opacity?: number;
|
|
75
77
|
renderBefore?: (this: T, buffer: OptimizedBuffer, deltaTime: number) => void;
|
|
76
78
|
renderAfter?: (this: T, buffer: OptimizedBuffer, deltaTime: number) => void;
|
|
@@ -104,6 +106,11 @@ export interface NativeRenderableIntegration {
|
|
|
104
106
|
readonly idle: (deltaTime: number) => void;
|
|
105
107
|
readonly active: (renderable: Renderable) => boolean;
|
|
106
108
|
};
|
|
109
|
+
/** A scroll node's SCROLL request, asked for only while `active` holds. */
|
|
110
|
+
readonly scroll?: {
|
|
111
|
+
readonly active: (renderable: Renderable) => boolean;
|
|
112
|
+
readonly notify: (renderable: Renderable) => void;
|
|
113
|
+
};
|
|
107
114
|
};
|
|
108
115
|
readonly beforeAfter?: boolean;
|
|
109
116
|
readonly paintBuffer?: "destination";
|
|
@@ -166,10 +173,12 @@ export declare abstract class Renderable extends BaseRenderable {
|
|
|
166
173
|
protected frameBuffer: OptimizedBuffer | null;
|
|
167
174
|
protected _focusable: boolean;
|
|
168
175
|
protected _focused: boolean;
|
|
169
|
-
protected _hasFocusedDescendant: boolean;
|
|
170
176
|
protected keypressHandler: ((key: KeyEvent) => void) | null;
|
|
171
177
|
protected pasteHandler: ((event: PasteEvent) => void) | null;
|
|
172
178
|
private _live;
|
|
179
|
+
private _animationFps;
|
|
180
|
+
private stopAnimationTick;
|
|
181
|
+
private animationDrawnFrame;
|
|
173
182
|
protected _liveCount: number;
|
|
174
183
|
private _sizeChangeListener;
|
|
175
184
|
private _hooks;
|
|
@@ -216,7 +225,8 @@ export declare abstract class Renderable extends BaseRenderable {
|
|
|
216
225
|
getSelectedText(): string;
|
|
217
226
|
shouldStartSelection(x: number, y: number): boolean;
|
|
218
227
|
focus(): void;
|
|
219
|
-
|
|
228
|
+
/** Ancestors can paint focus within, so a focus change marks them dirty. */
|
|
229
|
+
protected propagateFocusChange(_hasFocus: boolean): void;
|
|
220
230
|
blur(): void;
|
|
221
231
|
get focused(): boolean;
|
|
222
232
|
get hasFocusedDescendant(): boolean;
|
|
@@ -225,6 +235,10 @@ export declare abstract class Renderable extends BaseRenderable {
|
|
|
225
235
|
set live(value: boolean);
|
|
226
236
|
protected propagateLiveCount(delta: number): void;
|
|
227
237
|
protected onLiveCountChanged(previous: number): void;
|
|
238
|
+
get animationFps(): number | undefined;
|
|
239
|
+
set animationFps(value: number | undefined);
|
|
240
|
+
private updateAnimationTick;
|
|
241
|
+
protected onAnimationTick(deltaTime: number, ticks: number, time: number): void;
|
|
228
242
|
handleKeyPress?(key: KeyEvent): boolean;
|
|
229
243
|
handlePaste?(event: PasteEvent): void;
|
|
230
244
|
findDescendantById(id: string): Renderable | undefined;
|
|
@@ -239,6 +253,10 @@ export declare abstract class Renderable extends BaseRenderable {
|
|
|
239
253
|
get screenY(): number;
|
|
240
254
|
protected get _screenX(): number;
|
|
241
255
|
protected get _screenY(): number;
|
|
256
|
+
/** @internal Where the body paints: the buffer's origin when the node paints its own buffer. */
|
|
257
|
+
protected _paintOrigin(buffer: OptimizedBuffer): [number, number];
|
|
258
|
+
/** @internal Record or draw the native body at its paint origin. */
|
|
259
|
+
protected _drawNativeBody(buffer: OptimizedBuffer): void;
|
|
242
260
|
protected get _paintWidth(): number;
|
|
243
261
|
protected get _paintHeight(): number;
|
|
244
262
|
get x(): number;
|
package/animation/Timeline.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import type { CliRenderer } from "../renderer.js";
|
|
2
2
|
export interface TimelineOptions {
|
|
3
3
|
duration?: number;
|
|
4
|
+
/** Updates per second while it plays, above 0 (Infinity allowed). Below the renderer's targetFps it ticks on the
|
|
5
|
+
* shared animation clock instead of holding the render loop. Default: the engine's `defaults.frameRate` (60). */
|
|
6
|
+
frameRate?: number;
|
|
4
7
|
loop?: boolean;
|
|
5
8
|
autoplay?: boolean;
|
|
6
9
|
onComplete?: () => void;
|
|
@@ -84,6 +87,7 @@ export declare class Timeline {
|
|
|
84
87
|
isPlaying: boolean;
|
|
85
88
|
isComplete: boolean;
|
|
86
89
|
duration: number;
|
|
90
|
+
private _frameRate;
|
|
87
91
|
loop: boolean;
|
|
88
92
|
synced: boolean;
|
|
89
93
|
private autoplay;
|
|
@@ -91,6 +95,8 @@ export declare class Timeline {
|
|
|
91
95
|
private onPause?;
|
|
92
96
|
private stateChangeListeners;
|
|
93
97
|
constructor(options?: TimelineOptions);
|
|
98
|
+
get frameRate(): number | undefined;
|
|
99
|
+
set frameRate(value: number | undefined);
|
|
94
100
|
addStateChangeListener(listener: (timeline: Timeline) => void): void;
|
|
95
101
|
removeStateChangeListener(listener: (timeline: Timeline) => void): void;
|
|
96
102
|
private notifyStateChange;
|
|
@@ -109,6 +115,8 @@ declare class TimelineEngine {
|
|
|
109
115
|
private renderer;
|
|
110
116
|
private frameCallback;
|
|
111
117
|
private isLive;
|
|
118
|
+
private tickFps;
|
|
119
|
+
private stopTicks;
|
|
112
120
|
defaults: {
|
|
113
121
|
frameRate: number;
|
|
114
122
|
};
|
|
@@ -116,6 +124,7 @@ declare class TimelineEngine {
|
|
|
116
124
|
attach(renderer: CliRenderer): void;
|
|
117
125
|
detach(): void;
|
|
118
126
|
private updateLiveState;
|
|
127
|
+
private setTickFps;
|
|
119
128
|
private onTimelineStateChange;
|
|
120
129
|
register(timeline: Timeline): void;
|
|
121
130
|
unregister(timeline: Timeline): void;
|
package/buffer.d.ts
CHANGED
|
@@ -58,8 +58,8 @@ export declare class OptimizedBuffer {
|
|
|
58
58
|
/** @internal Resource controllers draw only within their owning Context. */
|
|
59
59
|
_getSceneDrawTarget(scene: NativeScene): NativeDrawingTarget;
|
|
60
60
|
private drawChecked;
|
|
61
|
-
/** @internal Scene text
|
|
62
|
-
|
|
61
|
+
/** @internal Scene text and boxes draw their native body without exposing its buffer. */
|
|
62
|
+
_drawSceneBody(scene: NativeScene, node: SceneNodeHandle, x: number, y: number): void;
|
|
63
63
|
/** Raw planes are available only during a synchronous post-process scope. Prefer withBuffers(). */
|
|
64
64
|
get buffers(): {
|
|
65
65
|
char: Uint32Array;
|
|
@@ -98,6 +98,8 @@ export declare class OptimizedBuffer {
|
|
|
98
98
|
get widthMethod(): WidthMethod;
|
|
99
99
|
get width(): number;
|
|
100
100
|
get height(): number;
|
|
101
|
+
/** With `respectAlpha`, `drawFrameBuffer()` blends this buffer's cells when it is the source. Without it, a source at
|
|
102
|
+
* full opacity is copied cell for cell, transparent and translucent cells included, unless either buffer holds images. */
|
|
101
103
|
setRespectAlpha(respectAlpha: boolean): void;
|
|
102
104
|
getRealCharBytes(addLineBreaks?: boolean): Uint8Array;
|
|
103
105
|
private withResolvedChars;
|
|
@@ -111,9 +113,13 @@ export declare class OptimizedBuffer {
|
|
|
111
113
|
bgColor?: RGBA;
|
|
112
114
|
fgColor?: RGBA;
|
|
113
115
|
} | null): void;
|
|
116
|
+
/** @internal Draws text within maxWidth cells from x, cut on a glyph; nothing when maxWidth < 1. */
|
|
117
|
+
drawTextFit(text: string, x: number, y: number, maxWidth: number, fg: RGBA, bg?: RGBA, ellipsis?: boolean): void;
|
|
114
118
|
fillRect(x: number, y: number, width: number, height: number, bg: RGBA): void;
|
|
115
119
|
colorMatrix(matrix: Float32Array, cellMask: Float32Array, strength?: number, target?: TargetChannel): void;
|
|
116
120
|
colorMatrixUniform(matrix: Float32Array, strength?: number, target?: TargetChannel): void;
|
|
121
|
+
/** Composites a source cell rectangle, clipped to the scissor. At full opacity a source without `respectAlpha` is
|
|
122
|
+
* copied, transparent and translucent cells included, unless either buffer holds images; otherwise each cell blends. */
|
|
117
123
|
drawFrameBuffer(destX: number, destY: number, frameBuffer: OptimizedBuffer, sourceX?: number, sourceY?: number, sourceWidth?: number, sourceHeight?: number): void;
|
|
118
124
|
destroy(): void;
|
|
119
125
|
drawTextBuffer(textBufferView: TextBufferView, x: number, y: number): void;
|