@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/renderables/Image.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Renderable, type RenderableOptions, type NativeRenderableIntegration } from "../Renderable.js";
|
|
2
|
-
import { NativeImage, type ImageSource } from "../image.js";
|
|
2
|
+
import { NativeImage, type ExtractOptions, type ImageSource } from "../image.js";
|
|
3
3
|
import type { OptimizedBuffer } from "../buffer.js";
|
|
4
4
|
import type { ImageRenderProtocol, RenderContext, TerminalCapabilities } from "../types.js";
|
|
5
5
|
export type ImageFit = "fit" | "cover" | "fill";
|
|
@@ -7,11 +7,17 @@ export type ImageRenderableSource = ImageSource | NativeImage;
|
|
|
7
7
|
export interface ImageRenderableOptions extends RenderableOptions<ImageRenderable> {
|
|
8
8
|
source?: ImageRenderableSource;
|
|
9
9
|
fit?: ImageFit;
|
|
10
|
+
/** The region of the source to show, in source pixels; `fit` applies to it. */
|
|
11
|
+
crop?: ExtractOptions;
|
|
10
12
|
protocol?: ImageRenderProtocol;
|
|
11
13
|
onLoad?: (image: NativeImage) => void;
|
|
12
14
|
onError?: (error: unknown) => void;
|
|
13
15
|
}
|
|
14
16
|
export declare function resolveImageRenderProtocol(requested: ImageRenderProtocol, capabilities: TerminalCapabilities | null, hasResolution: boolean): Exclude<ImageRenderProtocol, "auto">;
|
|
17
|
+
/** @internal Copies a crop of u32 pixels with a positive size that lies inside a width x height source, or throws. */
|
|
18
|
+
export declare function checkCrop(crop: ExtractOptions, width?: number, height?: number): ExtractOptions;
|
|
19
|
+
/** @internal */
|
|
20
|
+
export declare function sameCrop(a: ExtractOptions | undefined, b: ExtractOptions | undefined): boolean;
|
|
15
21
|
export declare class ImageRenderable extends Renderable {
|
|
16
22
|
static readonly nativeIntegration: NativeRenderableIntegration;
|
|
17
23
|
private _source;
|
|
@@ -22,6 +28,7 @@ export declare class ImageRenderable extends Renderable {
|
|
|
22
28
|
onLoad?: (image: NativeImage) => void;
|
|
23
29
|
onError?: (error: unknown) => void;
|
|
24
30
|
private _fit;
|
|
31
|
+
private _crop;
|
|
25
32
|
private _protocol;
|
|
26
33
|
loadPromise: Promise<void> | null;
|
|
27
34
|
constructor(ctx: RenderContext, options: ImageRenderableOptions);
|
|
@@ -30,6 +37,9 @@ export declare class ImageRenderable extends Renderable {
|
|
|
30
37
|
get image(): NativeImage | null;
|
|
31
38
|
get fit(): ImageFit;
|
|
32
39
|
set fit(value: ImageFit | null | undefined);
|
|
40
|
+
get crop(): ExtractOptions | undefined;
|
|
41
|
+
/** A crop that is not whole pixels, or lies outside the loaded image, reports through onError and keeps the previous one. */
|
|
42
|
+
set crop(value: ExtractOptions | null | undefined);
|
|
33
43
|
get protocol(): ImageRenderProtocol;
|
|
34
44
|
set protocol(value: ImageRenderProtocol | null | undefined);
|
|
35
45
|
get effectiveProtocol(): Exclude<ImageRenderProtocol, "auto">;
|
|
@@ -43,6 +53,8 @@ export declare class ImageRenderable extends Renderable {
|
|
|
43
53
|
protected createFrameBuffer(): void;
|
|
44
54
|
protected renderSelf(buffer: OptimizedBuffer): void;
|
|
45
55
|
private load;
|
|
56
|
+
private region;
|
|
57
|
+
private acceptCrop;
|
|
46
58
|
private setNativeSceneImage;
|
|
47
59
|
protected destroySelf(): void;
|
|
48
60
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Renderable, type BaseRenderable, type RenderableOptions } from "../Renderable.js";
|
|
2
|
-
import { OptimizedBuffer } from "../buffer.js";
|
|
2
|
+
import type { OptimizedBuffer } from "../buffer.js";
|
|
3
3
|
import type { RenderContext, LineInfoProvider } from "../types.js";
|
|
4
4
|
import { RGBA } from "../lib/RGBA.js";
|
|
5
5
|
export interface LineSign {
|
|
@@ -205,6 +205,7 @@ export declare class MarkdownRenderable extends Renderable {
|
|
|
205
205
|
private destroyListItemChildrenAfter;
|
|
206
206
|
private applyListItemMarker;
|
|
207
207
|
private createListChildRenderable;
|
|
208
|
+
private getHorizontalRuleColor;
|
|
208
209
|
private createHorizontalRuleRenderable;
|
|
209
210
|
private createCodeRenderable;
|
|
210
211
|
private applyMarkdownCodeRenderable;
|
|
@@ -247,7 +248,6 @@ export declare class MarkdownRenderable extends Renderable {
|
|
|
247
248
|
private destroyUnusedDefaultRenderable;
|
|
248
249
|
private updateBlockRenderable;
|
|
249
250
|
private updateTopLevelBlocks;
|
|
250
|
-
private canUpdateBlockRenderable;
|
|
251
251
|
private updateBlocks;
|
|
252
252
|
private clearBlockStates;
|
|
253
253
|
/**
|
|
@@ -83,3 +83,9 @@ export declare class ArrowRenderable extends Renderable {
|
|
|
83
83
|
private glyphWidth;
|
|
84
84
|
private getArrowChar;
|
|
85
85
|
}
|
|
86
|
+
/** @internal Cells per unit of a scrollbar's `scrollBy`. */
|
|
87
|
+
export declare function scrollUnitSize(bar: {
|
|
88
|
+
viewportSize: number;
|
|
89
|
+
scrollSize: number;
|
|
90
|
+
scrollStep?: number | null;
|
|
91
|
+
}, unit: ScrollUnit): number;
|
|
@@ -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 {
|
|
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 {
|
|
8
|
-
import {
|
|
9
|
-
export
|
|
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,17 +24,18 @@ 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
|
-
|
|
35
|
-
|
|
36
|
-
readonly
|
|
37
|
-
readonly
|
|
38
|
-
readonly
|
|
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
|
-
private selectionListener
|
|
38
|
+
private readonly selectionListener;
|
|
43
39
|
private autoScrollMouseX;
|
|
44
40
|
private autoScrollMouseY;
|
|
45
41
|
private readonly autoScrollThresholdVertical;
|
|
@@ -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
|
-
|
|
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 {};
|
package/renderables/Select.d.ts
CHANGED
|
@@ -83,8 +83,6 @@ export declare class SelectRenderable extends Renderable {
|
|
|
83
83
|
};
|
|
84
84
|
constructor(ctx: RenderContext, options: SelectRenderableOptions);
|
|
85
85
|
protected renderSelf(buffer: OptimizedBuffer, deltaTime: number): void;
|
|
86
|
-
private refreshFrameBuffer;
|
|
87
|
-
private renderScrollIndicatorToFrameBuffer;
|
|
88
86
|
get options(): SelectOption[];
|
|
89
87
|
set options(options: SelectOption[]);
|
|
90
88
|
getSelectedOption(): SelectOption | null;
|
|
@@ -60,9 +60,6 @@ export declare class TabSelectRenderable extends Renderable {
|
|
|
60
60
|
private calculateDynamicHeight;
|
|
61
61
|
protected defaultDimension(kind: "width" | "height"): number | "auto" | `${number}%`;
|
|
62
62
|
protected renderSelf(buffer: OptimizedBuffer, deltaTime: number): void;
|
|
63
|
-
private refreshFrameBuffer;
|
|
64
|
-
private truncateText;
|
|
65
|
-
private renderScrollArrowsToFrameBuffer;
|
|
66
63
|
setOptions(options: TabSelectOption[]): void;
|
|
67
64
|
getSelectedOption(): TabSelectOption | null;
|
|
68
65
|
getSelectedIndex(): number;
|
|
@@ -61,7 +61,6 @@ export declare class TextTableRenderable extends Renderable {
|
|
|
61
61
|
private _columnCount;
|
|
62
62
|
private _layout;
|
|
63
63
|
private _layoutDirty;
|
|
64
|
-
private _rasterDirty;
|
|
65
64
|
private _cachedMeasureLayout;
|
|
66
65
|
private _cachedMeasureWidth;
|
|
67
66
|
private readonly _defaultOptions;
|
|
@@ -130,9 +129,6 @@ export declare class TextTableRenderable extends Renderable {
|
|
|
130
129
|
private getHorizontalBorderCount;
|
|
131
130
|
private drawBorders;
|
|
132
131
|
private drawCells;
|
|
133
|
-
private drawCellRange;
|
|
134
|
-
private redrawSelectionRows;
|
|
135
|
-
private clearCellRange;
|
|
136
132
|
private ensureLayoutReady;
|
|
137
133
|
private getCellAtLocalPosition;
|
|
138
134
|
private applySelectionToCells;
|
|
@@ -140,8 +136,6 @@ export declare class TextTableRenderable extends Renderable {
|
|
|
140
136
|
private getColumnAtLocalX;
|
|
141
137
|
private getFullCellSelectionCoords;
|
|
142
138
|
private findRowForLocalY;
|
|
143
|
-
private getSelectionRowRange;
|
|
144
|
-
private getDirtySelectionRowRange;
|
|
145
139
|
private resetRowSelection;
|
|
146
140
|
private resetCellSelections;
|
|
147
141
|
private createEmptyLayout;
|
|
@@ -151,6 +145,5 @@ export declare class TextTableRenderable extends Renderable {
|
|
|
151
145
|
private resolveColumnFitter;
|
|
152
146
|
private resolveCellPadding;
|
|
153
147
|
private resolveColumnGap;
|
|
154
|
-
private
|
|
155
|
-
private invalidateRasterOnly;
|
|
148
|
+
private invalidateLayout;
|
|
156
149
|
}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import type { OptimizedBuffer } from "../buffer.js";
|
|
2
|
+
import { Renderable, type NativeRenderableIntegration, type RenderableOptions } from "../Renderable.js";
|
|
3
|
+
import type { RenderContext } from "../types.js";
|
|
4
|
+
import type { ExtractOptions } from "../image.js";
|
|
5
|
+
import { type ImageFit } from "./Image.js";
|
|
6
|
+
export interface VideoMetadata {
|
|
7
|
+
width: number;
|
|
8
|
+
height: number;
|
|
9
|
+
fps: number;
|
|
10
|
+
duration: number;
|
|
11
|
+
hasAudio: boolean;
|
|
12
|
+
}
|
|
13
|
+
export interface VideoRenderableOptions extends RenderableOptions<VideoRenderable> {
|
|
14
|
+
/** Path of an MP4 (H.264/AAC) file. */
|
|
15
|
+
source?: string;
|
|
16
|
+
fit?: ImageFit;
|
|
17
|
+
/** The region of the source to show, in source pixels; `fit` applies to it, and only the region is scaled. */
|
|
18
|
+
crop?: ExtractOptions;
|
|
19
|
+
/** Plays each source once it opens. */
|
|
20
|
+
autoplay?: boolean;
|
|
21
|
+
loop?: boolean;
|
|
22
|
+
/** Opens the audio track. With false, playback opens no audio device and follows the wall clock. Defaults to true. */
|
|
23
|
+
audio?: boolean;
|
|
24
|
+
muted?: boolean;
|
|
25
|
+
volume?: number;
|
|
26
|
+
/** Positive values show frames earlier relative to the audio. */
|
|
27
|
+
avSyncOffsetMs?: number;
|
|
28
|
+
/** Upper bound of the presentation rate, an integer from 1 to 120. Defaults to 30. */
|
|
29
|
+
maxFps?: number;
|
|
30
|
+
onReady?: (metadata: VideoMetadata) => void;
|
|
31
|
+
onError?: (error: Error) => void;
|
|
32
|
+
onEnd?: () => void;
|
|
33
|
+
onPlay?: () => void;
|
|
34
|
+
onPause?: () => void;
|
|
35
|
+
onSeek?: (time: number) => void;
|
|
36
|
+
onTimeUpdate?: (time: number) => void;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Plays a video file in a native scene node. Decoding, the media clock, and frame drawing stay native;
|
|
40
|
+
* this wrapper sends control calls and reads playback state on the animation clock while playing.
|
|
41
|
+
*/
|
|
42
|
+
export declare class VideoRenderable extends Renderable {
|
|
43
|
+
static readonly nativeIntegration: NativeRenderableIntegration;
|
|
44
|
+
private _source;
|
|
45
|
+
private _fit;
|
|
46
|
+
private _crop;
|
|
47
|
+
private _loop;
|
|
48
|
+
private _audio;
|
|
49
|
+
private _muted;
|
|
50
|
+
private _volume;
|
|
51
|
+
private _avSyncOffsetMs;
|
|
52
|
+
private _maxFps;
|
|
53
|
+
private _autoplay;
|
|
54
|
+
private _metadata;
|
|
55
|
+
private _playRequested;
|
|
56
|
+
private stopTick?;
|
|
57
|
+
private _opens;
|
|
58
|
+
onReady?: (metadata: VideoMetadata) => void;
|
|
59
|
+
onError?: (error: Error) => void;
|
|
60
|
+
onEnd?: () => void;
|
|
61
|
+
onPlay?: () => void;
|
|
62
|
+
onPause?: () => void;
|
|
63
|
+
onSeek?: (time: number) => void;
|
|
64
|
+
onTimeUpdate?: (time: number) => void;
|
|
65
|
+
constructor(ctx: RenderContext, options: VideoRenderableOptions);
|
|
66
|
+
get source(): string | undefined;
|
|
67
|
+
/** Opens a new source; playback intent carries over to it. */
|
|
68
|
+
set source(value: string | null | undefined);
|
|
69
|
+
private open;
|
|
70
|
+
get fit(): ImageFit;
|
|
71
|
+
set fit(value: ImageFit | null | undefined);
|
|
72
|
+
get crop(): ExtractOptions | undefined;
|
|
73
|
+
/** A crop that is not whole pixels, or lies outside the open source, reports through onError and keeps the previous one. */
|
|
74
|
+
set crop(value: ExtractOptions | null | undefined);
|
|
75
|
+
get loop(): boolean;
|
|
76
|
+
set loop(value: boolean | null | undefined);
|
|
77
|
+
get audio(): boolean;
|
|
78
|
+
set audio(value: boolean | null | undefined);
|
|
79
|
+
get muted(): boolean;
|
|
80
|
+
set muted(value: boolean | null | undefined);
|
|
81
|
+
get volume(): number;
|
|
82
|
+
set volume(value: number | null | undefined);
|
|
83
|
+
get avSyncOffsetMs(): number;
|
|
84
|
+
set avSyncOffsetMs(value: number | null | undefined);
|
|
85
|
+
get maxFps(): number;
|
|
86
|
+
set maxFps(value: number | null | undefined);
|
|
87
|
+
/** Applies to the next source that opens, and to an open source that has not started yet. */
|
|
88
|
+
get autoplay(): boolean;
|
|
89
|
+
set autoplay(value: boolean | null | undefined);
|
|
90
|
+
get ready(): boolean;
|
|
91
|
+
get videoMetadata(): Readonly<VideoMetadata> | null;
|
|
92
|
+
get playing(): boolean;
|
|
93
|
+
get paused(): boolean;
|
|
94
|
+
get ended(): boolean;
|
|
95
|
+
get duration(): number;
|
|
96
|
+
get durationMs(): number;
|
|
97
|
+
get currentTime(): number;
|
|
98
|
+
/** Seeks; a nullish write is ignored. */
|
|
99
|
+
set currentTime(value: number | null | undefined);
|
|
100
|
+
/** Adaptive quality tier: 0 decodes at full size; higher tiers decode smaller while output cannot keep up. */
|
|
101
|
+
get qualityTier(): number;
|
|
102
|
+
get currentTimeMs(): number;
|
|
103
|
+
play(): void;
|
|
104
|
+
resume(): void;
|
|
105
|
+
pause(): void;
|
|
106
|
+
toggle(): void;
|
|
107
|
+
seek(time: number): void;
|
|
108
|
+
seekBy(delta: number): void;
|
|
109
|
+
seekToMs(milliseconds: number): void;
|
|
110
|
+
protected createFrameBuffer(): void;
|
|
111
|
+
protected renderSelf(_buffer: OptimizedBuffer): void;
|
|
112
|
+
private poll;
|
|
113
|
+
private native;
|
|
114
|
+
private readState;
|
|
115
|
+
private failed;
|
|
116
|
+
private errorDetail;
|
|
117
|
+
private applyOption;
|
|
118
|
+
private control;
|
|
119
|
+
private syncPlayback;
|
|
120
|
+
private setNativeSceneVideo;
|
|
121
|
+
private acceptCrop;
|
|
122
|
+
private startRequested;
|
|
123
|
+
private afterOpen;
|
|
124
|
+
private reportError;
|
|
125
|
+
protected destroySelf(): void;
|
|
126
|
+
}
|
package/renderables/index.d.ts
CHANGED
|
@@ -10,10 +10,11 @@ export * from "./EmbeddedTerminal.js";
|
|
|
10
10
|
export * from "./FrameBuffer.js";
|
|
11
11
|
export * from "./Input.js";
|
|
12
12
|
export * from "./Image.js";
|
|
13
|
+
export * from "./Video.js";
|
|
13
14
|
export * from "./LineNumberRenderable.js";
|
|
14
15
|
export * from "./Markdown.js";
|
|
15
16
|
export * from "./ScrollBar.js";
|
|
16
|
-
export { ScrollBoxRenderable, type ScrollBoxOptions } from "./ScrollBox.js";
|
|
17
|
+
export { ScrollBoxRenderable, ScrollBoxBar, ScrollBoxContent, ScrollBoxViewport, ScrollBoxWrapper, type ScrollBoxOptions, } from "./ScrollBox.js";
|
|
17
18
|
export * from "./Select.js";
|
|
18
19
|
export * from "./Slider.js";
|
|
19
20
|
export * from "./TextTable.js";
|
package/renderer-theme-mode.d.ts
CHANGED
|
@@ -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
|
-
|
|
26
|
-
private completeThemeQuery;
|
|
21
|
+
cancelRefresh(): void;
|
|
27
22
|
private requestThemeOscColors;
|
|
28
23
|
private applyThemeMode;
|
|
29
24
|
}
|