@opentui/core 0.1.84 → 0.1.86

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.
@@ -0,0 +1,6 @@
1
+ import type { TextChunk } from "../text-buffer";
2
+ import type { SimpleHighlight } from "./tree-sitter/types";
3
+ export declare function detectLinks(chunks: TextChunk[], context: {
4
+ content: string;
5
+ highlights: SimpleHighlight[];
6
+ }): TextChunk[];
package/lib/index.d.ts CHANGED
@@ -16,3 +16,4 @@ export * from "./tree-sitter";
16
16
  export * from "./data-paths";
17
17
  export * from "./extmarks";
18
18
  export * from "./terminal-palette";
19
+ export { detectLinks } from "./detect-links";
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "main": "index.js",
5
5
  "types": "index.d.ts",
6
6
  "type": "module",
7
- "version": "0.1.84",
7
+ "version": "0.1.86",
8
8
  "description": "OpenTUI is a TypeScript library on a native Zig core for building terminal user interfaces (TUIs)",
9
9
  "license": "MIT",
10
10
  "repository": {
@@ -57,11 +57,11 @@
57
57
  "bun-webgpu": "0.1.5",
58
58
  "planck": "^1.4.2",
59
59
  "three": "0.177.0",
60
- "@opentui/core-darwin-x64": "0.1.84",
61
- "@opentui/core-darwin-arm64": "0.1.84",
62
- "@opentui/core-linux-x64": "0.1.84",
63
- "@opentui/core-linux-arm64": "0.1.84",
64
- "@opentui/core-win32-x64": "0.1.84",
65
- "@opentui/core-win32-arm64": "0.1.84"
60
+ "@opentui/core-darwin-x64": "0.1.86",
61
+ "@opentui/core-darwin-arm64": "0.1.86",
62
+ "@opentui/core-linux-x64": "0.1.86",
63
+ "@opentui/core-linux-arm64": "0.1.86",
64
+ "@opentui/core-win32-x64": "0.1.86",
65
+ "@opentui/core-win32-arm64": "0.1.86"
66
66
  }
67
67
  }
@@ -4,12 +4,17 @@ import { TreeSitterClient } from "../lib/tree-sitter";
4
4
  import { TextBufferRenderable, type TextBufferOptions } from "./TextBufferRenderable";
5
5
  import type { OptimizedBuffer } from "../buffer";
6
6
  import type { SimpleHighlight } from "../lib/tree-sitter/types";
7
+ import type { TextChunk } from "../text-buffer";
7
8
  export interface HighlightContext {
8
9
  content: string;
9
10
  filetype: string;
10
11
  syntaxStyle: SyntaxStyle;
11
12
  }
12
13
  export type OnHighlightCallback = (highlights: SimpleHighlight[], context: HighlightContext) => SimpleHighlight[] | undefined | Promise<SimpleHighlight[] | undefined>;
