@opentui/core 0.2.9 → 0.2.11

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.
@@ -1,10 +1,10 @@
1
1
  // @bun
2
2
  import {
3
3
  exports_src
4
- } from "./index-tx8a4862.js";
4
+ } from "./index-hpxarv5s.js";
5
5
  import {
6
6
  __require
7
- } from "./index-t4yn324k.js";
7
+ } from "./index-ysvpktsp.js";
8
8
 
9
9
  // src/runtime-plugin.ts
10
10
  import { existsSync, readFileSync, realpathSync } from "fs";
@@ -418,4 +418,4 @@ function createRuntimePlugin(input = {}) {
418
418
  export { isCoreRuntimeModuleSpecifier, runtimeModuleIdForSpecifier, createRuntimePlugin };
419
419
 
420
420
  //# debugId=4F4ECA92927B118964756E2164756E21
421
- //# sourceMappingURL=index-2rpq11jp.js.map
421
+ //# sourceMappingURL=index-16cethat.js.map
@@ -1,7 +1,7 @@
1
1
  // @bun
2
2
  import {
3
3
  createRuntimePlugin
4
- } from "./index-2rpq11jp.js";
4
+ } from "./index-16cethat.js";
5
5
 
6
6
  // src/runtime-plugin-support-configure.ts
7
7
  var {plugin: registerBunPlugin } = globalThis.Bun;
