@opentui/core 0.8.4 → 0.9.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.
Files changed (88) hide show
  1. package/NativeScene.d.ts +11 -3
  2. package/Renderable.d.ts +22 -6
  3. package/ansi.d.ts +1 -1
  4. package/{chunk-bun-dsfc571f.js → chunk-bun-v1wzs0bj.js} +679 -112
  5. package/chunk-bun-v1wzs0bj.js.map +35 -0
  6. package/{chunk-bun-83k2gdpc.js → chunk-bun-xartp4ps.js} +8718 -9733
  7. package/chunk-bun-xartp4ps.js.map +68 -0
  8. package/{chunk-node-3ssb37vb.js → chunk-node-5cqzgmq3.js} +8718 -9733
  9. package/chunk-node-5cqzgmq3.js.map +68 -0
  10. package/{chunk-node-5nvhjp1a.js → chunk-node-mcdre3zn.js} +679 -112
  11. package/chunk-node-mcdre3zn.js.map +34 -0
  12. package/edit-buffer.d.ts +47 -6
  13. package/editor-view.d.ts +28 -0
  14. package/index.bun.js +1355 -4789
  15. package/index.bun.js.map +18 -24
  16. package/index.node.js +1355 -4789
  17. package/index.node.js.map +19 -31
  18. package/lib/KeyHandler.d.ts +1 -1
  19. package/lib/extmarks.d.ts +15 -51
  20. package/lib/index.d.ts +1 -2
  21. package/lib/kitty-keys.d.ts +2 -0
  22. package/lib/parse.keypress.d.ts +8 -3
  23. package/lib/parse.mouse.d.ts +0 -13
  24. package/lib/stdin-parser-native.d.ts +36 -24
  25. package/lib/terminal-capability-detection.d.ts +3 -3
  26. package/lib/terminal-palette.d.ts +3 -0
  27. package/lib/tree-sitter/client.d.ts +14 -3
  28. package/lib/tree-sitter/types.d.ts +10 -0
  29. package/lib/tree-sitter-styled-text.d.ts +2 -0
  30. package/lib/yoga.options.d.ts +3 -0
  31. package/native-abi.generated.d.ts +1400 -1
  32. package/package.json +9 -10
  33. package/parser.worker.js +112 -29
  34. package/parser.worker.js.map +3 -3
  35. package/plugins/core-slot.d.ts +1 -1
  36. package/renderables/ASCIIFont.d.ts +5 -0
  37. package/renderables/Code.d.ts +25 -2
  38. package/renderables/Diff.d.ts +3 -1
  39. package/renderables/EditBufferRenderable.d.ts +30 -1
  40. package/renderables/EmbeddedTerminal.d.ts +1 -1
  41. package/renderables/Input.d.ts +6 -3
  42. package/renderables/LineNumberRenderable.d.ts +4 -0
  43. package/renderables/Markdown.d.ts +208 -124
  44. package/renderables/ScrollBox.d.ts +7 -2
  45. package/renderables/ScrollBoxParts.d.ts +4 -5
  46. package/renderables/Select.d.ts +2 -2
  47. package/renderables/TabSelect.d.ts +2 -2
  48. package/renderables/Text.d.ts +3 -1
  49. package/renderables/TextBufferRenderable.d.ts +4 -0
  50. package/renderables/TextTable.d.ts +22 -0
  51. package/renderables/Textarea.d.ts +2 -1
  52. package/renderables/__tests__/code-model-harness.d.ts +40 -0
  53. package/renderables/index.d.ts +1 -3
  54. package/renderables/markdown-document.d.ts +37 -0
  55. package/renderables/props.d.ts +10 -0
  56. package/renderer-theme-mode.d.ts +5 -1
  57. package/renderer.d.ts +23 -9
  58. package/runtime-plugin.js +32 -57
  59. package/runtime-plugin.js.map +1 -1
  60. package/syntax-style.d.ts +5 -0
  61. package/testing/mock-tree-sitter-client.d.ts +5 -0
  62. package/testing/model.d.ts +15 -0
  63. package/testing.bun.js +8 -31
  64. package/testing.bun.js.map +4 -4
  65. package/testing.js +8 -31
  66. package/testing.js.map +4 -4
  67. package/tests/shrink-same-check.d.ts +4 -0
  68. package/tests/yoga-upstream/tools/utils.d.ts +9 -2
  69. package/text-buffer-view.d.ts +4 -0
  70. package/text-buffer.d.ts +16 -1
  71. package/types.d.ts +2 -2
  72. package/yoga.bun.js +1 -1
  73. package/yoga.internal.d.ts +1 -0
  74. package/yoga.js +1 -1
  75. package/zig.d.ts +107 -6
  76. package/chunk-bun-83k2gdpc.js.map +0 -70
  77. package/chunk-bun-dsfc571f.js.map +0 -35
  78. package/chunk-node-3ssb37vb.js.map +0 -70
  79. package/chunk-node-5nvhjp1a.js.map +0 -34
  80. package/lib/debounce.d.ts +0 -42
  81. package/lib/extmarks-history.d.ts +0 -17
  82. package/lib/parse.keypress-kitty.d.ts +0 -5
  83. package/lib/queue.d.ts +0 -15
  84. package/lib/stdin-parser.d.ts +0 -97
  85. package/renderables/composition/VRenderable.d.ts +0 -16
  86. package/renderables/composition/constructs.d.ts +0 -35
  87. package/renderables/composition/vnode.d.ts +0 -46
  88. package/renderables/markdown-parser.d.ts +0 -12