14
+ export interface ChunkRenderContext extends HighlightContext {
15
+ highlights: SimpleHighlight[];
16
+ }
17
+ export type OnChunksCallback = (chunks: TextChunk[], context: ChunkRenderContext) => TextChunk[] | undefined | Promise<TextChunk[] | undefined>;
13
18
  export interface CodeOptions extends TextBufferOptions {
14
19
  content?: string;
15
20
  filetype?: string;
@@ -19,6 +24,7 @@ export interface CodeOptions extends TextBufferOptions {
19
24
  drawUnstyledText?: boolean;
20
25
  streaming?: boolean;
21
26
  onHighlight?: OnHighlightCallback;
27
+ onChunks?: OnChunksCallback;
22
28
  }
23
29
  export declare class CodeRenderable extends TextBufferRenderable {
24
30
  private _content;
@@ -35,6 +41,7 @@ export declare class CodeRenderable extends TextBufferRenderable {
35
41
  private _hadInitialContent;
36
42
  private _lastHighlights;
37
43
  private _onHighlight?;
44
+ private _onChunks?;
38
45
  protected _contentDefaultOptions: {
39
46
  content: string;
40
47
  conceal: true;
@@ -45,7 +52,7 @@ export declare class CodeRenderable extends TextBufferRenderable {
45
52
  get content(): string;
46
53
  set content(value: string);
47
54
  get filetype(): string | undefined;
48
- set filetype(value: string);
55
+ set filetype(value: string | undefined);
49
56
  get syntaxStyle(): SyntaxStyle;
50
57
  set syntaxStyle(value: SyntaxStyle);
51
58
  get conceal(): boolean;
@@ -58,7 +65,10 @@ export declare class CodeRenderable extends TextBufferRenderable {
58
65
  set treeSitterClient(value: TreeSitterClient);
59
66
  get onHighlight(): OnHighlightCallback | undefined;
60
67
  set onHighlight(value: OnHighlightCallback | undefined);
68
+ get onChunks(): OnChunksCallback | undefined;
69
+ set onChunks(value: OnChunksCallback | undefined);
61
70
  get isHighlighting(): boolean;
71
+ protected transformChunks(chunks: TextChunk[], context: ChunkRenderContext): Promise<TextChunk[]>;
62
72
  private ensureVisibleTextBeforeHighlight;
63
73
  private startHighlight;
64
74
  getLineHighlights(lineIdx: number): import("..").Highlight[];
@@ -51,11 +51,23 @@ export interface MarkdownTableOptions {
51
51
  export interface MarkdownOptions extends RenderableOptions<MarkdownRenderable> {
52
52
  content?: string;
53
53
  syntaxStyle: SyntaxStyle;
54
+ /** Controls concealment for markdown syntax markers in markdown text blocks. */
54
55
  conceal?: boolean;
56
+ /** Controls concealment inside fenced code blocks rendered by CodeRenderable. */
57
+ concealCode?: boolean;
55
58
  treeSitterClient?: TreeSitterClient;
56
59
  /**
57
60
  * Enable streaming mode for incremental content updates.
58
- * When true, trailing tokens are kept unstable to handle incomplete content.
61
+ *
62
+ * Semantics:
63
+ * - The trailing markdown block stays unstable while streaming is enabled.
64
+ * - Tables render all rows produced by the markdown parser (including trailing rows).
65
+ * - Incomplete table rows are normalized by the parser and rendered with empty cells
66
+ * where data is missing.
67
+ *
68
+ * Expectations:
69
+ * - Keep this true while chunks are still being appended.
70
+ * - Set this to false once streaming is complete to finalize trailing token parsing.
59
71
  */
60
72
  streaming?: boolean;
61
73
  /**
@@ -71,6 +83,7 @@ export interface MarkdownOptions extends RenderableOptions<MarkdownRenderable> {
71
83
  export interface RenderNodeContext {
72
84
  syntaxStyle: SyntaxStyle;
73
85
  conceal: boolean;
86
+ concealCode: boolean;
74
87
  treeSitterClient?: TreeSitterClient;
75
88
  /** Creates default renderable for this token */
76
89
  defaultRender: () => Renderable | null;
@@ -90,6 +103,7 @@ export declare class MarkdownRenderable extends Renderable {
90
103
  private _content;
91
104
  private _syntaxStyle;
92
105
  private _conceal;
106
+ private _concealCode;
93
107
  private _treeSitterClient?;
94
108
  private _tableOptions?;
95
109
  private _renderNode?;
@@ -97,9 +111,11 @@ export declare class MarkdownRenderable extends Renderable {
97
111
  private _streaming;
98
112
  _blockStates: BlockState[];
99
113
  private _styleDirty;
114
+ private _linkifyMarkdownChunks;
100
115
  protected _contentDefaultOptions: {
101
116
  content: string;
102
117
  conceal: true;
118
+ concealCode: false;
103
119
  streaming: false;
104
120
  };
105
121
  constructor(ctx: RenderContext, options: MarkdownOptions);
@@ -109,6 +125,8 @@ export declare class MarkdownRenderable extends Renderable {
109
125
  set syntaxStyle(value: SyntaxStyle);
110
126
  get conceal(): boolean;
111
127
  set conceal(value: boolean);
128
+ get concealCode(): boolean;
129
+ set concealCode(value: boolean);
112
130
  get streaming(): boolean;
113
131
  set streaming(value: boolean);
114
132
  get tableOptions(): MarkdownTableOptions | undefined;
@@ -119,14 +137,15 @@ export declare class MarkdownRenderable extends Renderable {
119
137
  private renderInlineContent;
120
138
  private renderInlineToken;
121
139
  private renderInlineTokenWithStyle;
122
- private renderHeadingChunks;
123
- private renderParagraphChunks;
124
- private renderBlockquoteChunks;
125
- private renderListChunks;
126
- private renderThematicBreakChunks;
127
- private renderTokenToChunks;
128
- private createTextRenderable;
140
+ private createMarkdownCodeRenderable;
129
141
  private createCodeRenderable;
142
+ private applyMarkdownCodeRenderable;
143
+ private applyCodeBlockRenderable;
144
+ private shouldRenderSeparately;
145
+ private getInterBlockMargin;
146
+ private createMarkdownBlockToken;
147
+ private normalizeMarkdownBlockRaw;
148
+ private buildRenderableTokens;
130
149
  private getTableRowsToRender;
131
150
  private hashString;
132
151
  private hashTableToken;
package/renderer.d.ts CHANGED
@@ -207,6 +207,7 @@ export declare class CliRenderer extends EventEmitter implements RenderContext {
207
207
  private _themeMode;
208
208
  private inputHandlers;
209
209
  private prependedInputHandlers;
210
+ private shouldRestoreModesOnNextFocus;
210
211
  private idleResolvers;
211
212
  private _debugInputs;
212
213
  private _debugModeEnabled;
package/testing.js CHANGED
@@ -4,7 +4,7 @@ import {
4
4
  CliRenderer,
5
5
  TreeSitterClient,
6
6
  resolveRenderLib
7
- } from "./index-qr7b6cvh.js";
7
+ } from "./index-4sjb8n0n.js";
8
8
 
9
9
  // src/testing/test-renderer.ts
10
10
  import { Readable } from "stream";