@opentui/core 0.0.0-20251030-1c570263 → 0.0.0-20251102-23e7b561
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/3d.js +1 -1
- package/assets/markdown/highlights.scm +150 -0
- package/assets/markdown/injections.scm +27 -0
- package/assets/markdown/tree-sitter-markdown.wasm +0 -0
- package/assets/markdown_inline/highlights.scm +115 -0
- package/assets/markdown_inline/tree-sitter-markdown_inline.wasm +0 -0
- package/{index-xn9k0wzm.js → index-rzgaxyf4.js} +611 -148
- package/{index-xn9k0wzm.js.map → index-rzgaxyf4.js.map} +16 -15
- package/index.js +82 -17
- package/index.js.map +5 -5
- package/lib/KeyHandler.d.ts +4 -1
- package/lib/index.d.ts +1 -0
- package/lib/parse.keypress.d.ts +1 -0
- package/lib/stdin-buffer.d.ts +42 -0
- package/lib/tree-sitter/client.d.ts +1 -0
- package/lib/tree-sitter/parsers-config.d.ts +38 -0
- package/lib/tree-sitter/types.d.ts +18 -1
- package/lib/tree-sitter-styled-text.d.ts +9 -2
- package/package.json +9 -9
- package/parser.worker.js +250 -27
- package/parser.worker.js.map +3 -3
- package/renderables/Box.d.ts +1 -0
- package/renderables/Code.d.ts +14 -0
- package/syntax-style.d.ts +2 -0
- package/testing.js +1 -1
- package/text-buffer.d.ts +1 -0
- package/zig.d.ts +1 -0
package/index.js
CHANGED
|
@@ -30,6 +30,7 @@ import {
|
|
|
30
30
|
RendererControlState,
|
|
31
31
|
RootRenderable,
|
|
32
32
|
Selection,
|
|
33
|
+
StdinBuffer,
|
|
33
34
|
StyledText,
|
|
34
35
|
TerminalConsole,
|
|
35
36
|
TextAttributes,
|
|
@@ -133,7 +134,7 @@ import {
|
|
|
133
134
|
white,
|
|
134
135
|
wrapWithDelegates,
|
|
135
136
|
yellow
|
|
136
|
-
} from "./index-
|
|
137
|
+
} from "./index-rzgaxyf4.js";
|
|
137
138
|
// src/text-buffer-view.ts
|
|
138
139
|
class TextBufferView {
|
|
139
140
|
lib;
|
|
@@ -860,6 +861,14 @@ class SyntaxStyle {
|
|
|
860
861
|
this.guard();
|
|
861
862
|
return this.mergedCache.size;
|
|
862
863
|
}
|
|
864
|
+
getAllStyles() {
|
|
865
|
+
this.guard();
|
|
866
|
+
return new Map(this.styleDefs);
|
|
867
|
+
}
|
|
868
|
+
getRegisteredNames() {
|
|
869
|
+
this.guard();
|
|
870
|
+
return Array.from(this.styleDefs.keys());
|
|
871
|
+
}
|
|
863
872
|
destroy() {
|
|
864
873
|
if (this._destroyed)
|
|
865
874
|
return;
|
|
@@ -2194,6 +2203,13 @@ class BoxRenderable extends Renderable {
|
|
|
2194
2203
|
this.applyYogaGap(options);
|
|
2195
2204
|
}
|
|
2196
2205
|
}
|
|
2206
|
+
initializeBorder() {
|
|
2207
|
+
if (this._border === false) {
|
|
2208
|
+
this._border = true;
|
|
2209
|
+
this.borderSides = getBorderSides(this._border);
|
|
2210
|
+
this.applyYogaBorders();
|
|
2211
|
+
}
|
|
2212
|
+
}
|
|
2197
2213
|
get customBorderChars() {
|
|
2198
2214
|
return this._customBorderCharsObj;
|
|
2199
2215
|
}
|
|
@@ -2228,9 +2244,10 @@ class BoxRenderable extends Renderable {
|
|
|
2228
2244
|
}
|
|
2229
2245
|
set borderStyle(value) {
|
|
2230
2246
|
let _value = value ?? this._defaultOptions.borderStyle;
|
|
2231
|
-
if (this._borderStyle !== _value) {
|
|
2247
|
+
if (this._borderStyle !== _value || !this._border) {
|
|
2232
2248
|
this._borderStyle = _value;
|
|
2233
2249
|
this._customBorderChars = undefined;
|
|
2250
|
+
this.initializeBorder();
|
|
2234
2251
|
this.requestRender();
|
|
2235
2252
|
}
|
|
2236
2253
|
}
|
|
@@ -2241,6 +2258,7 @@ class BoxRenderable extends Renderable {
|
|
|
2241
2258
|
const newColor = parseColor(value ?? this._defaultOptions.borderColor);
|
|
2242
2259
|
if (this._borderColor !== newColor) {
|
|
2243
2260
|
this._borderColor = newColor;
|
|
2261
|
+
this.initializeBorder();
|
|
2244
2262
|
this.requestRender();
|
|
2245
2263
|
}
|
|
2246
2264
|
}
|
|
@@ -2251,6 +2269,7 @@ class BoxRenderable extends Renderable {
|
|
|
2251
2269
|
const newColor = parseColor(value ?? this._defaultOptions.focusedBorderColor);
|
|
2252
2270
|
if (this._focusedBorderColor !== newColor) {
|
|
2253
2271
|
this._focusedBorderColor = newColor;
|
|
2272
|
+
this.initializeBorder();
|
|
2254
2273
|
if (this._focused) {
|
|
2255
2274
|
this.requestRender();
|
|
2256
2275
|
}
|
|
@@ -2623,8 +2642,14 @@ class CodeRenderable extends TextBufferRenderable {
|
|
|
2623
2642
|
_isHighlighting = false;
|
|
2624
2643
|
_treeSitterClient;
|
|
2625
2644
|
_pendingRehighlight = false;
|
|
2645
|
+
_pendingUpdate = false;
|
|
2646
|
+
_currentHighlightId = 0;
|
|
2647
|
+
_conceal;
|
|
2648
|
+
_drawUnstyledText;
|
|
2626
2649
|
_contentDefaultOptions = {
|
|
2627
|
-
content: ""
|
|
2650
|
+
content: "",
|
|
2651
|
+
conceal: true,
|
|
2652
|
+
drawUnstyledText: true
|
|
2628
2653
|
};
|
|
2629
2654
|
constructor(ctx, options) {
|
|
2630
2655
|
super(ctx, options);
|
|
@@ -2632,6 +2657,8 @@ class CodeRenderable extends TextBufferRenderable {
|
|
|
2632
2657
|
this._filetype = options.filetype;
|
|
2633
2658
|
this._syntaxStyle = options.syntaxStyle;
|
|
2634
2659
|
this._treeSitterClient = options.treeSitterClient ?? getTreeSitterClient();
|
|
2660
|
+
this._conceal = options.conceal ?? this._contentDefaultOptions.conceal;
|
|
2661
|
+
this._drawUnstyledText = options.drawUnstyledText ?? this._contentDefaultOptions.drawUnstyledText;
|
|
2635
2662
|
this.updateContent(this._content);
|
|
2636
2663
|
}
|
|
2637
2664
|
get content() {
|
|
@@ -2640,7 +2667,7 @@ class CodeRenderable extends TextBufferRenderable {
|
|
|
2640
2667
|
set content(value) {
|
|
2641
2668
|
if (this._content !== value) {
|
|
2642
2669
|
this._content = value;
|
|
2643
|
-
this.
|
|
2670
|
+
this.scheduleUpdate();
|
|
2644
2671
|
}
|
|
2645
2672
|
}
|
|
2646
2673
|
get filetype() {
|
|
@@ -2649,7 +2676,7 @@ class CodeRenderable extends TextBufferRenderable {
|
|
|
2649
2676
|
set filetype(value) {
|
|
2650
2677
|
if (this._filetype !== value) {
|
|
2651
2678
|
this._filetype = value;
|
|
2652
|
-
this.
|
|
2679
|
+
this.scheduleUpdate();
|
|
2653
2680
|
}
|
|
2654
2681
|
}
|
|
2655
2682
|
get syntaxStyle() {
|
|
@@ -2658,36 +2685,70 @@ class CodeRenderable extends TextBufferRenderable {
|
|
|
2658
2685
|
set syntaxStyle(value) {
|
|
2659
2686
|
if (this._syntaxStyle !== value) {
|
|
2660
2687
|
this._syntaxStyle = value;
|
|
2661
|
-
this.
|
|
2688
|
+
this.scheduleUpdate();
|
|
2689
|
+
}
|
|
2690
|
+
}
|
|
2691
|
+
get conceal() {
|
|
2692
|
+
return this._conceal;
|
|
2693
|
+
}
|
|
2694
|
+
set conceal(value) {
|
|
2695
|
+
if (this._conceal !== value) {
|
|
2696
|
+
this._conceal = value;
|
|
2697
|
+
this.scheduleUpdate();
|
|
2698
|
+
}
|
|
2699
|
+
}
|
|
2700
|
+
get drawUnstyledText() {
|
|
2701
|
+
return this._drawUnstyledText;
|
|
2702
|
+
}
|
|
2703
|
+
set drawUnstyledText(value) {
|
|
2704
|
+
if (this._drawUnstyledText !== value) {
|
|
2705
|
+
this._drawUnstyledText = value;
|
|
2706
|
+
this.scheduleUpdate();
|
|
2662
2707
|
}
|
|
2663
2708
|
}
|
|
2709
|
+
scheduleUpdate() {
|
|
2710
|
+
if (this._pendingUpdate)
|
|
2711
|
+
return;
|
|
2712
|
+
this._pendingUpdate = true;
|
|
2713
|
+
queueMicrotask(() => {
|
|
2714
|
+
this._pendingUpdate = false;
|
|
2715
|
+
this.updateContent(this._content);
|
|
2716
|
+
});
|
|
2717
|
+
}
|
|
2664
2718
|
async updateContent(content) {
|
|
2665
2719
|
if (content.length === 0)
|
|
2666
2720
|
return;
|
|
2667
|
-
if (this._isHighlighting) {
|
|
2668
|
-
this._pendingRehighlight = true;
|
|
2669
|
-
return;
|
|
2670
|
-
}
|
|
2671
2721
|
if (!this._filetype) {
|
|
2672
2722
|
this.fallback(content);
|
|
2673
2723
|
return;
|
|
2674
2724
|
}
|
|
2675
|
-
this.
|
|
2725
|
+
this._currentHighlightId++;
|
|
2726
|
+
const highlightId = this._currentHighlightId;
|
|
2727
|
+
if (this._drawUnstyledText) {
|
|
2728
|
+
this.fallback(content);
|
|
2729
|
+
}
|
|
2676
2730
|
this._isHighlighting = true;
|
|
2731
|
+
this._pendingRehighlight = false;
|
|
2677
2732
|
try {
|
|
2678
|
-
const styledText = await treeSitterToStyledText(content, this._filetype, this._syntaxStyle, this._treeSitterClient
|
|
2733
|
+
const styledText = await treeSitterToStyledText(content, this._filetype, this._syntaxStyle, this._treeSitterClient, {
|
|
2734
|
+
conceal: { enabled: this._conceal }
|
|
2735
|
+
});
|
|
2736
|
+
if (highlightId !== this._currentHighlightId) {
|
|
2737
|
+
return;
|
|
2738
|
+
}
|
|
2679
2739
|
if (this.isDestroyed)
|
|
2680
2740
|
return;
|
|
2681
2741
|
this.textBuffer.setStyledText(styledText);
|
|
2682
2742
|
this.updateTextInfo();
|
|
2683
2743
|
} catch (error) {
|
|
2744
|
+
if (highlightId !== this._currentHighlightId) {
|
|
2745
|
+
return;
|
|
2746
|
+
}
|
|
2684
2747
|
console.warn("Code highlighting failed, falling back to plain text:", error);
|
|
2685
2748
|
this.fallback(content);
|
|
2686
2749
|
} finally {
|
|
2687
|
-
this.
|
|
2688
|
-
|
|
2689
|
-
this._pendingRehighlight = false;
|
|
2690
|
-
process.nextTick(() => this.updateContent(this._content));
|
|
2750
|
+
if (highlightId === this._currentHighlightId) {
|
|
2751
|
+
this._isHighlighting = false;
|
|
2691
2752
|
}
|
|
2692
2753
|
}
|
|
2693
2754
|
}
|
|
@@ -2710,6 +2771,9 @@ class CodeRenderable extends TextBufferRenderable {
|
|
|
2710
2771
|
];
|
|
2711
2772
|
return new StyledText(chunks);
|
|
2712
2773
|
}
|
|
2774
|
+
getLineHighlights(lineIdx) {
|
|
2775
|
+
return this.textBuffer.getLineHighlights(lineIdx);
|
|
2776
|
+
}
|
|
2713
2777
|
}
|
|
2714
2778
|
// src/renderables/TextNode.ts
|
|
2715
2779
|
var BrandedTextNodeRenderable = Symbol.for("@opentui/core/TextNodeRenderable");
|
|
@@ -6059,6 +6123,7 @@ export {
|
|
|
6059
6123
|
TabSelect,
|
|
6060
6124
|
SyntaxStyle,
|
|
6061
6125
|
StyledText,
|
|
6126
|
+
StdinBuffer,
|
|
6062
6127
|
SliderRenderable,
|
|
6063
6128
|
Selection,
|
|
6064
6129
|
SelectRenderableEvents,
|
|
@@ -6114,5 +6179,5 @@ export {
|
|
|
6114
6179
|
ASCIIFont
|
|
6115
6180
|
};
|
|
6116
6181
|
|
|
6117
|
-
//# debugId=
|
|
6182
|
+
//# debugId=52657F382323749F64756E2164756E21
|
|
6118
6183
|
//# sourceMappingURL=index.js.map
|