package/zig.d.ts CHANGED
@@ -4,6 +4,7 @@ export type { LineInfo, AllocatorStats, AudioStreamCreateOptions, BuildOptions,
4
4
  import type { ExtractOptions } from "./image.js";
5
5
  import { RGBA } from "./lib/RGBA.js";
6
6
  import { type StyledText } from "./lib/styled-text.js";
7
+ import type { TextChunk } from "./text-buffer.js";
7
8
  import { type MeasureFunction } from "./yoga.js";
8
9
  import { YogaHost } from "./yoga.internal.js";
9
10
  import type { NativeSpanFeedOptions, NativeSpanFeedStats, ReserveInfo, AudioCreateOptions, AudioStartOptions, AudioVoiceOptions, AudioStreamCreateOptions, NativeAudioStreamCloseReason as NativeAudioStreamCloseReasonType, NativeAudioStreamFormat as NativeAudioStreamFormatType, NativeAudioStreamState as NativeAudioStreamStateType, NativeAudioStreamStats, NativeAudioCaptureStats, AudioStats, BuildOptions, AllocatorStats, NativeFrameWork, NativeRenderStats, NativeImageInfo } from "./zig-structs.js";
@@ -82,12 +83,48 @@ export type ContextImagePixelsHandle = ContextObjectHandle & {
82
83
  export type ContextUnicodeHandle = ContextObjectHandle & {
83
84
  readonly [contextResourceBrand]: "unicode";
84
85
  };
86
+ export type ContextMarkdownHandle = ContextObjectHandle & {
87
+ readonly [contextResourceBrand]: "markdown";
88
+ };
89
+ /** `ot_markdown_options`: OT_MD_* flags, the style bound nodes draw with, and the hook filter's substrings. */
90
+ export interface NativeMarkdownOptions {
91
+ flags: number;
92
+ syntaxStyle: ContextSyntaxStyleHandle | null;
93
+ hookFilter?: readonly string[];
94
+ /** Lowers the 64 MiB source limit; 0 or absent keeps it. */
95
+ sourceByteLimit?: number;
96
+ }
97
+ /** `ot_markdown_result`; `removedFrom` is undefined when nothing was removed. */
98
+ export interface NativeMarkdownResult {
99
+ changed: number;
100
+ committed: number;
101
+ removedFrom: number | undefined;
102
+ }
103
+ /** `ot_markdown_block`; `parent` is undefined at top level. */
104
+ export interface NativeMarkdownBlock {
105
+ index: number;
106
+ parent: number | undefined;
107
+ kind: number;
108
+ flags: number;
109
+ sourceStart: number;
110
+ sourceEnd: number;
111
+ infoStart: number;
112
+ infoEnd: number;
113
+ number: number;
114
+ }
115
+ /** A leaf's parser output: its display text as chunks, and OT_MD_SPAN_* flags per chunk. */
116
+ export interface NativeMarkdownLeaf {
117
+ chunks: TextChunk[];
118
+ spans: Uint32Array;
119
+ }
85
120
  export type ContextEmbeddedTerminalHandle = ContextObjectHandle & {
86
121
  readonly [contextResourceBrand]: "embedded_terminal";
87
122
  };
88
123
  export type SessionBuffer = "current" | "next";
89
124
  export interface NativeContextEditBufferOptions {
90
125
  widthMethod?: WidthMethod | "no-zwj";
126
+ /** Measure with the width method of the session whose scene shows the buffer. */
127
+ followSessionWidth?: boolean;
91
128
  }
92
129
  export interface NativeEditBufferInfo {
93
130
  contentEpoch: bigint;
@@ -133,8 +170,12 @@ export declare enum NativeEditCommand {
133
170
  CursorOffset = 9,
134
171
  Clear = 10,
135
172
  ClearHistory = 11,
136
- DebugRope = 12
173
+ DebugRope = 12,
174
+ CursorOffsetAtomic = 13,
175
+ KeepOutside = 14
137
176
  }
177
+ /** The argument that applies the cursor rules around atomic marks to Left, Right, Backspace, Delete, Up and Down. */
178
+ export declare const NativeEditAtomic = 1;
138
179
  export declare enum NativeEditPositionQuery {
139
180
  Cursor = 0,
140
181
  NextWord = 1,
@@ -156,6 +197,8 @@ export interface NativeEditorStyle {
156
197
  fg?: RGBA | null;
157
198
  bg?: RGBA | null;
158
199
  attributes?: number | null;
200
+ /** Syntax styles only: the attribute bits the style sets or clears when a group set composes it. */
201
+ suppliedAttributes?: number | null;
159
202
  }
160
203
  export declare enum NativeEditHighlightOperation {
161
204
  AddLine = 0,
@@ -164,6 +207,21 @@ export declare enum NativeEditHighlightOperation {
164
207
  ClearLine = 3,
165
208
  ClearAll = 4
166
209
  }
210
+ export declare enum NativeEditMarkOperation {
211
+ Add = 0,
212
+ Remove = 1,
213
+ Clear = 2
214
+ }
215
+ /** An edit mark in cursor offsets; `style` is a SyntaxStyle id, 0 for none. */
216
+ export interface NativeEditMark {
217
+ id: number;
218
+ kind: number;
219
+ atomic: boolean;
220
+ style: number;
221
+ priority: number;
222
+ start: number;
223
+ end: number;
224
+ }
167
225
  export interface NativeEditorViewport {
168
226
  x: number;
169
227
  y: number;
@@ -482,7 +540,7 @@ export interface NativeContextImageDraw {
482
540
  protocol?: ImageRenderProtocol;
483
541
  }
484
542
  export interface NativeSceneTextSelectionOptions {
485
- operation: "reset" | "set" | "update";
543
+ operation: "reset" | "set" | "update" | "colors";
486
544
  anchorX: number;
487
545
  anchorY: number;
488
546
  focusX: number;
@@ -680,6 +738,7 @@ export type NativeSessionControl = {
680
738
  } | {
681
739
  kind: "palette-query";
682
740
  bytes: Uint8Array;
741
+ sentinel?: boolean;
683
742
  } | {
684
743
  kind: "title";
685
744
  title: string;
@@ -693,10 +752,10 @@ export type NativeSessionControl = {
693
752
  kind: "program-status";
694
753
  status: ProgramStatus;
695
754
  } | {
696
- kind: "query-pixel-resolution";
755
+ kind: "query-pixel-resolution" | "query-theme-colors";
697
756
  sentinel?: boolean;
698
757
  } | {
699
- kind: "restore-modes" | "query-theme-colors" | "reset-background";
758
+ kind: "restore-modes" | "reset-background" | "end-reply-sentinel";
700
759
  };
701
760
  export interface NativeSessionCursorOptions extends CursorStyleOptions {
702
761
  position?: {
@@ -984,15 +1043,23 @@ export declare enum LogLevel {
984
1043
  * Logical coordinates (logicalRow, logicalCol) are document-absolute.
985
1044
  */
986
1045
  export interface VisualCursor {
1046
+ /** Wrapped row relative to the top of the viewport. */
987
1047
  visualRow: number;
1048
+ /** Display-cell column relative to the viewport. */
988
1049
  visualCol: number;
1050
+ /** Zero-based logical line in the document. */
989
1051
  logicalRow: number;
1052
+ /** Display-cell column relative to the logical line start. */
990
1053
  logicalCol: number;
1054
+ /** Display cells from the document start, counting each newline as one. */
991
1055
  offset: number;
992
1056
  }
993
1057
  export interface LogicalCursor {
1058
+ /** Zero-based logical line in the document. */
994
1059
  row: number;
1060
+ /** Display cells from the logical line start. */
995
1061
  col: number;
1062
+ /** Display cells from the document start, counting each newline as one. */
996
1063
  offset: number;
997
1064
  }
998
1065
  export interface MeasureResult {
@@ -1034,6 +1101,7 @@ export declare class FFIRenderLib {
1034
1101
  private sceneFlushApplied;
1035
1102
  private editorSelectionRecord;
1036
1103
  private readonly editorViewInfoRecord;
1104
+ private markRecords;
1037
1105
  private readonly videoStateRecord;
1038
1106
  private readonly videoStateView;
1039
1107
  private readonly selectionResetRecord;
@@ -1064,6 +1132,7 @@ export declare class FFIRenderLib {
1064
1132
  readonly encoder: TextEncoder;
1065
1133
  private readonly emptyBytes;
1066
1134
  readonly decoder: TextDecoder;
1135
+ private readonly textDecoder;
1067
1136
  private logCallbackWrapper;
1068
1137
  private diagnosticDrain?;
1069
1138
  private nativeSpanFeedCallbackWrapper;
@@ -1147,7 +1216,12 @@ export declare class FFIRenderLib {
1147
1216
  contextTextBufferGetRange(context: NativeContextHandle, text: ContextTextBufferHandle, start: number, end: number): string;
1148
1217
  contextTextBufferSetDefaults(context: NativeContextHandle, text: ContextTextBufferHandle, mask: NativeEditorStyleMask, style: NativeEditorStyle): void;
1149
1218
  contextTextBufferSetTabWidth(context: NativeContextHandle, text: ContextTextBufferHandle, width: number): void;
1219
+ contextTextBufferSetWidthMethod(context: NativeContextHandle, text: ContextTextBufferHandle, widthMethod: WidthMethod): void;
1150
1220
  contextTextBufferHighlight(context: NativeContextHandle, text: ContextTextBufferHandle, operation: NativeEditHighlightOperation, argument?: number, highlight?: Highlight): void;
1221
+ /** The Context's id for an ordered list of style names (`ot_context_group_set`). */
1222
+ contextGroupSet(context: NativeContextHandle, names: readonly string[]): number;
1223
+ /** Replaces layer `layerId` in `[start, end)` bytes with `runs`: (start, end, group set) triples. */
1224
+ contextTextBufferSetLayer(context: NativeContextHandle, text: ContextTextBufferHandle, layerId: number, start: number, end: number, runs: Uint32Array): void;
1151
1225
  contextTextBufferGetHighlights(context: NativeContextHandle, text: ContextTextBufferHandle, line: number): Highlight[];
1152
1226
  contextTextBufferViewSetViewport(context: NativeContextHandle, view: ContextTextBufferViewHandle, viewport: NativeEditorViewport, sizeOnly?: boolean): void;
1153
1227
  contextTextBufferViewCommand(context: NativeContextHandle, view: ContextTextBufferViewHandle, command: NativeTextViewCommand, argument: number): void;
@@ -1185,6 +1259,7 @@ export declare class FFIRenderLib {
1185
1259
  contextEditBufferHistory(context: NativeContextHandle, editBuffer: ContextEditBufferHandle, redo: boolean): string | null;
1186
1260
  contextEditBufferGetPosition(context: NativeContextHandle, editBuffer: ContextEditBufferHandle, query: NativeEditPositionQuery, a?: number, b?: number): LogicalCursor | null;
1187
1261
  contextEditBufferGetRange(context: NativeContextHandle, editBuffer: ContextEditBufferHandle, byCoords: boolean, startRow: number, startCol: number, endRow: number, endCol: number): string;
1262
+ contextEditBufferConvertOffset(context: NativeContextHandle, editBuffer: ContextEditBufferHandle, value: number, toCell: boolean): number;
1188
1263
  contextEditBufferMeasureText(context: NativeContextHandle, editBuffer: ContextEditBufferHandle, bytes: Uint8Array): number;
1189
1264
  editMeasureText(bytes: Uint8Array, widthMethod: WidthMethod, tabWidth: number): number;
1190
1265
  contextEditBufferSetDefaults(context: NativeContextHandle, editBuffer: ContextEditBufferHandle, mask: NativeEditorStyleMask, style: NativeEditorStyle): void;
@@ -1193,6 +1268,10 @@ export declare class FFIRenderLib {
1193
1268
  contextSyntaxStyleGetStyleCount(context: NativeContextHandle, style: ContextSyntaxStyleHandle): number;
1194
1269
  contextEditBufferHighlight(context: NativeContextHandle, editBuffer: ContextEditBufferHandle, operation: NativeEditHighlightOperation, argument?: number, highlight?: Highlight): void;
1195
1270
  contextEditBufferGetHighlights(context: NativeContextHandle, editBuffer: ContextEditBufferHandle, line: number): Highlight[];
1271
+ /** Adds, removes or clears marks; returns the new id, the removed id or 0. */
1272
+ contextEditBufferMark(context: NativeContextHandle, editBuffer: ContextEditBufferHandle, operation: NativeEditMarkOperation, mark?: Partial<NativeEditMark>): number;
1273
+ /** Marks in (start, id) order: mark `id`, or all for 0, of type `kind`, or any when it is omitted. */
1274
+ contextEditBufferGetMarks(context: NativeContextHandle, editBuffer: ContextEditBufferHandle, id?: number, kind?: number): NativeEditMark[];
1196
1275
  contextEditorViewSetViewport(context: NativeContextHandle, view: ContextEditorViewHandle, viewport: NativeEditorViewport, sizeOnly?: boolean, moveCursor?: boolean): void;
1197
1276
  contextEditorViewGetViewport(context: NativeContextHandle, view: ContextEditorViewHandle): NativeEditorViewport;
1198
1277
  contextEditorViewSetScrollMargin(context: NativeContextHandle, view: ContextEditorViewHandle, margin: number): void;
@@ -1303,6 +1382,7 @@ export declare class FFIRenderLib {
1303
1382
  sceneSetMeasure(context: NativeContextHandle, node: SceneNodeHandle, measure: MeasureFunction | null): void;
1304
1383
  sceneHasMeasure(context: NativeContextHandle, node: SceneNodeHandle): boolean;
1305
1384
  sceneReachesHooks(context: NativeContextHandle, node: SceneNodeHandle): boolean;
1385
+ scenePainted(context: NativeContextHandle, node: SceneNodeHandle): boolean;
1306
1386
  sceneMarkDirty(context: NativeContextHandle, node: SceneNodeHandle): void;
1307
1387
  sceneMoveNode(context: NativeContextHandle, node: SceneNodeHandle, parent: SceneNodeHandle | null, index: number): void;
1308
1388
  sceneSetViewport(context: NativeContextHandle, node: SceneNodeHandle, viewport: SceneNodeHandle | null): void;
@@ -1320,6 +1400,26 @@ export declare class FFIRenderLib {
1320
1400
  sceneFlush(context: NativeContextHandle, staging: SceneStaging): void;
1321
1401
  sceneSetText(context: NativeContextHandle, node: SceneNodeHandle, bytes: Uint8Array): void;
1322
1402
  sceneSetStyledText(context: NativeContextHandle, node: SceneNodeHandle, content: StyledText): void;
1403
+ /** The byte the latest finished frame drew at cell (x, y) of a text node, or undefined. */
1404
+ sceneGetTextByteAt(context: NativeContextHandle, node: SceneNodeHandle, x: number, y: number): number | undefined;
1405
+ private markdownOptions;
1406
+ private markdownCall;
1407
+ markdownCreate(context: NativeContextHandle, options: NativeMarkdownOptions): ContextMarkdownHandle;
1408
+ markdownDestroy(context: NativeContextHandle, doc: ContextMarkdownHandle): void;
1409
+ markdownSetOptions(context: NativeContextHandle, doc: ContextMarkdownHandle, options: NativeMarkdownOptions): NativeMarkdownResult;
1410
+ /** Appends `bytes`, or with `replace` parses them as the whole document. */
1411
+ markdownWrite(context: NativeContextHandle, doc: ContextMarkdownHandle, bytes: Uint8Array, replace: boolean): NativeMarkdownResult;
1412
+ markdownFinish(context: NativeContextHandle, doc: ContextMarkdownHandle): NativeMarkdownResult;
1413
+ /** The source's bytes `start` to `end` (default: all), read in place. */
1414
+ markdownGetSource(context: NativeContextHandle, doc: ContextMarkdownHandle, start?: number, end?: number): string;
1415
+ /** The blocks changed since the last read, in document order; reading acknowledges them. */
1416
+ markdownReadChanges(context: NativeContextHandle, doc: ContextMarkdownHandle, count: number): NativeMarkdownBlock[];
1417
+ /** A paragraph's, heading's or cell's inline source, as an inline hook gets it. */
1418
+ markdownReadSource(context: NativeContextHandle, doc: ContextMarkdownHandle, block: number): string;
1419
+ /** A leaf's parser output with its styles resolved through the doc's style. */
1420
+ markdownReadLeaf(context: NativeContextHandle, doc: ContextMarkdownHandle, block: number): NativeMarkdownLeaf;
1421
+ /** Binds a scene text node to a paragraph or heading, which the doc then writes. */
1422
+ markdownBind(context: NativeContextHandle, doc: ContextMarkdownHandle, block: number, node: SceneNodeHandle): void;
1323
1423
  private encodeStyledText;
1324
1424
  sceneSetSlider(context: NativeContextHandle, node: SceneNodeHandle, options: NativeSceneSliderOptions): void;
1325
1425
  sceneGetSliderThumb(context: NativeContextHandle, node: SceneNodeHandle): {
@@ -1347,7 +1447,7 @@ export declare class FFIRenderLib {
1347
1447
  private sceneTextMetrics;
1348
1448
  sceneGetText(context: NativeContextHandle, node: SceneNodeHandle): string;
1349
1449
  sceneGetTextLineInfo(context: NativeContextHandle, node: SceneNodeHandle, firstLine?: number, lineCount?: number): LineInfo;
1350
- sceneGetLayout(context: NativeContextHandle, node: SceneNodeHandle, observation?: boolean | "paint"): NativeSceneLayout;
1450
+ sceneGetLayout(context: NativeContextHandle, node: SceneNodeHandle, observation?: boolean | "paint" | "content"): NativeSceneLayout;
1351
1451
  sceneSetHooks(context: NativeContextHandle, node: SceneNodeHandle, flags: number, generation: bigint, initialWidth: number, initialHeight: number): void;
1352
1452
  /** Paint options can change between steps; attempt limits remain fixed.
1353
1453
  * A RECORD acknowledgement passes its recording; null records nothing. */
@@ -1363,7 +1463,8 @@ export declare class FFIRenderLib {
1363
1463
  /** Every returned status consumes the draft; an admission exception preserves it for retry. */
1364
1464
  sceneFrameCommit(context: NativeContextHandle, session: SessionHandle, frame: NativeSceneFrameRequest, force: boolean): NativeSessionRenderStatus;
1365
1465
  sceneFrameCancel(context: NativeContextHandle, session: SessionHandle, frameId: bigint): void;
1366
- sceneHitTest(context: NativeContextHandle, session: SessionHandle, x: number, y: number): number;
1466
+ /** `excluded` is a node's public number whose own hits the test skips, or zero. */
1467
+ sceneHitTest(context: NativeContextHandle, session: SessionHandle, x: number, y: number, excluded?: number): number;
1367
1468
  /** @internal Tests set this through `createTestRenderer({ nativeSceneFullFrame })`. */
1368
1469
  sceneSetDebugFlags(context: NativeContextHandle, session: SessionHandle, flags: number): void;
1369
1470
  sceneGetStats(context: NativeContextHandle, session: SessionHandle): NativeRenderStats;