@opentui/core 0.2.15 → 0.2.16
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/{index-yyyfmp8n.js → index-hzcw4q21.js} +84 -32
- package/{index-yyyfmp8n.js.map → index-hzcw4q21.js.map} +5 -5
- package/{index-pzzbb0f6.js → index-qe67qr6s.js} +3 -3
- package/{index-3fq5hq97.js → index-qfwqv8y3.js} +143 -19
- package/{index-3fq5hq97.js.map → index-qfwqv8y3.js.map} +8 -8
- package/{index-bdfngvbe.js → index-t1vzaxv4.js} +2 -2
- package/index.js +2 -2
- package/lib/extmarks.d.ts +1 -0
- package/package.json +7 -7
- package/renderables/Input.d.ts +5 -0
- package/renderables/Markdown.d.ts +2 -1
- package/renderables/ScrollBox.d.ts +1 -0
- package/renderer.d.ts +29 -9
- package/runtime-plugin-support-configure.js +4 -4
- package/runtime-plugin-support.js +4 -4
- package/runtime-plugin.js +3 -3
- package/testing/test-recorder.d.ts +4 -4
- package/testing/test-renderer.d.ts +34 -2
- package/testing.d.ts +1 -0
- package/testing.js +283 -17
- package/testing.js.map +6 -5
- package/zig-structs.d.ts +10 -0
- package/zig.d.ts +3 -2
- /package/{index-pzzbb0f6.js.map → index-qe67qr6s.js.map} +0 -0
- /package/{index-bdfngvbe.js.map → index-t1vzaxv4.js.map} +0 -0
|
@@ -183,7 +183,7 @@ import {
|
|
|
183
183
|
white,
|
|
184
184
|
wrapWithDelegates,
|
|
185
185
|
yellow
|
|
186
|
-
} from "./index-
|
|
186
|
+
} from "./index-qfwqv8y3.js";
|
|
187
187
|
|
|
188
188
|
// src/index.ts
|
|
189
189
|
var exports_src2 = {};
|
|
@@ -5782,17 +5782,23 @@ var InputRenderableEvents;
|
|
|
5782
5782
|
|
|
5783
5783
|
class InputRenderable extends TextareaRenderable {
|
|
5784
5784
|
_maxLength;
|
|
5785
|
+
_minLength;
|
|
5785
5786
|
_lastCommittedValue = "";
|
|
5786
5787
|
static defaultOptions = {
|
|
5787
5788
|
placeholder: "",
|
|
5788
5789
|
maxLength: 1000,
|
|
5790
|
+
minLength: 0,
|
|
5789
5791
|
value: ""
|
|
5790
5792
|
};
|
|
5791
5793
|
constructor(ctx, options) {
|
|
5792
5794
|
const defaults = InputRenderable.defaultOptions;
|
|
5793
5795
|
const maxLength = options.maxLength ?? defaults.maxLength;
|
|
5796
|
+
const minLength = options.minLength ?? defaults.minLength;
|
|
5794
5797
|
const rawValue = options.value ?? defaults.value;
|
|
5795
5798
|
const initialValue = rawValue.replace(/[\n\r]/g, "").substring(0, maxLength);
|
|
5799
|
+
if (minLength > maxLength) {
|
|
5800
|
+
throw new Error(`InputRenderable: minLength (${minLength}) cannot be greater than maxLength (${maxLength})`);
|
|
5801
|
+
}
|
|
5796
5802
|
super(ctx, {
|
|
5797
5803
|
...options,
|
|
5798
5804
|
placeholder: options.placeholder ?? defaults.placeholder,
|
|
@@ -5807,6 +5813,7 @@ class InputRenderable extends TextareaRenderable {
|
|
|
5807
5813
|
]
|
|
5808
5814
|
});
|
|
5809
5815
|
this._maxLength = maxLength;
|
|
5816
|
+
this._minLength = minLength;
|
|
5810
5817
|
this._lastCommittedValue = this.plainText;
|
|
5811
5818
|
if (initialValue) {
|
|
5812
5819
|
this.cursorOffset = initialValue.length;
|
|
@@ -5861,6 +5868,9 @@ class InputRenderable extends TextareaRenderable {
|
|
|
5861
5868
|
}
|
|
5862
5869
|
submit() {
|
|
5863
5870
|
const currentValue = this.plainText;
|
|
5871
|
+
if (currentValue.length < this._minLength) {
|
|
5872
|
+
return false;
|
|
5873
|
+
}
|
|
5864
5874
|
if (currentValue !== this._lastCommittedValue) {
|
|
5865
5875
|
this._lastCommittedValue = currentValue;
|
|
5866
5876
|
this.emit("change" /* CHANGE */, currentValue);
|
|
@@ -5930,6 +5940,15 @@ class InputRenderable extends TextareaRenderable {
|
|
|
5930
5940
|
get maxLength() {
|
|
5931
5941
|
return this._maxLength;
|
|
5932
5942
|
}
|
|
5943
|
+
set minLength(minLength) {
|
|
5944
|
+
if (minLength > this._maxLength) {
|
|
5945
|
+
throw new Error(`InputRenderable: minLength (${minLength}) cannot be greater than maxLength (${this._maxLength})`);
|
|
5946
|
+
}
|
|
5947
|
+
this._minLength = minLength;
|
|
5948
|
+
}
|
|
5949
|
+
get minLength() {
|
|
5950
|
+
return this._minLength;
|
|
5951
|
+
}
|
|
5933
5952
|
set placeholder(placeholder) {
|
|
5934
5953
|
super.placeholder = placeholder;
|
|
5935
5954
|
}
|
|
@@ -8822,7 +8841,7 @@ class MarkdownRenderable extends Renderable {
|
|
|
8822
8841
|
}
|
|
8823
8842
|
applyListChildRenderable(renderable, token, previousToken, id) {
|
|
8824
8843
|
if ((token.type === "text" || token.type === "paragraph") && renderable instanceof CodeRenderable) {
|
|
8825
|
-
this.applyMarkdownCodeRenderable(renderable, this.
|
|
8844
|
+
this.applyMarkdownCodeRenderable(renderable, this.normalizeScrollbackMarkdownBlockRaw(token.raw), 0);
|
|
8826
8845
|
return true;
|
|
8827
8846
|
}
|
|
8828
8847
|
if (token.type === "list" && renderable instanceof BoxRenderable) {
|
|
@@ -8840,9 +8859,6 @@ class MarkdownRenderable extends Renderable {
|
|
|
8840
8859
|
children[i]?.destroyRecursively();
|
|
8841
8860
|
}
|
|
8842
8861
|
}
|
|
8843
|
-
getListChildMarkdownRaw(token) {
|
|
8844
|
-
return token.type === "paragraph" ? this.normalizeScrollbackMarkdownBlockRaw(token.raw) : token.raw;
|
|
8845
|
-
}
|
|
8846
8862
|
applyListItemMarker(row, input) {
|
|
8847
8863
|
const marker = row.getChildren()[0];
|
|
8848
8864
|
if (!(marker instanceof TextRenderable))
|
|
@@ -8860,7 +8876,7 @@ class MarkdownRenderable extends Renderable {
|
|
|
8860
8876
|
}
|
|
8861
8877
|
createListChildRenderable(token, id) {
|
|
8862
8878
|
if (token.type === "text" || token.type === "paragraph") {
|
|
8863
|
-
return this.createMarkdownCodeRenderable(this.
|
|
8879
|
+
return this.createMarkdownCodeRenderable(this.normalizeScrollbackMarkdownBlockRaw(token.raw), id);
|
|
8864
8880
|
}
|
|
8865
8881
|
if (token.type === "list")
|
|
8866
8882
|
return this.createListRenderable(token, id);
|
|
@@ -8944,10 +8960,19 @@ class MarkdownRenderable extends Renderable {
|
|
|
8944
8960
|
shouldRenderSeparately(token) {
|
|
8945
8961
|
return token.type === "code" || token.type === "table" || token.type === "blockquote" || token.type === "hr";
|
|
8946
8962
|
}
|
|
8947
|
-
getInterBlockMargin(token,
|
|
8948
|
-
if (!
|
|
8963
|
+
getInterBlockMargin(token, nextToken) {
|
|
8964
|
+
if (!nextToken)
|
|
8965
|
+
return 0;
|
|
8966
|
+
if (this.shouldRenderSeparately(token))
|
|
8967
|
+
return 1;
|
|
8968
|
+
if (!this.shouldRenderSeparately(nextToken))
|
|
8949
8969
|
return 0;
|
|
8950
|
-
return
|
|
8970
|
+
return TRAILING_MARKDOWN_BLOCK_NEWLINES_RE.test(token.raw) ? 0 : 1;
|
|
8971
|
+
}
|
|
8972
|
+
applyInterBlockMargin(state, token, nextToken) {
|
|
8973
|
+
if (state.tracksInterBlockMargin === false)
|
|
8974
|
+
return;
|
|
8975
|
+
state.renderable.marginBottom = this.getInterBlockMargin(token, nextToken);
|
|
8951
8976
|
}
|
|
8952
8977
|
createMarkdownBlockToken(raw) {
|
|
8953
8978
|
return {
|
|
@@ -9335,9 +9360,9 @@ class MarkdownRenderable extends Renderable {
|
|
|
9335
9360
|
}
|
|
9336
9361
|
return next ?? this.createTopLevelDefaultRenderable(block, index);
|
|
9337
9362
|
}
|
|
9338
|
-
createDefaultRenderable(token, index,
|
|
9363
|
+
createDefaultRenderable(token, index, nextToken) {
|
|
9339
9364
|
const id = `${this.id}-block-${index}`;
|
|
9340
|
-
const marginBottom = this.getInterBlockMargin(token,
|
|
9365
|
+
const marginBottom = this.getInterBlockMargin(token, nextToken);
|
|
9341
9366
|
if (token.type === "code") {
|
|
9342
9367
|
return this.createCodeRenderable(token, id, marginBottom);
|
|
9343
9368
|
}
|
|
@@ -9361,8 +9386,8 @@ class MarkdownRenderable extends Renderable {
|
|
|
9361
9386
|
}
|
|
9362
9387
|
return this.createMarkdownCodeRenderable(token.raw, id, marginBottom);
|
|
9363
9388
|
}
|
|
9364
|
-
updateBlockRenderable(state, token, index,
|
|
9365
|
-
const marginBottom = this.getInterBlockMargin(token,
|
|
9389
|
+
updateBlockRenderable(state, token, index, nextToken, forceListRefresh = false) {
|
|
9390
|
+
const marginBottom = this.getInterBlockMargin(token, nextToken);
|
|
9366
9391
|
if (token.type === "code") {
|
|
9367
9392
|
this.applyCodeBlockRenderable(state.renderable, token, marginBottom);
|
|
9368
9393
|
return;
|
|
@@ -9448,7 +9473,7 @@ class MarkdownRenderable extends Renderable {
|
|
|
9448
9473
|
continue;
|
|
9449
9474
|
}
|
|
9450
9475
|
if (existing && !forceTableRefresh && !this._renderNode && existing.token.type === block.token.type && this.canUpdateBlockRenderable(existing.renderable, block.token)) {
|
|
9451
|
-
this.updateBlockRenderable(existing, block.token, blockIndex,
|
|
9476
|
+
this.updateBlockRenderable(existing, block.token, blockIndex, blocks[i + 1]?.token);
|
|
9452
9477
|
existing.renderable.marginBottom = 0;
|
|
9453
9478
|
if (existing.marginTop !== block.marginTop) {
|
|
9454
9479
|
this.applyMargins(existing.renderable, block.marginTop, 0);
|
|
@@ -9513,7 +9538,8 @@ class MarkdownRenderable extends Renderable {
|
|
|
9513
9538
|
token: { type: "text", raw: this._content, text: this._content },
|
|
9514
9539
|
tokenRaw: this._content,
|
|
9515
9540
|
marginTop: 0,
|
|
9516
|
-
renderable: fallback
|
|
9541
|
+
renderable: fallback,
|
|
9542
|
+
tracksInterBlockMargin: true
|
|
9517
9543
|
}
|
|
9518
9544
|
];
|
|
9519
9545
|
return;
|
|
@@ -9524,17 +9550,18 @@ class MarkdownRenderable extends Renderable {
|
|
|
9524
9550
|
}
|
|
9525
9551
|
this._stableBlockCount = 0;
|
|
9526
9552
|
const blockTokens = this.buildRenderableTokens(tokens);
|
|
9527
|
-
const lastBlockIndex = blockTokens.length - 1;
|
|
9528
9553
|
let blockIndex = 0;
|
|
9529
9554
|
for (let i = 0;i < blockTokens.length; i++) {
|
|
9530
9555
|
const token = blockTokens[i];
|
|
9531
|
-
const
|
|
9556
|
+
const nextToken = blockTokens[i + 1];
|
|
9532
9557
|
const existing = this._blockStates[blockIndex];
|
|
9533
9558
|
const shouldForceRefresh = forceTableRefresh;
|
|
9534
9559
|
if (existing && existing.token === token) {
|
|
9535
9560
|
if (shouldForceRefresh) {
|
|
9536
|
-
this.updateBlockRenderable(existing, token, blockIndex,
|
|
9561
|
+
this.updateBlockRenderable(existing, token, blockIndex, nextToken);
|
|
9537
9562
|
existing.tokenRaw = token.raw;
|
|
9563
|
+
} else {
|
|
9564
|
+
this.applyInterBlockMargin(existing, token, nextToken);
|
|
9538
9565
|
}
|
|
9539
9566
|
blockIndex++;
|
|
9540
9567
|
continue;
|
|
@@ -9542,16 +9569,19 @@ class MarkdownRenderable extends Renderable {
|
|
|
9542
9569
|
if (existing && existing.tokenRaw === token.raw && existing.token.type === token.type) {
|
|
9543
9570
|
existing.token = token;
|
|
9544
9571
|
if (shouldForceRefresh) {
|
|
9545
|
-
this.updateBlockRenderable(existing, token, blockIndex,
|
|
9572
|
+
this.updateBlockRenderable(existing, token, blockIndex, nextToken);
|
|
9546
9573
|
existing.tokenRaw = token.raw;
|
|
9574
|
+
} else {
|
|
9575
|
+
this.applyInterBlockMargin(existing, token, nextToken);
|
|
9547
9576
|
}
|
|
9548
9577
|
blockIndex++;
|
|
9549
9578
|
continue;
|
|
9550
9579
|
}
|
|
9551
9580
|
if (existing && existing.token.type === token.type) {
|
|
9552
|
-
this.updateBlockRenderable(existing, token, blockIndex,
|
|
9581
|
+
this.updateBlockRenderable(existing, token, blockIndex, nextToken);
|
|
9553
9582
|
existing.token = token;
|
|
9554
9583
|
existing.tokenRaw = token.raw;
|
|
9584
|
+
existing.tracksInterBlockMargin = true;
|
|
9555
9585
|
blockIndex++;
|
|
9556
9586
|
continue;
|
|
9557
9587
|
}
|
|
@@ -9560,26 +9590,32 @@ class MarkdownRenderable extends Renderable {
|
|
|
9560
9590
|
}
|
|
9561
9591
|
let renderable;
|
|
9562
9592
|
let tableContentCache;
|
|
9593
|
+
let tracksInterBlockMargin = true;
|
|
9563
9594
|
if (this._renderNode) {
|
|
9595
|
+
let defaultRenderable;
|
|
9564
9596
|
const context = {
|
|
9565
9597
|
syntaxStyle: this._syntaxStyle,
|
|
9566
9598
|
conceal: this._conceal,
|
|
9567
9599
|
concealCode: this._concealCode,
|
|
9568
9600
|
treeSitterClient: this._treeSitterClient,
|
|
9569
|
-
defaultRender: () =>
|
|
9601
|
+
defaultRender: () => {
|
|
9602
|
+
defaultRenderable = this.createDefaultRenderable(token, blockIndex, nextToken);
|
|
9603
|
+
return defaultRenderable;
|
|
9604
|
+
}
|
|
9570
9605
|
};
|
|
9571
9606
|
const custom = this._renderNode(token, context);
|
|
9572
9607
|
if (custom) {
|
|
9573
9608
|
renderable = custom;
|
|
9609
|
+
tracksInterBlockMargin = custom === defaultRenderable;
|
|
9574
9610
|
}
|
|
9575
9611
|
}
|
|
9576
9612
|
if (!renderable) {
|
|
9577
9613
|
if (token.type === "table") {
|
|
9578
|
-
const tableBlock = this.createTableBlock(token, `${this.id}-block-${blockIndex}`, this.getInterBlockMargin(token,
|
|
9614
|
+
const tableBlock = this.createTableBlock(token, `${this.id}-block-${blockIndex}`, this.getInterBlockMargin(token, nextToken));
|
|
9579
9615
|
renderable = tableBlock.renderable;
|
|
9580
9616
|
tableContentCache = tableBlock.tableContentCache;
|
|
9581
9617
|
} else {
|
|
9582
|
-
renderable = this.createDefaultRenderable(token, blockIndex,
|
|
9618
|
+
renderable = this.createDefaultRenderable(token, blockIndex, nextToken) ?? undefined;
|
|
9583
9619
|
}
|
|
9584
9620
|
}
|
|
9585
9621
|
if (token.type === "table" && !tableContentCache && renderable instanceof TextTableRenderable) {
|
|
@@ -9592,7 +9628,8 @@ class MarkdownRenderable extends Renderable {
|
|
|
9592
9628
|
token,
|
|
9593
9629
|
tokenRaw: token.raw,
|
|
9594
9630
|
renderable,
|
|
9595
|
-
tableContentCache
|
|
9631
|
+
tableContentCache,
|
|
9632
|
+
tracksInterBlockMargin
|
|
9596
9633
|
};
|
|
9597
9634
|
}
|
|
9598
9635
|
blockIndex++;
|
|
@@ -9616,8 +9653,7 @@ class MarkdownRenderable extends Renderable {
|
|
|
9616
9653
|
}
|
|
9617
9654
|
for (let i = 0;i < this._blockStates.length; i++) {
|
|
9618
9655
|
const state = this._blockStates[i];
|
|
9619
|
-
const
|
|
9620
|
-
const marginBottom = this.getInterBlockMargin(state.token, hasNextToken);
|
|
9656
|
+
const marginBottom = this.getInterBlockMargin(state.token, this._blockStates[i + 1]?.token);
|
|
9621
9657
|
if (state.token.type === "code") {
|
|
9622
9658
|
this.applyCodeBlockRenderable(state.renderable, state.token, marginBottom);
|
|
9623
9659
|
continue;
|
|
@@ -9627,7 +9663,7 @@ class MarkdownRenderable extends Renderable {
|
|
|
9627
9663
|
continue;
|
|
9628
9664
|
}
|
|
9629
9665
|
if (state.token.type === "list") {
|
|
9630
|
-
this.updateBlockRenderable(state, state.token, i,
|
|
9666
|
+
this.updateBlockRenderable(state, state.token, i, this._blockStates[i + 1]?.token, true);
|
|
9631
9667
|
continue;
|
|
9632
9668
|
}
|
|
9633
9669
|
if (state.token.type === "hr") {
|
|
@@ -10671,6 +10707,18 @@ class ScrollBoxRenderable extends BoxRenderable {
|
|
|
10671
10707
|
return false;
|
|
10672
10708
|
}
|
|
10673
10709
|
}
|
|
10710
|
+
isAtStickyReengagePoint(stickyStart, maxScrollTop, maxScrollLeft) {
|
|
10711
|
+
switch (stickyStart) {
|
|
10712
|
+
case "top":
|
|
10713
|
+
return maxScrollTop > 0 && this.scrollTop <= 0;
|
|
10714
|
+
case "bottom":
|
|
10715
|
+
return maxScrollTop > 0 && this.scrollTop >= maxScrollTop - 1;
|
|
10716
|
+
case "left":
|
|
10717
|
+
return maxScrollLeft > 0 && this.scrollLeft <= 0;
|
|
10718
|
+
case "right":
|
|
10719
|
+
return maxScrollLeft > 0 && this.scrollLeft >= maxScrollLeft - 1;
|
|
10720
|
+
}
|
|
10721
|
+
}
|
|
10674
10722
|
add(obj, index) {
|
|
10675
10723
|
return this.content.add(obj, index);
|
|
10676
10724
|
}
|
|
@@ -10869,9 +10917,13 @@ class ScrollBoxRenderable extends BoxRenderable {
|
|
|
10869
10917
|
if (this._stickyScroll) {
|
|
10870
10918
|
const newMaxScrollTop = Math.max(0, this.scrollHeight - this.viewport.height);
|
|
10871
10919
|
const newMaxScrollLeft = Math.max(0, this.scrollWidth - this.viewport.width);
|
|
10872
|
-
|
|
10873
|
-
|
|
10874
|
-
|
|
10920
|
+
const stickyStart = this._stickyStart;
|
|
10921
|
+
if (stickyStart && !this._hasManualScroll) {
|
|
10922
|
+
this.applyStickyStart(stickyStart);
|
|
10923
|
+
} else if (stickyStart && this._hasManualScroll && this.isAtStickyReengagePoint(stickyStart, newMaxScrollTop, newMaxScrollLeft)) {
|
|
10924
|
+
this._hasManualScroll = false;
|
|
10925
|
+
this.applyStickyStart(stickyStart);
|
|
10926
|
+
} else if (!this._hasManualScroll) {
|
|
10875
10927
|
if (this._stickyScrollTop) {
|
|
10876
10928
|
this.scrollTop = 0;
|
|
10877
10929
|
} else if (this._stickyScrollBottom && newMaxScrollTop > 0) {
|
|
@@ -11733,5 +11785,5 @@ class TimeToFirstDrawRenderable extends Renderable {
|
|
|
11733
11785
|
}
|
|
11734
11786
|
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 };
|
|
11735
11787
|
|
|
11736
|
-
//# debugId=
|
|
11737
|
-
//# sourceMappingURL=index-
|
|
11788
|
+
//# debugId=811F02B84CBDC3E964756E2164756E21
|
|
11789
|
+
//# sourceMappingURL=index-hzcw4q21.js.map
|