@opentui/core 0.8.3 → 0.9.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 (87) hide show
  1. package/NativeScene.d.ts +13 -2
  2. package/Renderable.d.ts +16 -6
  3. package/ansi.d.ts +1 -1
  4. package/{chunk-bun-psdzwx7h.js → chunk-bun-rgb7yx3r.js} +8959 -9989
  5. package/chunk-bun-rgb7yx3r.js.map +68 -0
  6. package/{chunk-bun-12ttbayv.js → chunk-bun-ywheza3e.js} +664 -102
  7. package/chunk-bun-ywheza3e.js.map +35 -0
  8. package/{chunk-node-drh8dgw6.js → chunk-node-fcberveq.js} +8959 -9989
  9. package/chunk-node-fcberveq.js.map +68 -0
  10. package/{chunk-node-88t8pbzy.js → chunk-node-k5s8s41v.js} +664 -102
  11. package/chunk-node-k5s8s41v.js.map +34 -0
  12. package/edit-buffer.d.ts +40 -5
  13. package/editor-view.d.ts +28 -0
  14. package/index.bun.js +1252 -4790
  15. package/index.bun.js.map +18 -24
  16. package/index.node.js +1252 -4790
  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 +1395 -0
  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 +2 -0
  50. package/renderables/TextTable.d.ts +6 -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.d.ts +4 -0
  70. package/types.d.ts +2 -2
  71. package/yoga.bun.js +1 -1
  72. package/yoga.internal.d.ts +1 -0
  73. package/yoga.js +1 -1
  74. package/zig.d.ts +104 -5
  75. package/chunk-bun-12ttbayv.js.map +0 -35
  76. package/chunk-bun-psdzwx7h.js.map +0 -70
  77. package/chunk-node-88t8pbzy.js.map +0 -34
  78. package/chunk-node-drh8dgw6.js.map +0 -70
  79. package/lib/debounce.d.ts +0 -42
  80. package/lib/extmarks-history.d.ts +0 -17
  81. package/lib/parse.keypress-kitty.d.ts +0 -5
  82. package/lib/queue.d.ts +0 -15
  83. package/lib/stdin-parser.d.ts +0 -97
  84. package/renderables/composition/VRenderable.d.ts +0 -16
  85. package/renderables/composition/constructs.d.ts +0 -35
  86. package/renderables/composition/vnode.d.ts +0 -46
  87. package/renderables/markdown-parser.d.ts +0 -12
@@ -3,18 +3,14 @@ import { type RenderContext } from "../types.js";
3
3
  import { SyntaxStyle } from "../syntax-style.js";
4
4
  import type { BorderStyle } from "../lib/border.js";
5
5
  import { RGBA, type ColorInput } from "../lib/RGBA.js";
6
- import { type MarkedToken, type Token, type Tokens } from "marked";
7
- import { type TextTableColumnFitter, type TextTableColumnWidthMode, type TextTableContent } from "./TextTable.js";
8
- import type { TreeSitterClient } from "../lib/tree-sitter/index.js";
9
- import { type ParseState } from "./markdown-parser.js";
6
+ import { type TextTableColumnFitter, type TextTableColumnWidthMode } from "./TextTable.js";
7
+ import { type TreeSitterClient } from "../lib/tree-sitter/index.js";
10
8
  export type MarkdownTableStyle = "grid" | "columns";