@@ -41,4 +41,4 @@ function ensureRuntimePluginSupport(options = {}) {
41
41
  export { ensureRuntimePluginSupport };
42
42
 
43
43
  //# debugId=09C0597CB92E654F64756E2164756E21
44
- //# sourceMappingURL=index-75ztg4rr.js.map
44
+ //# sourceMappingURL=index-akz3tpeb.js.map
@@ -134,7 +134,6 @@ import {
134
134
  italic,
135
135
  link,
136
136
  magenta,
137
- main,
138
137
  maybeMakeRenderable,
139
138
  measureText,
140
139
  mergeKeyAliases,
@@ -184,7 +183,7 @@ import {
184
183
  white,
185
184
  wrapWithDelegates,
186
185
  yellow
187
- } from "./index-t4yn324k.js";
186
+ } from "./index-ysvpktsp.js";
188
187
 
189
188
  // src/index.ts
190
189
  var exports_src2 = {};
@@ -194,7 +193,6 @@ __export(exports_src2, {
194
193
  white: () => white,
195
194
  vstyles: () => vstyles,
196
195
  visualizeRenderableTree: () => visualizeRenderableTree,
197
- updateAssets: () => main,
198
196
  underline: () => underline,
199
197
  treeSitterToTextChunks: () => treeSitterToTextChunks,
200
198
  treeSitterToStyledText: () => treeSitterToStyledText,
@@ -8677,6 +8675,204 @@ class MarkdownRenderable extends Renderable {
8677
8675
  renderable.add(this.createMarkdownCodeRenderable(this.getBlockquoteContent(token), `${id}-content`, 0, this._linkifyMarkdownChunks, "markup.quote"));
8678
8676
  return renderable;
8679
8677
  }
8678
+ createListRenderable(token, id, marginBottom = 0) {
8679
+ const list = new BoxRenderable(this.ctx, {
8680
+ id,
8681
+ width: "100%",
8682
+ flexDirection: "column",
8683
+ flexShrink: 0,
8684
+ marginBottom
8685
+ });
8686
+ for (const item of this.getListItemInputs(token, id)) {
8687
+ list.add(this.createListItemRenderable(item));
8688
+ }
8689
+ return list;
8690
+ }
8691
+ getListItemInputs(token, id) {
8692
+ const items = token.items ?? [];
8693
+ const start = token.start === "" || token.start === undefined || token.start === null ? 1 : Number(token.start);
8694
+ const markerWidth = Math.max(1, ...items.map((_2, index) => (token.ordered ? `${start + index}.` : "-").length));
8695
+ return items.map((item, index) => ({
8696
+ item,
8697
+ marker: token.ordered ? `${start + index}.` : "-",
8698
+ markerWidth,
8699
+ id: `${id}-item-${index}`
8700
+ }));
8701
+ }
8702
+ applyListRenderable(renderable, token, previousToken, id, marginBottom = 0) {
8703
+ if (!(renderable instanceof BoxRenderable))
8704
+ return false;
8705
+ renderable.marginBottom = marginBottom;
8706
+ const inputs = this.getListItemInputs(token, id);
8707
+ const previousItems = previousToken?.items ?? [];
8708
+ const rows = renderable.getChildren();
8709
+ for (let index = 0;index < inputs.length; index += 1) {
8710
+ const input = inputs[index];
8711
+ const existing = rows[index];
8712
+ if (existing instanceof BoxRenderable && this.applyListItemRenderable(existing, input, previousItems[index])) {
8713
+ continue;
8714
+ }
8715
+ existing?.destroyRecursively();
8716
+ renderable.add(this.createListItemRenderable(input), index);
8717
+ }
8718
+ for (let index = rows.length - 1;index >= inputs.length; index -= 1) {
8719
+ rows[index]?.destroyRecursively();
8720
+ }
8721
+ return true;
8722
+ }
8723
+ createListItemRenderable(input) {
8724
+ const row = new BoxRenderable(this.ctx, {
8725
+ id: input.id,
8726
+ width: "100%",
8727
+ flexDirection: "row",
8728
+ flexShrink: 0,
8729
+ marginBottom: /\n[ \t]*\n$/.test(input.item.raw) ? 1 : 0
8730
+ });
8731
+ row.add(new TextRenderable(this.ctx, {
8732
+ id: `${input.id}-marker`,
8733
+ content: new StyledText([this.createChunk(input.marker.padStart(input.markerWidth) + " ", "markup.list")]),
8734
+ width: input.markerWidth + 1,
8735
+ flexShrink: 0
8736
+ }));
8737
+ const content = new BoxRenderable(this.ctx, {
8738
+ id: `${input.id}-content`,
8739
+ flexDirection: "column",
8740
+ flexGrow: 1,
8741
+ flexShrink: 1
8742
+ });
8743
+ row.add(content);
8744
+ let pendingMarginTop = 0;
8745
+ for (let index = 0;index < input.item.tokens.length; index += 1) {
8746
+ const child = input.item.tokens[index];
8747
+ if (!child)
8748
+ continue;
8749
+ if (child.type === "checkbox")
8750
+ continue;
8751
+ if (child.type === "space") {
8752
+ pendingMarginTop = Math.max(pendingMarginTop, 1);
8753
+ continue;
8754
+ }
8755
+ const renderable = this.createListChildRenderable(child, `${input.id}-child-${index}`);
8756
+ if (!renderable)
8757
+ continue;
8758
+ if (pendingMarginTop > 0) {
8759
+ renderable.marginTop = pendingMarginTop;
8760
+ pendingMarginTop = 0;
8761
+ }
8762
+ content.add(renderable);
8763
+ }
8764
+ return row;
8765
+ }
8766
+ applyListItemRenderable(row, input, previousItem) {
8767
+ this.applyListItemMarker(row, input);
8768
+ const content = row.getChildren()[1];
8769
+ if (!(content instanceof BoxRenderable))
8770
+ return false;
8771
+ if (previousItem && previousItem.raw === input.item.raw) {
8772
+ return true;
8773
+ }
8774
+ return this.applyListItemChildren(content, input.item, previousItem, input.id);
8775
+ }
8776
+ applyListItemChildren(content, item, previousItem, id) {
8777
+ const previousTokens = previousItem ? this.getRenderableListItemTokens(previousItem) : [];
8778
+ const children = content.getChildren();
8779
+ let childIndex = 0;
8780
+ let pendingMarginTop = 0;
8781
+ for (let tokenIndex = 0;tokenIndex < item.tokens.length; tokenIndex += 1) {
8782
+ const token = item.tokens[tokenIndex];
8783
+ if (!token)
8784
+ continue;
8785
+ if (token.type === "checkbox")
8786
+ continue;
8787
+ if (token.type === "space") {
8788
+ pendingMarginTop = Math.max(pendingMarginTop, 1);
8789
+ continue;
8790
+ }
8791
+ const existing = children[childIndex];
8792
+ const childId = `${id}-child-${tokenIndex}`;
8793
+ if (!existing) {
8794
+ const renderable = this.createListChildRenderable(token, childId);
8795
+ if (!renderable)
8796
+ return false;
8797
+ renderable.marginTop = pendingMarginTop;
8798
+ pendingMarginTop = 0;
8799
+ content.add(renderable, childIndex);
8800
+ childIndex += 1;
8801
+ continue;
8802
+ }
8803
+ if (!this.applyListChildRenderable(existing, token, previousTokens[childIndex], childId)) {
8804
+ return false;
8805
+ }
8806
+ existing.marginTop = pendingMarginTop;
8807
+ pendingMarginTop = 0;
8808
+ childIndex += 1;
8809
+ }
8810
+ this.destroyListItemChildrenAfter(content, childIndex);
8811
+ return true;
8812
+ }
8813
+ getRenderableListItemTokens(item) {
8814
+ const tokens = [];
8815
+ for (const token of item.tokens) {
8816
+ if (token.type === "checkbox" || token.type === "space")
8817
+ continue;
8818
+ tokens.push(token);
8819
+ }
8820
+ return tokens;
8821
+ }
8822
+ applyListChildRenderable(renderable, token, previousToken, id) {
8823
+ if ((token.type === "text" || token.type === "paragraph") && renderable instanceof CodeRenderable) {
8824
+ this.applyMarkdownCodeRenderable(renderable, this.getListChildMarkdownRaw(token), 0);
8825
+ return true;
8826
+ }
8827
+ if (token.type === "list" && renderable instanceof BoxRenderable) {
8828
+ return this.applyListRenderable(renderable, token, previousToken, id);
8829
+ }
8830
+ if (token.type === "code" && renderable instanceof CodeRenderable) {
8831
+ this.applyCodeBlockRenderable(renderable, token, 0);
8832
+ return true;
8833
+ }
8834
+ return previousToken?.raw === token.raw;
8835
+ }
8836
+ destroyListItemChildrenAfter(content, index) {
8837
+ const children = content.getChildren();
8838
+ for (let i = children.length - 1;i >= index; i -= 1) {
8839
+ children[i]?.destroyRecursively();
8840
+ }
8841
+ }
8842
+ getListChildMarkdownRaw(token) {
8843
+ return token.type === "paragraph" ? this.normalizeScrollbackMarkdownBlockRaw(token.raw) : token.raw;
8844
+ }
8845
+ applyListItemMarker(row, input) {
8846
+ const marker = row.getChildren()[0];
8847
+ if (!(marker instanceof TextRenderable))
8848
+ return;
8849
+ const marginBottom = /\n[ \t]*\n$/.test(input.item.raw) ? 1 : 0;
8850
+ const markerWidth = input.markerWidth + 1;
8851
+ const markerText = input.marker.padStart(input.markerWidth) + " ";
8852
+ if (row.marginBottom !== marginBottom)
8853
+ row.marginBottom = marginBottom;
8854
+ if (marker.width !== markerWidth)
8855
+ marker.width = markerWidth;
8856
+ if (marker.chunks[0]?.text !== markerText) {
8857
+ marker.content = new StyledText([this.createChunk(markerText, "markup.list")]);
8858
+ }
8859
+ }
8860
+ createListChildRenderable(token, id) {
8861
+ if (token.type === "text" || token.type === "paragraph") {
8862
+ return this.createMarkdownCodeRenderable(this.getListChildMarkdownRaw(token), id);
8863
+ }
8864
+ if (token.type === "list")
8865
+ return this.createListRenderable(token, id);
8866
+ if (token.type === "code")
8867
+ return this.createCodeRenderable(token, id);
8868
+ if (token.type === "blockquote")
8869
+ return this.createBlockquoteRenderable(token, id);
8870
+ if (token.type === "hr")
8871
+ return this.createHorizontalRuleRenderable(id);
8872
+ if (token.type === "table")
8873
+ return this.createTableBlock(token, id).renderable;
8874
+ return token.raw ? this.createMarkdownCodeRenderable(token.raw, id) : null;
8875
+ }
8680
8876
  createHorizontalRuleRenderable(id, marginBottom = 0) {
8681
8877
  return new BoxRenderable(this.ctx, {
8682
8878
  id,
@@ -9097,6 +9293,11 @@ class MarkdownRenderable extends Renderable {
9097
9293
  renderable2.marginTop = marginTop;
9098
9294
  return { renderable: renderable2 };
9099
9295
  }
9296
+ if (token.type === "list") {
9297
+ const renderable2 = this.createListRenderable(token, id);
9298
+ renderable2.marginTop = marginTop;
9299
+ return { renderable: renderable2 };
9300
+ }
9100
9301
  if (token.type === "hr") {
9101
9302
  const renderable2 = this.createHorizontalRuleRenderable(id);
9102
9303
  renderable2.marginTop = marginTop;
@@ -9142,6 +9343,9 @@ class MarkdownRenderable extends Renderable {
9142
9343
  if (token.type === "blockquote") {
9143
9344
  return this.createBlockquoteRenderable(token, id, marginBottom);
9144
9345
  }
9346
+ if (token.type === "list") {
9347
+ return this.createListRenderable(token, id, marginBottom);
9348
+ }
9145
9349
  if (token.type === "hr") {
9146
9350
  return this.createHorizontalRuleRenderable(id, marginBottom);
9147
9351
  }
@@ -9156,7 +9360,7 @@ class MarkdownRenderable extends Renderable {
9156
9360
  }
9157
9361
  return this.createMarkdownCodeRenderable(token.raw, id, marginBottom);
9158
9362
  }
9159
- updateBlockRenderable(state, token, index, hasNextToken) {
9363
+ updateBlockRenderable(state, token, index, hasNextToken, forceListRefresh = false) {
9160
9364
  const marginBottom = this.getInterBlockMargin(token, hasNextToken);
9161
9365
  if (token.type === "code") {
9162
9366
  this.applyCodeBlockRenderable(state.renderable, token, marginBottom);
@@ -9166,6 +9370,14 @@ class MarkdownRenderable extends Renderable {
9166
9370
  this.applyBlockquoteRenderable(state.renderable, token, marginBottom);
9167
9371
  return;
9168
9372
  }
9373
+ if (token.type === "list") {
9374
+ if (!this.applyListRenderable(state.renderable, token, forceListRefresh ? undefined : state.token, `${this.id}-block-${index}`, marginBottom)) {
9375
+ state.renderable.destroyRecursively();
9376
+ state.renderable = this.createListRenderable(token, `${this.id}-block-${index}`, marginBottom);
9377
+ this.add(state.renderable, index);
9378
+ }
9379
+ return;
9380
+ }
9169
9381
  if (token.type === "hr") {
9170
9382
  state.renderable.marginBottom = marginBottom;
9171
9383
  return;
@@ -9181,7 +9393,7 @@ class MarkdownRenderable extends Renderable {
9181
9393
  }
9182
9394
  state.renderable.destroyRecursively();
9183
9395
  const fallbackRenderable = this.createMarkdownCodeRenderable(tableToken.raw, `${this.id}-block-${index}`, marginBottom);
9184
- this.add(fallbackRenderable);
9396
+ this.add(fallbackRenderable, index);
9185
9397
  state.renderable = fallbackRenderable;
9186
9398
  state.tableContentCache = undefined;
9187
9399
  return;
@@ -9197,7 +9409,7 @@ class MarkdownRenderable extends Renderable {
9197
9409
  }
9198
9410
  state.renderable.destroyRecursively();
9199
9411
  const tableRenderable = this.createTextTableRenderable(cache.content, `${this.id}-block-${index}`, marginBottom);
9200
- this.add(tableRenderable);
9412
+ this.add(tableRenderable, index);
9201
9413
  state.renderable = tableRenderable;
9202
9414
  state.tableContentCache = cache;
9203
9415
  return;
@@ -9272,6 +9484,8 @@ class MarkdownRenderable extends Renderable {
9272
9484
  return renderable instanceof TextTableRenderable;
9273
9485
  if (token.type === "blockquote")
9274
9486
  return renderable instanceof BoxRenderable;
9487
+ if (token.type === "list")
9488
+ return renderable instanceof BoxRenderable;
9275
9489
  if (token.type === "hr")
9276
9490
  return renderable instanceof BoxRenderable;
9277
9491
  return renderable instanceof CodeRenderable;
@@ -9411,6 +9625,10 @@ class MarkdownRenderable extends Renderable {
9411
9625
  this.applyBlockquoteRenderable(state.renderable, state.token, marginBottom);
9412
9626
  continue;
9413
9627
  }
9628
+ if (state.token.type === "list") {
9629
+ this.updateBlockRenderable(state, state.token, i, hasNextToken, true);
9630
+ continue;
9631
+ }
9414
9632
  if (state.token.type === "hr") {
9415
9633
  state.renderable.marginBottom = marginBottom;
9416
9634
  continue;
@@ -11514,5 +11732,5 @@ class TimeToFirstDrawRenderable extends Renderable {
11514
11732
  }
11515
11733
  export { 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, Audio, setupAudio, FrameBufferRenderable, ASCIIFontRenderable, Generic, Box, Text, ASCIIFont, Input, Select, TabSelect, FrameBuffer, Code, ScrollBox, vstyles, VRenderable, LineNumberRenderable, DiffRenderable, defaultTextareaKeyBindings, TextareaRenderable, InputRenderableEvents, InputRenderable, TextTableRenderable, MarkdownRenderable, SliderRenderable, ScrollBarRenderable, ArrowRenderable, ScrollBoxRenderable, SelectRenderableEvents, SelectRenderable, TabSelectRenderableEvents, TabSelectRenderable, TimeToFirstDrawRenderable, exports_src2 as exports_src };
11516
11734
 
11517
- //# debugId=38C52BEFC4FA5FFE64756E2164756E21
11518
- //# sourceMappingURL=index-tx8a4862.js.map
11735
+ //# debugId=FD10850E13870AEB64756E2164756E21
11736
+ //# sourceMappingURL=index-hpxarv5s.js.map