@opentui/core 0.0.0-20251029-27ffe014 → 0.0.0-20251031-fc297165
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-vr8t68wb.js} +341 -67
- package/{index-xn9k0wzm.js.map → index-vr8t68wb.js.map} +9 -9
- package/index.js +69 -16
- package/index.js.map +4 -4
- 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/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
|
@@ -133,7 +133,7 @@ import {
|
|
|
133
133
|
white,
|
|
134
134
|
wrapWithDelegates,
|
|
135
135
|
yellow
|
|
136
|
-
} from "./index-
|
|
136
|
+
} from "./index-vr8t68wb.js";
|
|
137
137
|
// src/text-buffer-view.ts
|
|
138
138
|
class TextBufferView {
|
|
139
139
|
lib;
|
|
@@ -860,6 +860,14 @@ class SyntaxStyle {
|
|
|
860
860
|
this.guard();
|
|
861
861
|
return this.mergedCache.size;
|
|
862
862
|
}
|
|
863
|
+
getAllStyles() {
|
|
864
|
+
this.guard();
|
|
865
|
+
return new Map(this.styleDefs);
|
|
866
|
+
}
|
|
867
|
+
getRegisteredNames() {
|
|
868
|
+
this.guard();
|
|
869
|
+
return Array.from(this.styleDefs.keys());
|
|
870
|
+
}
|
|
863
871
|
destroy() {
|
|
864
872
|
if (this._destroyed)
|
|
865
873
|
return;
|
|
@@ -2623,8 +2631,14 @@ class CodeRenderable extends TextBufferRenderable {
|
|
|
2623
2631
|
_isHighlighting = false;
|
|
2624
2632
|
_treeSitterClient;
|
|
2625
2633
|
_pendingRehighlight = false;
|
|
2634
|
+
_pendingUpdate = false;
|
|
2635
|
+
_currentHighlightId = 0;
|
|
2636
|
+
_conceal;
|
|
2637
|
+
_drawUnstyledText;
|
|
2626
2638
|
_contentDefaultOptions = {
|
|
2627
|
-
content: ""
|
|
2639
|
+
content: "",
|
|
2640
|
+
conceal: true,
|
|
2641
|
+
drawUnstyledText: true
|
|
2628
2642
|
};
|
|
2629
2643
|
constructor(ctx, options) {
|
|
2630
2644
|
super(ctx, options);
|
|
@@ -2632,6 +2646,8 @@ class CodeRenderable extends TextBufferRenderable {
|
|
|
2632
2646
|
this._filetype = options.filetype;
|
|
2633
2647
|
this._syntaxStyle = options.syntaxStyle;
|
|
2634
2648
|
this._treeSitterClient = options.treeSitterClient ?? getTreeSitterClient();
|
|
2649
|
+
this._conceal = options.conceal ?? this._contentDefaultOptions.conceal;
|
|
2650
|
+
this._drawUnstyledText = options.drawUnstyledText ?? this._contentDefaultOptions.drawUnstyledText;
|
|
2635
2651
|
this.updateContent(this._content);
|
|
2636
2652
|
}
|
|
2637
2653
|
get content() {
|
|
@@ -2640,7 +2656,7 @@ class CodeRenderable extends TextBufferRenderable {
|
|
|
2640
2656
|
set content(value) {
|
|
2641
2657
|
if (this._content !== value) {
|
|
2642
2658
|
this._content = value;
|
|
2643
|
-
this.
|
|
2659
|
+
this.scheduleUpdate();
|
|
2644
2660
|
}
|
|
2645
2661
|
}
|
|
2646
2662
|
get filetype() {
|
|
@@ -2649,7 +2665,7 @@ class CodeRenderable extends TextBufferRenderable {
|
|
|
2649
2665
|
set filetype(value) {
|
|
2650
2666
|
if (this._filetype !== value) {
|
|
2651
2667
|
this._filetype = value;
|
|
2652
|
-
this.
|
|
2668
|
+
this.scheduleUpdate();
|
|
2653
2669
|
}
|
|
2654
2670
|
}
|
|
2655
2671
|
get syntaxStyle() {
|
|
@@ -2658,36 +2674,70 @@ class CodeRenderable extends TextBufferRenderable {
|
|
|
2658
2674
|
set syntaxStyle(value) {
|
|
2659
2675
|
if (this._syntaxStyle !== value) {
|
|
2660
2676
|
this._syntaxStyle = value;
|
|
2661
|
-
this.
|
|
2677
|
+
this.scheduleUpdate();
|
|
2662
2678
|
}
|
|
2663
2679
|
}
|
|
2680
|
+
get conceal() {
|
|
2681
|
+
return this._conceal;
|
|
2682
|
+
}
|
|
2683
|
+
set conceal(value) {
|
|
2684
|
+
if (this._conceal !== value) {
|
|
2685
|
+
this._conceal = value;
|
|
2686
|
+
this.scheduleUpdate();
|
|
2687
|
+
}
|
|
2688
|
+
}
|
|
2689
|
+
get drawUnstyledText() {
|
|
2690
|
+
return this._drawUnstyledText;
|
|
2691
|
+
}
|
|
2692
|
+
set drawUnstyledText(value) {
|
|
2693
|
+
if (this._drawUnstyledText !== value) {
|
|
2694
|
+
this._drawUnstyledText = value;
|
|
2695
|
+
this.scheduleUpdate();
|
|
2696
|
+
}
|
|
2697
|
+
}
|
|
2698
|
+
scheduleUpdate() {
|
|
2699
|
+
if (this._pendingUpdate)
|
|
2700
|
+
return;
|
|
2701
|
+
this._pendingUpdate = true;
|
|
2702
|
+
queueMicrotask(() => {
|
|
2703
|
+
this._pendingUpdate = false;
|
|
2704
|
+
this.updateContent(this._content);
|
|
2705
|
+
});
|
|
2706
|
+
}
|
|
2664
2707
|
async updateContent(content) {
|
|
2665
2708
|
if (content.length === 0)
|
|
2666
2709
|
return;
|
|
2667
|
-
if (this._isHighlighting) {
|
|
2668
|
-
this._pendingRehighlight = true;
|
|
2669
|
-
return;
|
|
2670
|
-
}
|
|
2671
2710
|
if (!this._filetype) {
|
|
2672
2711
|
this.fallback(content);
|
|
2673
2712
|
return;
|
|
2674
2713
|
}
|
|
2675
|
-
this.
|
|
2714
|
+
this._currentHighlightId++;
|
|
2715
|
+
const highlightId = this._currentHighlightId;
|
|
2716
|
+
if (this._drawUnstyledText) {
|
|
2717
|
+
this.fallback(content);
|
|
2718
|
+
}
|
|
2676
2719
|
this._isHighlighting = true;
|
|
2720
|
+
this._pendingRehighlight = false;
|
|
2677
2721
|
try {
|
|
2678
|
-
const styledText = await treeSitterToStyledText(content, this._filetype, this._syntaxStyle, this._treeSitterClient
|
|
2722
|
+
const styledText = await treeSitterToStyledText(content, this._filetype, this._syntaxStyle, this._treeSitterClient, {
|
|
2723
|
+
conceal: { enabled: this._conceal }
|
|
2724
|
+
});
|
|
2725
|
+
if (highlightId !== this._currentHighlightId) {
|
|
2726
|
+
return;
|
|
2727
|
+
}
|
|
2679
2728
|
if (this.isDestroyed)
|
|
2680
2729
|
return;
|
|
2681
2730
|
this.textBuffer.setStyledText(styledText);
|
|
2682
2731
|
this.updateTextInfo();
|
|
2683
2732
|
} catch (error) {
|
|
2733
|
+
if (highlightId !== this._currentHighlightId) {
|
|
2734
|
+
return;
|
|
2735
|
+
}
|
|
2684
2736
|
console.warn("Code highlighting failed, falling back to plain text:", error);
|
|
2685
2737
|
this.fallback(content);
|
|
2686
2738
|
} finally {
|
|
2687
|
-
this.
|
|
2688
|
-
|
|
2689
|
-
this._pendingRehighlight = false;
|
|
2690
|
-
process.nextTick(() => this.updateContent(this._content));
|
|
2739
|
+
if (highlightId === this._currentHighlightId) {
|
|
2740
|
+
this._isHighlighting = false;
|
|
2691
2741
|
}
|
|
2692
2742
|
}
|
|
2693
2743
|
}
|
|
@@ -2710,6 +2760,9 @@ class CodeRenderable extends TextBufferRenderable {
|
|
|
2710
2760
|
];
|
|
2711
2761
|
return new StyledText(chunks);
|
|
2712
2762
|
}
|
|
2763
|
+
getLineHighlights(lineIdx) {
|
|
2764
|
+
return this.textBuffer.getLineHighlights(lineIdx);
|
|
2765
|
+
}
|
|
2713
2766
|
}
|
|
2714
2767
|
// src/renderables/TextNode.ts
|
|
2715
2768
|
var BrandedTextNodeRenderable = Symbol.for("@opentui/core/TextNodeRenderable");
|
|
@@ -6114,5 +6167,5 @@ export {
|
|
|
6114
6167
|
ASCIIFont
|
|
6115
6168
|
};
|
|
6116
6169
|
|
|
6117
|
-
//# debugId=
|
|
6170
|
+
//# debugId=FA34F12A6B07201B64756E2164756E21
|
|
6118
6171
|
//# sourceMappingURL=index.js.map
|