11
9
  export interface MarkdownTableOptions {
12
10
  /**
13
11
  * Visual style preset for markdown tables.
14
- * - "grid": boxed table with visible borders.
12
+ * - "grid": boxed table with visible borders (the default).
15
13
  * - "columns": borderless columns optimized for separated block output.
16
- *
17
- * Defaults to "columns" in `internalBlockMode: "top-level"`, otherwise "grid".
18
14
  */
19
15
  style?: MarkdownTableStyle;
20
16
  /**
@@ -73,19 +69,13 @@ export interface MarkdownOptions extends RenderableOptions<MarkdownRenderable> {
73
69
  conceal?: boolean;
74
70
  /** Controls concealment inside fenced code blocks rendered by CodeRenderable. */
75
71
  concealCode?: boolean;
72
+ /** Highlights fenced code blocks. Paragraphs, headings and tables never reach it. */
76
73
  treeSitterClient?: TreeSitterClient;
77
74
  /**
78
- * Enable streaming mode for incremental content updates.
79
- *
80
- * Semantics:
81
- * - The trailing markdown block stays unstable while streaming is enabled.
82
- * - Tables render all rows produced by the markdown parser (including trailing rows).
83
- * - Incomplete table rows are normalized by the parser and rendered with empty cells
84
- * where data is missing.
85
- *
86
- * Expectations:
87
- * - Keep this true while chunks are still being appended.
88
- * - Set this to false once streaming is complete to finalize trailing token parsing.
75
+ * Whether more content is still to come. While streaming, the last line shows as far as it is decided: a line
76
+ * that may still become a table row, a fence's end or a heading's underline waits for its end, and an emphasis
77
+ * or code span that has not closed yet draws as if it had. Set it to false once the content is complete; the
78
+ * document then shows as it would from one `content` without streaming.
89
79
  */
90
80
  streaming?: boolean;
91
81
  /**
@@ -93,47 +83,100 @@ export interface MarkdownOptions extends RenderableOptions<MarkdownRenderable> {
93
83
  */
94
84
  tableOptions?: MarkdownTableOptions;
95
85
  /**
96
- * Custom node renderer. Return a Renderable to override default rendering,
97
- * or undefined/null to use default rendering.
86
+ * Custom block renderer, called for each top-level block and each code block at any depth when it is built or
87
+ * changes. Return a Renderable to show instead, or undefined/null for the default rendering, which
88
+ * `context.defaultRender()` also returns.
98
89
  */
99
- renderNode?: (token: Token, context: RenderNodeContext) => Renderable | undefined | null;
90
+ renderBlock?: (block: MarkdownBlock, context: RenderNodeContext) => Renderable | undefined | null;
100
91
  /**
101
- * Internal only.
102
- * - "coalesced": combine ordinary markdown into larger render blocks.
103
- * - "top-level": preserve top-level markdown blocks as separate render blocks.
92
+ * Rewrites the display text of every paragraph, heading and table cell, in lists and quotes too, before it is
93
+ * shown: to show IDs as titled links, for example. Code blocks and `renderBlock` results never reach it. It runs
94
+ * when a block is drawn or changes, and must be synchronous.
104
95
  */
105
- internalBlockMode?: "coalesced" | "top-level";
96
+ inlineHook?: MarkdownInlineHook;
97
+ /** When set, the hook runs only on blocks and cells whose source contains one of these strings. */
98
+ inlineHookFilter?: readonly string[];
99
+ /**
100
+ * Delimiter extensions to parse. `"math"`: `$…$` and `\(…\)` are inline math, and `$$` or `\[` lines open a
101
+ * display math block, a code block of the language `math`.
102
+ */
103
+ extensions?: readonly "math"[];
104
+ }
105
+ /** One piece of a prose block's display text, as an inline hook sees and returns it. */
106
+ export interface MarkdownInlineSpan {
107
+ text: string;
108
+ fg?: RGBA;
109
+ bg?: RGBA;
110
+ attributes?: number;
111
+ /** A hyperlink Markdown already found (a Markdown link, an autolink or a bare URL). */
112
+ link?: {
113
+ url: string;
114
+ };
115
+ /** Whether the span is a code span. Without conceal its text keeps the backticks. */
116
+ code: boolean;
117
+ /** Inline math: its TeX without delimiters. Set only with `extensions: ["math"]`. */
118
+ math?: string;
119
+ /** What a click on the span means to the app, such as a session ID. Never sent to the terminal. */
120
+ target?: string;
106
121
  }
122
+ /** What an inline hook knows about the block or table cell. */
123
+ export interface MarkdownInlineContext {
124
+ /** The block's or cell's Markdown source. */
125
+ source: string;
126
+ conceal: boolean;
127
+ syntaxStyle: SyntaxStyle;
128
+ /** Whether the spans are one table cell's content; false for paragraphs and headings, in lists and quotes too. */
129
+ tableCell: boolean;
130
+ }
131
+ export type MarkdownInlineHook = (spans: MarkdownInlineSpan[], context: MarkdownInlineContext) => MarkdownInlineSpan[];
107
132
  export interface RenderNodeContext {
108
133
  syntaxStyle: SyntaxStyle;
109
134
  conceal: boolean;
110
135
  concealCode: boolean;
111
136
  treeSitterClient?: TreeSitterClient;
112
- /** Creates default renderable for this token */
137
+ /** Creates the default renderable for this block, or returns the one it shows. */
113
138
  defaultRender: () => Renderable | null;
114
139
  }
