@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/edit-buffer.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { type LogicalCursor, type RenderLib, type ContextEditBufferHandle } from "./zig.js";
1
+ import { NativeEditMarkOperation, type LogicalCursor, type NativeEditMark, type RenderLib, type ContextEditBufferHandle } from "./zig.js";
2
2
  import { type WidthMethod, type Highlight } from "./types.js";
3
3
  import { RGBA } from "./lib/RGBA.js";
4
4
  import { EventEmitter } from "events";
@@ -17,7 +17,14 @@ export declare class EditBuffer extends EventEmitter {
17
17
  private _destroyed;
18
18
  private _syntaxStyle?;
19
19
  constructor(lib: RenderLib, handle: ContextEditBufferHandle, source: NativeResourceOwner);
20
- static create(widthMethod: WidthMethod, source: NativeResourceOwner): EditBuffer;
20
+ /**
21
+ * With `followSessionWidth`, the buffer measures with the width method of the renderer whose scene shows it,
22
+ * including when the terminal's replies change that method; the cursor, selections, marks and undo points keep
23
+ * their text. Otherwise it keeps `widthMethod`. One renderer at a time may show such a buffer: showing it in another
24
+ * one throws until the first stops showing it (`NativeError` with `status === NativeStatus.WrongSession`).
25
+ */
26
+ static create(widthMethod: WidthMethod, source: NativeResourceOwner, followSessionWidth?: boolean): EditBuffer;
27
+ get isDestroyed(): boolean;
21
28
  private guard;
22
29
  /** @internal Editor views must use the buffer's library and Context. */
23
30
  _getOwner(): ResourceContext;
@@ -28,6 +35,8 @@ export declare class EditBuffer extends EventEmitter {
28
35
  private position;
29
36
  private highlight;
30
37
  private setDefaults;
38
+ /** @internal Called when text replacement drops the marks with the history, or on destroy: nothing can restore them. */
39
+ _onHistoryReset?: () => void;
31
40
  private setNativeText;
32
41
  /**
33
42
  * Set text and completely reset the buffer state (clears history, resets add_buffer).
@@ -44,37 +53,61 @@ export declare class EditBuffer extends EventEmitter {
44
53
  /** Historical name for copied text replacement that preserves undo history. */
45
54
  replaceTextOwned(text: string): void;
46
55
  getLineCount(): number;
56
+ /** Sets the fixed width of each tab in display cells. */
47
57
  setTabWidth(width: number): void;
58
+ /** Returns the fixed width of each tab in display cells. */
48
59
  getTabWidth(): number;
60
+ /** Returns the buffer text with LF line breaks. JavaScript indexes this string in UTF-16 code units. */
49
61
  getText(): string;
50
62
  insertChar(char: string): void;
51
63
  insertText(text: string): void;
64
+ /** @internal Set by extmarks controllers: whether the cursor rules around virtual extmarks apply now. */
65
+ _atomic?: () => boolean;
66
+ private rules;
52
67
  deleteChar(): void;
53
68
  deleteCharBackward(): void;
69
+ /** Deletes a half-open range between (zero-based logical line, display-cell column) pairs. */
54
70
  deleteRange(startLine: number, startCol: number, endLine: number, endCol: number): void;
55
71
  newLine(): void;
56
72
  deleteLine(): void;
73
+ /** Moves to the previous cursor stop, not necessarily one display cell or UTF-16 code unit. */
57
74
  moveCursorLeft(): void;
75
+ /** Moves to the next cursor stop, not necessarily one display cell or UTF-16 code unit. */
58
76
  moveCursorRight(): void;
77
+ /** Moves up one logical line using the desired display-cell column. */
59
78
  moveCursorUp(): void;
79
+ /** Moves down one logical line using the desired display-cell column. */
60
80
  moveCursorDown(): void;
81
+ /** Moves to a zero-based logical line. */
61
82
  gotoLine(line: number): void;
83
+ /** Sets the cursor by zero-based logical line and display-cell column. */
62
84
  setCursor(line: number, col: number): void;
85
+ /** Sets the cursor by zero-based logical line and display-cell column. */
63
86
  setCursorToLineCol(line: number, col: number): void;
87
+ /** Sets the cursor in display cells from the document start, counting each newline as one cell. Offsets past the end clamp to the end. */
64
88
  setCursorByOffset(offset: number): void;
89
+ /** @internal Moves a cursor inside virtual extmarks to their outer edge: the end (> 0), the start (< 0) or nearer. */
90
+ _keepOutside(direction: number): void;
91
+ /** Returns the logical line, display-cell column, and document cell offset (one cell per newline). */
65
92
  getCursorPosition(): LogicalCursor;
93
+ /** Returns the next word boundary in logical line and cell coordinates. */
66
94
  getNextWordBoundary(): LogicalCursor;
95
+ /** Returns the previous word boundary in logical line and cell coordinates. */
67
96
  getPrevWordBoundary(): LogicalCursor;
97
+ /** Returns the logical line end in display cells. */
68
98
  getEOL(): LogicalCursor;
69
- /** @internal Extmarks read the end without moving the cursor. */
70
- _getEOF(): LogicalCursor;
71
- /** @internal Extmarks read where Left would move without moving the cursor. */
72
- _getPrevCharBoundary(): LogicalCursor;
99
+ /** @internal Extmarks are stored in the native buffer, which moves them with edits, undo and redo. */
100
+ _mark(operation: NativeEditMarkOperation, mark?: Partial<NativeEditMark>): number;
101
+ /** @internal */
102
+ _getMarks(id?: number, kind?: number): NativeEditMark[];
103
+ /** Maps document cells (one per newline) to a logical row and cell column, not a string index. */
73
104
  offsetToPosition(offset: number): {
74
105
  row: number;
75
106
  col: number;
76
107
  } | null;
108
+ /** Maps a logical row and cell column to document cells, counting one cell per newline. */
77
109
  positionToOffset(row: number, col: number): number;
110
+ /** Returns a logical line's start in document cells, counting one cell per newline. */
78
111
  getLineStartOffset(row: number): number;
79
112
  /**
80
113
  * Returns the global display offset at the end of `text` as this buffer would lay it out, without storing it: its
@@ -82,7 +115,13 @@ export declare class EditBuffer extends EventEmitter {
82
115
  * `measureEditText()` to measure without a buffer.
83
116
  */
84
117
  measureText(text: string): number;
118
+ /** Converts a UTF-16 index in getText() to document cells (one per newline). Rounds down within a grapheme; clamps at EOF. */
119
+ stringIndexToCellOffset(index: number): number;
120
+ /** Converts document cells to a UTF-16 index in getText(). Rounds down within a grapheme, past zero-width text at a tie, and clamps at EOF. */
121
+ cellOffsetToStringIndex(offset: number): number;
122
+ /** Reads [startOffset, endOffset) in document display cells, counting one cell per newline. */
85
123
  getTextRange(startOffset: number, endOffset: number): string;
124
+ /** Reads a half-open range between (zero-based logical row, display-cell column) pairs. */
86
125
  getTextRangeByCoords(startRow: number, startCol: number, endRow: number, endCol: number): string;
87
126
  debugLogRope(): void;
88
127
  undo(): string | null;
@@ -96,7 +135,9 @@ export declare class EditBuffer extends EventEmitter {
96
135
  resetDefaults(): void;
97
136
  setSyntaxStyle(style: SyntaxStyle | null): void;
98
137
  getSyntaxStyle(): SyntaxStyle | null;
138
+ /** Highlights a range in display cells relative to the logical line. */
99
139
  addHighlight(lineIdx: number, highlight: Highlight): void;
140
+ /** Highlights a range in document display cells excluding newlines, not UTF-16 indices. */
100
141
  addHighlightByCharRange(highlight: Highlight): void;
101
142
  removeHighlightsByRef(hlRef: number): void;
102
143
  clearLineHighlights(lineIdx: number): void;
package/editor-view.d.ts CHANGED
@@ -34,43 +34,71 @@ export declare class EditorView {
34
34
  setWrapMode(mode: "none" | "char" | "word"): void;
35
35
  getVirtualLineCount(): number;
36
36
  getTotalVirtualLineCount(): number;
37
+ /** Selects [start, end) in document display cells, counting each newline as one. */
37
38
  setSelection(start: number, end: number, bgColor?: RGBA, fgColor?: RGBA): void;
39
+ /** Sets the exclusive end in document display cells, counting each newline as one. */
38
40
  updateSelection(end: number, bgColor?: RGBA, fgColor?: RGBA): void;
39
41
  resetSelection(): void;
42
+ /** Returns half-open bounds in document display cells, counting each newline as one. */
40
43
  getSelection(): {
41
44
  start: number;
42
45
  end: number;
43
46
  } | null;
44
47
  hasSelection(): boolean;
48
+ /** Selects between viewport-local positions: x in display cells, y in wrapped rows. */
45
49
  setLocalSelection(anchorX: number, anchorY: number, focusX: number, focusY: number, bgColor?: RGBA, fgColor?: RGBA, updateCursor?: boolean, followCursor?: boolean, behavior?: SelectionBehavior): boolean;
50
+ /** Updates the selection between viewport-local cell columns and wrapped rows. */
46
51
  updateLocalSelection(anchorX: number, anchorY: number, focusX: number, focusY: number, bgColor?: RGBA, fgColor?: RGBA, updateCursor?: boolean, followCursor?: boolean, behavior?: SelectionBehavior): boolean;
47
52
  resetLocalSelection(): void;
48
53
  convertSelectionToCell(): boolean;
49
54
  setSelectionOccupancy(occupancy: SelectionOccupancy): void;
50
55
  getSelectionOccupancy(): SelectionOccupancy;
56
+ /** Selects document cell offsets (one per newline); cell occupancy includes the grapheme at the larger endpoint. */
51
57
  setSelectionInclusive(start: number, end: number, bgColor?: RGBA, fgColor?: RGBA): void;
52
58
  setSelectionColors(bgColor?: RGBA, fgColor?: RGBA): void;
59
+ /** Returns selected text as a UTF-16-indexed JavaScript string. */
53
60
  getSelectedText(): string;
61
+ /** Returns the zero-based logical row and display-cell column. */
54
62
  getCursor(): {
55
63
  row: number;
56
64
  col: number;
57
65
  };
66
+ /** Returns the buffer text as a UTF-16-indexed JavaScript string. */
58
67
  getText(): string;
68
+ /** Returns viewport and logical cell coordinates; the offset counts document cells, one per newline. */
59
69
  getVisualCursor(): VisualCursor;
70
+ /** @internal Set while an extmarks controller lives: Up and Down apply the cursor rules around virtual extmarks. */
71
+ _atomic: boolean;
72
+ private rules;
73
+ /** Moves the cursor up one wrapped row in the view. */
60
74
  moveUpVisual(): void;
75
+ /** Moves the cursor down one wrapped row in the view. */
61
76
  moveDownVisual(): void;
62
77
  deleteSelectedText(): void;
63
78
  /** @internal The native controller replaces a selection in one checked operation. */
64
79
  _replaceSelectedText(text: string): NativeEditorReplacement;
80
+ /** Sets the cursor in document display cells, counting each newline as one. Offsets past the end clamp to the end. */
65
81
  setCursorByOffset(offset: number): void;
82
+ /** Returns the next word boundary in logical and viewport cell coordinates. */
66
83
  getNextWordBoundary(): VisualCursor;
84
+ /** Returns the previous word boundary in logical and viewport cell coordinates. */
67
85
  getPrevWordBoundary(): VisualCursor;
86
+ /** Returns the logical line end in logical and viewport cell coordinates. */
68
87
  getEOL(): VisualCursor;
88
+ /** Returns the wrapped row start in logical and viewport cell coordinates. */
69
89
  getVisualSOL(): VisualCursor;
90
+ /** Returns the wrapped row end in logical and viewport cell coordinates. */
70
91
  getVisualEOL(): VisualCursor;
71
92
  gotoVisualLineEnd(): void;
72
93
  getLineInfo(): LineInfo;
73
94
  getLogicalLineInfo(): LineInfo;
95
+ /**
96
+ * @internal A cursor that a wheel step, a pointer or the offset setter left inside virtual extmarks goes to the outer
97
+ * edge of the marks around it: toward the end for a positive `direction`, the start for a negative one, or the nearer
98
+ * edge. Only with an extmarks controller, and not while a selection is left: it holds the cursor at its focus.
99
+ */
100
+ _keepCursorOutside(direction: number): void;
101
+ /** Marks use half-open document cell ranges, counting each newline as one. */
74
102
  get extmarks(): any;
75
103
  setPlaceholderStyledText(chunks: {
76
104
  text: string;