@fairyhunter13/opentui-core 0.1.98 → 0.1.100

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.
@@ -10424,6 +10424,9 @@ class MarkdownRenderable extends Renderable {
10424
10424
  content: context.content,
10425
10425
  highlights: context.highlights
10426
10426
  });
10427
+ _inlineConcealChunks = (chunks, context) => {
10428
+ return this.buildInlineConcealChunks(chunks, context);
10429
+ };
10427
10430
  _contentDefaultOptions = {
10428
10431
  content: "",
10429
10432
  conceal: true,
@@ -10677,6 +10680,196 @@ class MarkdownRenderable extends Renderable {
10677
10680
  break;
10678
10681
  }
10679
10682
  }
10683
+ buildInlineConcealChunks(chunks, context) {
10684
+ const result = [];
10685
+ try {
10686
+ const parsed = parseMarkdownIncremental(context.content, null, 0);
10687
+ const tokens = parsed.tokens;
10688
+ for (const token of tokens) {
10689
+ this.renderBlockTokenInline(token, result);
10690
+ }
10691
+ } catch {
10692
+ return chunks;
10693
+ }
10694
+ if (result.length > 0 && result[result.length - 1].text === `
10695
+ `) {
10696
+ result.pop();
10697
+ }
10698
+ if (result.length === 0)
10699
+ return chunks;
10700
+ const linked = this._linkifyMarkdownChunks(result, context);
10701
+ if (Array.isArray(linked))
10702
+ return linked;
10703
+ return result;
10704
+ }
10705
+ renderBlockTokenInline(token, chunks) {
10706
+ switch (token.type) {
10707
+ case "heading": {
10708
+ const headingToken = token;
10709
+ const style = `markup.heading.${headingToken.depth}`;
10710
+ for (const child of headingToken.tokens) {
10711
+ this.renderInlineTokenWithStyle(child, chunks, style);
10712
+ }
10713
+ chunks.push(this.createDefaultChunk(`
10714
+ `));
10715
+ break;
10716
+ }
10717
+ case "paragraph": {
10718
+ const paragraphToken = token;
10719
+ this.renderInlineContent(paragraphToken.tokens, chunks);
10720
+ chunks.push(this.createDefaultChunk(`
10721
+ `));
10722
+ break;
10723
+ }
10724
+ case "list": {
10725
+ this.renderListInline(token, chunks, 0);
10726
+ break;
10727
+ }
10728
+ case "blockquote": {
10729
+ const quoteToken = token;
10730
+ for (const child of quoteToken.tokens) {
10731
+ const markedChild = child;
10732
+ if (markedChild.type === "paragraph" && "tokens" in markedChild) {
10733
+ chunks.push(this.createChunk("\u258E ", "markup.quote"));
10734
+ for (const inline of markedChild.tokens) {
10735
+ this.renderInlineTokenWithStyle(inline, chunks, "markup.quote");
10736
+ }
10737
+ chunks.push(this.createDefaultChunk(`
10738
+ `));
10739
+ } else {
10740
+ chunks.push(this.createChunk("\u258E ", "markup.quote"));
10741
+ this.renderBlockTokenInline(markedChild, chunks);
10742
+ }
10743
+ }
10744
+ break;
10745
+ }
10746
+ case "code": {
10747
+ const codeToken = token;
10748
+ const rawStyle = this.getStyle("markup.raw.block");
10749
+ const codeText = codeToken.text;
10750
+ for (const line of codeText.split(`
10751
+ `)) {
10752
+ chunks.push({
10753
+ __isChunk: true,
10754
+ text: " " + line,
10755
+ fg: rawStyle?.fg,
10756
+ bg: rawStyle?.bg,
10757
+ attributes: rawStyle ? createTextAttributes({
10758
+ bold: rawStyle.bold,
10759
+ italic: rawStyle.italic,
10760
+ underline: rawStyle.underline,
10761
+ dim: rawStyle.dim
10762
+ }) : 0
10763
+ });
10764
+ chunks.push(this.createDefaultChunk(`
10765
+ `));
10766
+ }
10767
+ break;
10768
+ }
10769
+ case "html": {
10770
+ chunks.push(this.createDefaultChunk(token.text));
10771
+ chunks.push(this.createDefaultChunk(`
10772
+ `));
10773
+ break;
10774
+ }
10775
+ case "hr": {
10776
+ const hrStyle = this.getStyle("punctuation.special");
10777
+ chunks.push({
10778
+ __isChunk: true,
10779
+ text: "\u2500".repeat(40),
10780
+ fg: hrStyle?.fg,
10781
+ bg: hrStyle?.bg,
10782
+ attributes: hrStyle ? createTextAttributes({
10783
+ bold: hrStyle.bold,
10784
+ italic: hrStyle.italic,
10785
+ underline: hrStyle.underline,
10786
+ dim: hrStyle.dim
10787
+ }) : 0
10788
+ });
10789
+ chunks.push(this.createDefaultChunk(`
10790
+ `));
10791
+ break;
10792
+ }
10793
+ case "table": {
10794
+ chunks.push(this.createDefaultChunk(token.raw ?? ""));
10795
+ chunks.push(this.createDefaultChunk(`
10796
+ `));
10797
+ break;
10798
+ }
10799
+ case "def":
10800
+ break;
10801
+ case "space":
10802
+ chunks.push(this.createDefaultChunk(`
10803
+ `));
10804
+ break;
10805
+ default:
10806
+ if ("tokens" in token && Array.isArray(token.tokens)) {
10807
+ this.renderInlineContent(token.tokens, chunks);
10808
+ } else {
10809
+ chunks.push(this.createDefaultChunk(token.raw ?? ""));
10810
+ }
10811
+ chunks.push(this.createDefaultChunk(`
10812
+ `));
10813
+ break;
10814
+ }
10815
+ }
10816
+ renderListInline(list, chunks, depth) {
10817
+ const listStyle = this.getStyle("markup.list");
10818
+ const checkedStyle = this.getStyle("markup.list.checked");
10819
+ const uncheckedStyle = this.getStyle("markup.list.unchecked");
10820
+ for (let i = 0;i < list.items.length; i++) {
10821
+ const item = list.items[i];
10822
+ const indent = " ".repeat(depth);
10823
+ const start = typeof list.start === "number" ? list.start : 1;
10824
+ if (item.task) {
10825
+ const checkmark = item.checked ? "\u2611 " : "\u2610 ";
10826
+ const checkStyle = item.checked ? checkedStyle : uncheckedStyle;
10827
+ chunks.push({
10828
+ __isChunk: true,
10829
+ text: indent + checkmark,
10830
+ fg: checkStyle?.fg ?? listStyle?.fg,
10831
+ bg: checkStyle?.bg ?? listStyle?.bg,
10832
+ attributes: checkStyle ? createTextAttributes({
10833
+ bold: checkStyle.bold,
10834
+ italic: checkStyle.italic,
10835
+ underline: checkStyle.underline,
10836
+ dim: checkStyle.dim
10837
+ }) : 0
10838
+ });
10839
+ } else {
10840
+ const bullet = list.ordered ? `${start + i}. ` : "\u2022 ";
10841
+ chunks.push({
10842
+ __isChunk: true,
10843
+ text: indent + bullet,
10844
+ fg: listStyle?.fg,
10845
+ bg: listStyle?.bg,
10846
+ attributes: listStyle ? createTextAttributes({
10847
+ bold: listStyle.bold,
10848
+ italic: listStyle.italic,
10849
+ underline: listStyle.underline,
10850
+ dim: listStyle.dim
10851
+ }) : 0
10852
+ });
10853
+ }
10854
+ for (const subToken of item.tokens) {
10855
+ const markedSub = subToken;
10856
+ if (markedSub.type === "text" && "tokens" in markedSub && Array.isArray(markedSub.tokens)) {
10857
+ this.renderInlineContent(markedSub.tokens, chunks);
10858
+ } else if (markedSub.type === "list") {
10859
+ chunks.push(this.createDefaultChunk(`
10860
+ `));
10861
+ this.renderListInline(markedSub, chunks, depth + 1);
10862
+ continue;
10863
+ } else if (markedSub.type === "paragraph" && "tokens" in markedSub) {
10864
+ this.renderInlineContent(markedSub.tokens, chunks);
10865
+ } else {
10866
+ this.renderInlineToken(markedSub, chunks);
10867
+ }
10868
+ }
10869
+ chunks.push(this.createDefaultChunk(`
10870
+ `));
10871
+ }
10872
+ }
10680
10873
  createMarkdownCodeRenderable(content, id, marginBottom = 0) {
10681
10874
  return new CodeRenderable(this.ctx, {
10682
10875
  id,
@@ -10688,7 +10881,7 @@ class MarkdownRenderable extends Renderable {
10688
10881
  conceal: this._conceal,
10689
10882
  drawUnstyledText: true,
10690
10883
  streaming: true,
10691
- onChunks: this._linkifyMarkdownChunks,
10884
+ onChunks: this._conceal ? this._inlineConcealChunks : this._linkifyMarkdownChunks,
10692
10885
  treeSitterClient: this._treeSitterClient,
10693
10886
  width: "100%",
10694
10887
  marginBottom
@@ -10719,6 +10912,7 @@ class MarkdownRenderable extends Renderable {
10719
10912
  renderable.conceal = this._conceal;
10720
10913
  renderable.drawUnstyledText = true;
10721
10914
  renderable.streaming = true;
10915
+ renderable.onChunks = this._conceal ? this._inlineConcealChunks : this._linkifyMarkdownChunks;
10722
10916
  renderable.marginBottom = marginBottom;
10723
10917
  }
10724
10918
  applyCodeBlockRenderable(renderable, token, marginBottom) {
@@ -13274,5 +13468,5 @@ class TimeToFirstDrawRenderable extends Renderable {
13274
13468
  }
13275
13469
  export { TextBufferView, EditBuffer, EditorView, convertThemeToStyles, SyntaxStyle, DistortionEffect, VignetteEffect, CloudsEffect, FlamesEffect, CRTRollingBarEffect, RainbowTextEffect, applyScanlines, applyInvert, applyNoise, applyChromaticAberration, applyAsciiArt, applyBrightness, applyGain, applySaturation, BloomEffect, SEPIA_MATRIX, PROTANOPIA_SIM_MATRIX, DEUTERANOPIA_SIM_MATRIX, TRITANOPIA_SIM_MATRIX, ACHROMATOPSIA_MATRIX, PROTANOPIA_COMP_MATRIX, DEUTERANOPIA_COMP_MATRIX, TRITANOPIA_COMP_MATRIX, TECHNICOLOR_MATRIX, SOLARIZATION_MATRIX, SYNTHWAVE_MATRIX, GREENSCALE_MATRIX, GRAYSCALE_MATRIX, INVERT_MATRIX, Timeline, engine, createTimeline, SlotRegistry, createSlotRegistry, createCoreSlotRegistry, registerCorePlugin, resolveCoreSlot, SlotRenderable, NativeSpanFeed, FrameBufferRenderable, ASCIIFontRenderable, BoxRenderable, TextBufferRenderable, CodeRenderable, isTextNodeRenderable, TextNodeRenderable, RootTextNodeRenderable, Generic, Box, Text, ASCIIFont, Input, Select, TabSelect, FrameBuffer, Code, ScrollBox, vstyles, VRenderable, LineNumberRenderable, TextRenderable, DiffRenderable, TextareaRenderable, InputRenderableEvents, InputRenderable, TextTableRenderable, MarkdownRenderable, SliderRenderable, ScrollBarRenderable, ArrowRenderable, ScrollBoxRenderable, SelectRenderableEvents, SelectRenderable, TabSelectRenderableEvents, TabSelectRenderable, TimeToFirstDrawRenderable, exports_src2 as exports_src };
13276
13470
 
13277
- //# debugId=DEBC6970CBDDAEE064756E2164756E21
13278
- //# sourceMappingURL=index-ac0yr0h5.js.map
13471
+ //# debugId=58C0D9F658E8DF0264756E2164756E21
13472
+ //# sourceMappingURL=index-apxf6k5b.js.map