115
- export type MarkdownCodeBlockRenderer = (token: Tokens.Code, context: RenderNodeContext) => Renderable | undefined | null;
116
- export type MarkdownCodeBlockRendererMap = ReadonlyMap<string, MarkdownCodeBlockRenderer> | Readonly<Record<string, MarkdownCodeBlockRenderer>>;
117
- export declare function createMarkdownCodeBlockRenderer(renderers: MarkdownCodeBlockRendererMap): MarkdownOptions["renderNode"];
118
- interface TableContentCache {
119
- content: TextTableContent;
120
- cellKeys: Uint32Array[];
140
+ export type MarkdownBlockKind = "paragraph" | "heading" | "code" | "html" | "rule" | "table" | "row" | "cell" | "quote" | "list" | "item";
141
+ /** A block of the document, read when a renderer needs it. */
142
+ export interface MarkdownBlock {
143
+ /** The block's id: its place in document order, counting nested blocks. */
144
+ readonly index: number;
145
+ readonly kind: MarkdownBlockKind;
146
+ /** A heading's level, 1 to 6. */
147
+ readonly level?: number;
148
+ /** Whether a list is numbered, and its first number. */
149
+ readonly ordered?: boolean;
150
+ readonly start?: number;
151
+ /** A task item's box; undefined for other items. */
152
+ readonly checked?: boolean;
153
+ /** A code block's language (the first word of its info string; `math` for display math) and info string. */
154
+ readonly lang?: string;
155
+ readonly info?: string;
156
+ /** Whether a code block's closing delimiter arrived. */
157
+ readonly closed?: boolean;
158
+ /** The block's Markdown source. */
159
+ readonly raw: string;
160
+ /** A code block's code, or a paragraph's, heading's or cell's display text; empty for other blocks. */
161
+ readonly text: string;
162
+ readonly children: readonly MarkdownBlock[];
121
163
  }
122
- export interface BlockState {
123
- token: MarkedToken;
124
- tokenRaw: string;
125
- marginTop?: number;
126
- renderable: Renderable;
127
- tableContentCache?: TableContentCache;
128
- tracksInterBlockMargin?: boolean;
129
- /** Whether built-in reconciliation can update this renderable without replacing it. */
130
- canUpdateInPlace: boolean;
164
+ /** A fenced, indented or display math code block. */
165
+ export interface MarkdownCodeBlock extends MarkdownBlock {
166
+ readonly type: "code";
167
+ readonly kind: "code";
168
+ readonly lang: string;
169
+ readonly info: string;
170
+ readonly closed: boolean;
131
171
  }
132
- export type { ParseState };
172
+ export type MarkdownCodeBlockRenderer = (block: MarkdownCodeBlock, context: RenderNodeContext) => Renderable | undefined | null;
173
+ export type MarkdownCodeBlockRendererMap = ReadonlyMap<string, MarkdownCodeBlockRenderer> | Readonly<Record<string, MarkdownCodeBlockRenderer>>;
174
+ export declare function createMarkdownCodeBlockRenderer(renderers: MarkdownCodeBlockRendererMap): MarkdownOptions["renderBlock"];
133
175
  export declare class MarkdownRenderable extends Renderable {
134
176
  static readonly nativeIntegration: NativeRenderableIntegration;
135
177
  private static _capabilitySubscriptions;
136
- private _content;
178
+ private _doc;
179
+ private _shown;
137
180
  private _syntaxStyle;
138
181
  private _fg?;
139
182
  private _bg?;
@@ -141,30 +184,31 @@ export declare class MarkdownRenderable extends Renderable {
141
184
  private _concealCode;
142
185
  private _treeSitterClient?;
143
186
  private _tableOptions?;
144
- private _renderNode?;
145
- private _internalBlockMode;
146
- _parseState: ParseState | null;
187
+ private _renderBlock?;
147
188
  private _streaming;
148
- _blockStates: BlockState[];
149
- _stableBlockCount: number;
189
+ private _inlineHook?;
190
+ private _inlineHookFilter?;
191
+ private _extensions;
192
+ private _styleCopy?;
193
+ private _flags;
194
+ private _before?;
195
+ private _beforeBytes?;
196
+ private _shownInCall?;
150
197
  private _styleDirty;
151
198
  private readonly applyStyleChanges;
152
- private _highlightMarkdownLinks;
153
- private _linkifyMarkdownChunks;
154
- private _ownedStructuredRenderables;
155
- private handleCapabilities;
156
199
  protected _contentDefaultOptions: {
157
200
  content: string;
158
201
  conceal: true;
159
202
  concealCode: false;
160
203
  streaming: false;
161
- internalBlockMode: "coalesced";
162
204
  };
163
205
  constructor(ctx: RenderContext, options: MarkdownOptions);
164
206
  get content(): string;
165
207
  set content(value: string);
166
208
  get syntaxStyle(): SyntaxStyle;
167
209
  set syntaxStyle(value: SyntaxStyle);
210
+ get treeSitterClient(): TreeSitterClient | undefined;
211
+ set treeSitterClient(value: TreeSitterClient | undefined);
168
212
  get fg(): RGBA | undefined;
169
213
  set fg(value: ColorInput | undefined);
170
214
  get bg(): RGBA | undefined;
@@ -177,81 +221,121 @@ export declare class MarkdownRenderable extends Renderable {
177
221
  set streaming(value: boolean);
178
222
  get tableOptions(): MarkdownTableOptions | undefined;
179
223
  set tableOptions(value: MarkdownTableOptions | undefined);
180
- get renderNode(): MarkdownOptions["renderNode"] | undefined;
181
- set renderNode(value: MarkdownOptions["renderNode"] | undefined);
182
- get internalBlockMode(): "coalesced" | "top-level";
183
- set internalBlockMode(value: "coalesced" | "top-level");
224
+ get renderBlock(): MarkdownOptions["renderBlock"] | undefined;
225
+ set renderBlock(value: MarkdownOptions["renderBlock"] | undefined);
226
+ get inlineHook(): MarkdownInlineHook | undefined;
227
+ set inlineHook(value: MarkdownInlineHook | undefined);
228
+ get inlineHookFilter(): readonly string[] | undefined;
229
+ set inlineHookFilter(value: readonly string[] | undefined);
230
+ get extensions(): readonly "math"[];
231
+ set extensions(value: readonly "math"[] | null | undefined);
232
+ /** Each block the document holds, in document order (the index is the block's id), with what shows it. */
233
+ get blocks(): readonly {
234
+ kind: MarkdownBlockKind;
235
+ renderable: Renderable | undefined;
236
+ }[];
237
+ /**
238
+ * How many top-level blocks are final: their rows equal those a render of the finished document draws, except
239
+ * that a link definition arriving after a committed block used its label makes that label a link. It counts from
240
+ * the first block and never goes down while the content only grows.
241
+ */
242
+ get committedBlockCount(): number;
243
+ /**
244
+ * Runs the inline hook again on the paragraphs, headings and table cells it rewrites whose source `select`
245
+ * accepts, for a change only the hook knows about, such as a new title for an ID it links. Nothing is parsed or
246
+ * highlighted again. Does nothing without a hook.
247
+ */
248
+ rerunInlineHook(select: (source: string) => boolean): void;
249
+ /** The `target` of the inline hook span the latest finished frame drew at screen cell (x, y), if any. */
250
+ targetAt(x: number, y: number): string | undefined;
251
+ clearCache(): void;
252
+ refreshStyles(): void;
253
+ private engineFlags;
254
+ private engineOptions;
255
+ /** The style the doc binds: the style itself, or a copy of its definitions when it lives in another Context. */
256
+ private nativeStyle;
257
+ /** Sends changed engine flags; `force` sends the hook filter too. */
258
+ private changeOptions;
259
+ private change;
260
+ /** Whether a removed block's source (before this call) equals a new block's: the same bytes at its range. */
261
+ private sameSource;
262
+ /** Binds a paragraph's or heading's node, which hands it to the doc. */
263
+ private bind;
264
+ /**
265
+ * After an option change, each paragraph and heading goes to the writer the options now give it: the doc does not
266
+ * list a leaf whose output did not change, so the host hands it over or takes it back here.
267
+ */
268
+ private syncLeaves;
269
+ /** Whether the host writes a paragraph or heading: the doc writes only concealed, linked, unhooked text. */
270
+ private hostWrites;
271
+ /**
272
+ * Shows a call's changes: builds or updates each listed block, then drops the renderables of removed blocks. A code
273
+ * block or text that takes a removed one's place, index and kind, keeps its renderable and highlight.
274
+ */
275
+ private apply;
276
+ private refresh;
277
+ private update;
278
+ /** Builds the renderable of block `index` and puts it where `old` was, or last in its parent. */
279
+ private show;
280
+ private showDescendants;
281
+ private subtreeEnd;
282
+ private parentOf;
283
+ /** Whether block `index` lies in a table or a renderer's result without a default, so nothing shows it on its own. */
284
+ private isHidden;
285
+ private rendersCustom;
286
+ /**
287
+ * The renderable of block `index`, a renderer's or the default one, and the default one if it shows (the one shown
288
+ * already, when it is still right).
289
+ */
290
+ private resolve;
291
+ /** The default renderable of block `index`; `current` is kept when it already shows a block of that kind. */
292
+ private buildDefault;
293
+ private setCode;
294
+ /** What a changed block changes besides its own renderable: text the host writes, the table or list around it. */
295
+ private afterChange;
296
+ /**
297
+ * Writes a paragraph, heading or HTML block the host writes: the parser's output, through the inline hook when
298
+ * the doc marked it, with its click targets. An unchanged output is not written again unless `force`.
299
+ */
300
+ private writeProse;
301
+ private spans;
302
+ private hook;
303
+ private tableOf;
304
+ /** The blocks that are children of block `index`, in order. */
305
+ private childrenOf;
306
+ /**
307
+ * Fills a table from its rows and cells: a header row in the heading style, then the body, as wide as the header,
308
+ * each column aligned as its delimiter row says.
309
+ */
310
+ private fillTable;
311
+ /** A cell's content: the parser's output, in the heading style in a header row, through the hook. */
312
+ private readCell;
313
+ /**
314
+ * A list's gaps and its items' markers: numbers align on their right, and the list is loose when items are. With
315
+ * `listed`, only those items changed: they are counted and marked, and the rest is written only when the gap or the
316
+ * marker width changes.
317
+ */
318
+ private updateList;
319
+ /** Whether an item has a blank line after it or between two of its blocks. */
320
+ private isLoose;
321
+ /** The style of text in block `index` that no part of it styles: the text style, under each quote around it. */
322
+ private baseStyle;
323
+ private styleText;
184
324
  private getStyle;
185
- private createChunk;
186
- private createDefaultChunk;
187
- private createInitialStyledText;
188
- private renderInlineContent;
189
- private renderInlineToken;
190
- private renderInlineTokenWithStyle;
191
- private addMarkdownLinkHighlights;
192
- private applyMargins;
193
- private createMarkdownCodeRenderable;
194
- private getBlockquoteContent;
195
- private getBlockquoteBorderColor;
196
- private createBlockquoteRenderable;
197
- private createListRenderable;
198
- private getListItemInputs;
199
- private applyListRenderable;
200
- private createListItemRenderable;
201
- private applyListItemRenderable;
202
- private applyListItemChildren;
203
- private getRenderableListItemTokens;
204
- private applyListChildRenderable;
205
- private destroyListItemChildrenAfter;
206
- private applyListItemMarker;
207
- private createListChildRenderable;
208
- private getHorizontalRuleColor;
209
- private createHorizontalRuleRenderable;
210
- private createCodeRenderable;
211
- private applyMarkdownCodeRenderable;
212
- private applyBlockquoteRenderable;
213
- private applyCodeBlockRenderable;
214
- private shouldRenderSeparately;
215
- private getInterBlockMargin;
216
- private applyInterBlockMargin;
217
- private createMarkdownBlockToken;
218
- private normalizeMarkdownBlockRaw;
219
- private normalizeScrollbackMarkdownBlockRaw;
220
- private isCodeBlockOnlyRenderer;
221
- private buildRenderableTokens;
222
- private buildTopLevelRenderBlocks;
223
- private shouldAddTopLevelMargin;
224
- private isSeparatedTopLevelBlock;
225
- private getTableRowsToRender;
226
- private hashString;
227
- private hashTableToken;
228
- private getTableCellKey;
229
- private createTableDataCellChunks;
230
- private createTableHeaderCellChunks;
231
- private buildTableContentCache;
325
+ /**
326
+ * Styles every renderable again for new colors, a new theme or new table options, and asks the renderers again,
327
+ * since they read the style; nothing is parsed again.
328
+ */
329
+ private restyle;
330
+ /** Builds every block's renderable again (a new renderer), keeping the doc. */
331
+ private rebuild;
332
+ /** A read-only view of block `index` for renderers. */
333
+ private view;
334
+ private leafText;
335
+ private sourceText;
232
336
  private resolveTableStyle;
233
- private usesBorderlessColumnSpacing;
234
337
  private resolveTableRenderableOptions;
235
338
  private applyTableRenderableOptions;
236
- private applyTableOptionsToBlocks;
237
- private createTextTableRenderable;
238
- private createTableBlock;
239
- private getStableBlockCount;
240
- private syncTopLevelBlockState;
241
- private getTopLevelBlockRaw;
242
- private createTopLevelDefaultRenderable;
243
- private createTopLevelRenderable;
244
- private createDefaultRenderable;
245
- private createCustomRenderable;
246
- private createTopLevelCustomRenderable;
247
- private renderCustomNode;
248
- private destroyUnusedDefaultRenderable;
249
- private updateBlockRenderable;
250
- private updateTopLevelBlocks;
251
- private updateBlocks;
252
- private clearBlockStates;
253
- clearCache(): void;
254
- refreshStyles(): void;
255
339
  private markStyleDirty;
256
340
  private rerenderDirtyStyles;
257
341
  _needsLifecyclePass(): boolean;
@@ -36,6 +36,7 @@ export declare class ScrollBoxRenderable extends BoxRenderable {
36
36
  readonly verticalScrollBar: ScrollBoxBar;
37
37
  protected static readonly defaultFocusable = true;
38
38
  private readonly selectionListener;
39
+ private autoScrollOwner?;
39
40
  private autoScrollMouseX;
40
41
  private autoScrollMouseY;
41
42
  private readonly autoScrollThresholdVertical;
@@ -43,7 +44,6 @@ export declare class ScrollBoxRenderable extends BoxRenderable {
43
44
  private readonly autoScrollSpeedSlow;
44
45
  private readonly autoScrollSpeedMedium;
45
46
  private readonly autoScrollSpeedFast;
46
- private isAutoScrolling;
47
47
  private cachedAutoScrollSpeed;
48
48
  private autoScrollAccumulatorX;
49
49
  private autoScrollAccumulatorY;
@@ -104,7 +104,9 @@ export declare class ScrollBoxRenderable extends BoxRenderable {
104
104
  private notifyScroll;
105
105
  /** Runs `callback` once in the next frame, after its layout and before it paints: layout reads in it are current,
106
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. */
107
+ * is hidden; destroying the box drops it. A `Code` block that the frame before painted keeps its last highlight's
108
+ * height through the frame that moves it out of view: a growth hold here reads that height, and for a block that ends
109
+ * above the view the rows in view move in the next frame. `anchor` and sticky bottom hold them. */
108
110
  afterLayout(callback: () => void): void;
109
111
  /** Keeps `node`, a descendant, at its place in the viewport through layout changes, over sticky follow, until the
110
112
  * returned function runs or the node leaves the box. A scroll moves the place it keeps; a scroll to the end or a later
@@ -140,12 +142,15 @@ export declare class ScrollBoxRenderable extends BoxRenderable {
140
142
  /** Thumb geometry is in half cells along the track, as the native slider's. */
141
143
  private thumbPointer;
142
144
  private pressTrack;
145
+ /** A pointer at the position the offset already reflects has nothing to apply: recomputing the offset could move
146
+ * it, by a rounding error or by the clamp on a press before the thumb's exact start. */
143
147
  private dragThumb;
144
148
  private endBarPress;
145
149
  handleKeyPress(key: KeyEvent): boolean;
146
150
  private resetScrollAccumulators;
147
151
  startAutoScroll(mouseX: number, mouseY: number): void;
148
152
  updateAutoScroll(mouseX: number, mouseY: number): void;
153
+ private draggingSelection;
149
154
  stopAutoScroll(): void;
150
155
  private handleAutoScroll;
151
156
  private getAutoScrollDirectionX;
@@ -5,7 +5,6 @@ import type { BaseRenderable, Renderable } from "../Renderable.js";
5
5
  import type { NativeScene } from "../NativeScene.js";
6
6
  import { type NativeSceneRect, type NativeSceneScrollBarOptions, type SceneNodeHandle } from "../zig.js";
7
7
  import type { BoxOptions } from "./Box.js";
8
- import type { VNode } from "./composition/vnode.js";
9
8
  import { type ArrowOptions, type ScrollUnit } from "./ScrollBar.js";
10
9
  import type { ScrollBoxRenderable } from "./ScrollBox.js";
11
10
  export type SceneStyleNode = {
@@ -85,12 +84,12 @@ export declare class ScrollBoxContent extends ScrollBoxSizedPart {
85
84
  constructor(box: ScrollBoxRenderable);
86
85
  protected rect(): NativeSceneRect;
87
86
  private setStyle;
88
- /** @internal Whether children lay out in a row, by the direction native was given. */
87
+ /** @internal Whether children lay out in a row, by the direction and mode native was given. */
89
88
  get _row(): boolean;
90
89
  get viewportCulling(): boolean;
91
90
  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;
91
+ add(obj: Renderable, index?: number): number;
92
+ insertBefore(obj: Renderable, anchor?: Renderable): number;
94
93
  remove(child: BaseRenderable): void;
95
94
  getChildren(): Renderable[];
96
95
  getChildrenCount(): number;
@@ -156,7 +155,7 @@ export declare class ScrollBoxBar extends ScrollBoxPart {
156
155
  handleKeyPress(key: KeyEvent): boolean;
157
156
  }
158
157
  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";
158
+ type ContentLayoutKey = "flexDirection" | "flexWrap" | "layoutMode" | "alignItems" | "alignContent" | "aspectRatio" | "justifyContent" | "alignSelf" | "flexGrow" | "flexShrink" | "flexBasis" | `${"min" | "max"}${"Width" | "Height"}` | `${"padding" | "margin"}${Edges}` | "gap" | "rowGap" | "columnGap";
160
159
  export interface ScrollBoxContent extends ContentLayout {
161
160
  }
162
161
  type ContentLayout = {
@@ -84,7 +84,7 @@ export declare class SelectRenderable extends Renderable {
84
84
  constructor(ctx: RenderContext, options: SelectRenderableOptions);
85
85
  protected renderSelf(buffer: OptimizedBuffer, deltaTime: number): void;
86
86
  get options(): SelectOption[];
87
- set options(options: SelectOption[]);
87
+ set options(options: SelectOption[] | null | undefined);
88
88
  getSelectedOption(): SelectOption | null;
89
89
  getSelectedIndex(): number;
90
90
  moveUp(steps?: number): void;
@@ -114,7 +114,7 @@ export declare class SelectRenderable extends Renderable {
114
114
  set font(font: keyof typeof fonts);
115
115
  set itemSpacing(spacing: number);
116
116
  set fastScrollStep(step: number);
117
- set keyBindings(bindings: SelectKeyBinding[]);
117
+ set keyBindings(bindings: SelectKeyBinding[] | null | undefined);
118
118
  set keyAliasMap(aliases: KeyAliasMap);
119
119
  set selectedIndex(value: number);
120
120
  }
@@ -73,7 +73,7 @@ export declare class TabSelectRenderable extends Renderable {
73
73
  getTabWidth(): number;
74
74
  handleKeyPress(key: KeyEvent): boolean;
75
75
  get options(): TabSelectOption[];
76
- set options(options: TabSelectOption[]);
76
+ set options(options: TabSelectOption[] | null | undefined);
77
77
  set backgroundColor(color: ColorInput);
78
78
  set textColor(color: ColorInput);
79
79
  set focusedBackgroundColor(color: ColorInput);
@@ -91,7 +91,7 @@ export declare class TabSelectRenderable extends Renderable {
91
91
  set wrapSelection(wrap: boolean);
92
92
  get tabWidth(): number;
93
93
  set tabWidth(tabWidth: number);
94
- set keyBindings(bindings: TabSelectKeyBinding[]);
94
+ set keyBindings(bindings: TabSelectKeyBinding[] | null | undefined);
95
95
  set keyAliasMap(aliases: KeyAliasMap);
96
96
  }
97
97
  export {};
@@ -26,8 +26,10 @@ export declare class TextRenderable extends TextBufferRenderable {
26
26
  _needsLifecyclePass(): boolean;
27
27
  requestRender(): void;
28
28
  add(obj: TextNodeRenderable | StyledText | string, index?: number): number;
29
+ add(obj: never, index?: number): number;
29
30
  remove(child: BaseRenderable): void;
30
- insertBefore(obj: BaseRenderable | any, anchor?: TextNodeRenderable): number;
31
+ insertBefore(obj: TextNodeRenderable | StyledText | string, anchor?: TextNodeRenderable): number;
32
+ insertBefore(obj: never, anchor?: never): number;
31
33
  getTextChildren(): BaseRenderable[];
32
34
  clear(): void;
33
35
  protected onFgChanged(newColor: RGBA): void;
@@ -67,6 +67,8 @@ export declare abstract class TextBufferRenderable extends Renderable implements
67
67
  get scrollHeight(): number;
68
68
  get maxScrollY(): number;
69
69
  get maxScrollX(): number;
70
+ /** The cells the text fills: native text leaves its padding out once it has a layout; until then, its box. */
71
+ private get textViewport();
70
72
  protected updateViewportOffset(scrollX?: number, scrollY?: number): void;
71
73
  get plainText(): string;
72
74
  get textLength(): number;
@@ -9,11 +9,14 @@ export type TextTableCellContent = TextChunk[] | null | undefined;
9
9
  export type TextTableContent = TextTableCellContent[][];
10
10
  export type TextTableColumnWidthMode = "content" | "full";
11
11
  export type TextTableColumnFitter = "proportional" | "balanced";
12
+ export type TextTableColumnAlignment = "left" | "center" | "right";
12
13
  export interface TextTableOptions extends RenderableOptions<TextTableRenderable> {
13
14
  content?: TextTableContent;
14
15
  wrapMode?: "none" | "char" | "word";
15
16
  columnWidthMode?: TextTableColumnWidthMode;
16
17
  columnFitter?: TextTableColumnFitter;
18
+ /** Each column's line alignment in its cells, by column; a missing entry is `"left"`. */
19
+ columnAlignments?: TextTableColumnAlignment[];
17
20
  cellPadding?: number;
18
21
  cellPaddingX?: number;
19
22
  cellPaddingY?: number;
@@ -37,6 +40,7 @@ export declare class TextTableRenderable extends Renderable {
37
40
  private _wrapMode;
38
41
  private _columnWidthMode;
39
42
  private _columnFitter;
43
+ private _columnAlignments;
40
44
  private _cellPaddingX;
41
45
  private _cellPaddingY;
42
46
  private _columnGap;
@@ -73,6 +77,8 @@ export declare class TextTableRenderable extends Renderable {
73
77
  set columnWidthMode(value: TextTableColumnWidthMode);
74
78
  get columnFitter(): TextTableColumnFitter;
75
79
  set columnFitter(value: TextTableColumnFitter);
80
+ get columnAlignments(): TextTableColumnAlignment[];
81
+ set columnAlignments(value: TextTableColumnAlignment[] | undefined);
76
82
  get cellPadding(): number;
77
83
  set cellPadding(value: number);
78
84
  get cellPaddingX(): number;
@@ -59,7 +59,8 @@ export declare class TextareaRenderable extends EditBufferRenderable {
59
59
  submit(): boolean;
60
60
  set onSubmit(handler: ((event: SubmitEvent) => void) | undefined);
61
61
  get onSubmit(): ((event: SubmitEvent) => void) | undefined;
62
- set keyBindings(bindings: KeyBinding[]);
62
+ set keyBindings(bindings: KeyBinding[] | null | undefined);
63
63
  set keyAliasMap(aliases: TextareaKeyAliasMap);
64
+ /** Mark endpoints count document display cells, including one per newline. */
64
65
  get extmarks(): ExtmarksController;
65
66
  }
@@ -0,0 +1,40 @@
1
+ import { TreeSitterClient } from "../../lib/tree-sitter/client.js";
2
+ import type { SimpleHighlight } from "../../lib/tree-sitter/types.js";
3
+ export type Filetype = "hide" | "plain" | undefined;
4
+ export declare function grammar(content: string, filetype: string): SimpleHighlight[];
5
+ export declare function rendered(content: string, filetype: Filetype, conceal: boolean): string[];
6
+ export interface Pending {
7
+ id: number;
8
+ content: string;
9
+ filetype: string;
10
+ tag: unknown;
11
+ resolve: (r: {
12
+ highlights?: SimpleHighlight[];
13
+ error?: string;
14
+ }) => void;
15
+ reject: (e: Error) => void;
16
+ }
17
+ export declare class ModelClient extends TreeSitterClient {
18
+ pending: Pending[];
19
+ calls: number;
20
+ tag: (content: string) => unknown;
21
+ constructor();
22
+ highlightOnce(content: string, filetype: string): Promise<{
23
+ highlights?: SimpleHighlight[];
24
+ error?: string;
25
+ }>;
26
+ answered: (tag: unknown) => void;
27
+ reply(index: number): void;
28
+ fail(index: number, answer: boolean): void;
29
+ }
30
+ export declare function rng(seed: number): () => number;
31
+ export declare const pieces: string[];
32
+ export declare function text(r: () => number, max: number): string;
33
+ export declare class Failure extends Error {
34
+ readonly property: string;
35
+ constructor(property: string, message: string);
36
+ }
37
+ export declare const SKIP: Set<string>;
38
+ export declare function fail(property: string, message: string): void;
39
+ export declare const tick: () => Promise<void>;
40
+ export declare function removeChunks<C>(commands: C[], same: (candidate: C[]) => Promise<boolean>): Promise<C[]>;
@@ -1,9 +1,6 @@
1
1
  export * from "./ASCIIFont.js";
2
2
  export * from "./Box.js";
3
3
  export * from "./Code.js";
4
- export * from "./composition/constructs.js";
5
- export * from "./composition/VRenderable.js";
6
- export * from "./composition/vnode.js";
7
4
  export * from "./Diff.js";
8
5
  export * from "./EditBufferRenderable.js";
9
6
  export * from "./EmbeddedTerminal.js";
@@ -13,6 +10,7 @@ export * from "./Image.js";
13
10
  export * from "./Video.js";
14
11
  export * from "./LineNumberRenderable.js";
15
12
  export * from "./Markdown.js";
13
+ export * from "./props.js";
16
14
  export * from "./ScrollBar.js";
17
15
  export { ScrollBoxRenderable, ScrollBoxBar, ScrollBoxContent, ScrollBoxViewport, ScrollBoxWrapper, type ScrollBoxOptions, } from "./ScrollBox.js";
18
16
  export * from "./Select.js";