@opentui/core 0.8.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 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 NativeSceneScrollOptions, type NativeSceneScrollState, 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,14 @@ 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
+ };
122
130
  /** @internal A scroll write moves the box's children, so it bumps the layout revision like a frame step. */
123
131
  setScroll(renderable: Renderable, options: NativeSceneScrollOptions): void;
124
132
  setScrollArrow(renderable: Renderable, axis: number, end: number, options: Omit<NativeSceneArrowOptions, "direction">): void;
@@ -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
- /** Cancel if graceful close has not completed within this finite interval. */
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/buffer.d.ts CHANGED
@@ -113,6 +113,8 @@ export declare class OptimizedBuffer {
113
113
  bgColor?: RGBA;
114
114
  fgColor?: RGBA;
115
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;
116
118
  fillRect(x: number, y: number, width: number, height: number, bg: RGBA): void;
117
119
  colorMatrix(matrix: Float32Array, cellMask: Float32Array, strength?: number, target?: TargetChannel): void;
118
120
  colorMatrixUniform(matrix: Float32Array, strength?: number, target?: TargetChannel): void;