@opentui/core 0.2.15 → 0.3.0
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/NativeSpanFeed.d.ts +6 -0
- package/{index-3fq5hq97.js → index-081xws23.js} +756 -147
- package/{index-3fq5hq97.js.map → index-081xws23.js.map} +11 -10
- package/{index-bdfngvbe.js → index-dhbwkghw.js} +2 -2
- package/{index-pzzbb0f6.js → index-qwem5zxy.js} +3 -3
- package/{index-yyyfmp8n.js → index-sq86yyfz.js} +86 -284
- package/{index-yyyfmp8n.js.map → index-sq86yyfz.js.map} +6 -7
- package/index.js +4 -4
- package/index.js.map +1 -1
- 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 +79 -12
- 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 +35 -4
- package/testing/test-streams.d.ts +12 -0
- package/testing.d.ts +1 -0
- package/testing.js +307 -49
- package/testing.js.map +8 -6
- package/types.d.ts +3 -1
- package/zig-structs.d.ts +17 -1
- package/zig.d.ts +18 -10
- /package/{index-bdfngvbe.js.map → index-dhbwkghw.js.map} +0 -0
- /package/{index-pzzbb0f6.js.map → index-qwem5zxy.js.map} +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
import {
|
|
3
3
|
createRuntimePlugin
|
|
4
|
-
} from "./index-
|
|
4
|
+
} from "./index-qwem5zxy.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-
|
|
44
|
+
//# sourceMappingURL=index-dhbwkghw.js.map
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
import {
|
|
3
3
|
exports_src
|
|
4
|
-
} from "./index-
|
|
4
|
+
} from "./index-sq86yyfz.js";
|
|
5
5
|
import {
|
|
6
6
|
__require
|
|
7
|
-
} from "./index-
|
|
7
|
+
} from "./index-081xws23.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-
|
|
421
|
+
//# sourceMappingURL=index-qwem5zxy.js.map
|
|
@@ -31,6 +31,7 @@ import {
|
|
|
31
31
|
MouseButton,
|
|
32
32
|
MouseEvent,
|
|
33
33
|
MouseParser,
|
|
34
|
+
NativeSpanFeed,
|
|
34
35
|
OptimizedBuffer,
|
|
35
36
|
PasteEvent,
|
|
36
37
|
RGBA,
|
|
@@ -40,7 +41,6 @@ import {
|
|
|
40
41
|
RootRenderable,
|
|
41
42
|
RootTextNodeRenderable,
|
|
42
43
|
Selection,
|
|
43
|
-
SpanInfoStruct,
|
|
44
44
|
StdinParser,
|
|
45
45
|
StyledText,
|
|
46
46
|
SyntaxStyle,
|
|
@@ -175,7 +175,6 @@ import {
|
|
|
175
175
|
stripAnsiSequences,
|
|
176
176
|
t,
|
|
177
177
|
terminalNamedSingleStrokeKeys,
|
|
178
|
-
toArrayBuffer,
|
|
179
178
|
treeSitterToStyledText,
|
|
180
179
|
treeSitterToTextChunks,
|
|
181
180
|
underline,
|
|
@@ -183,7 +182,7 @@ import {
|
|
|
183
182
|
white,
|
|
184
183
|
wrapWithDelegates,
|
|
185
184
|
yellow
|
|
186
|
-
} from "./index-
|
|
185
|
+
} from "./index-081xws23.js";
|
|
187
186
|
|
|
188
187
|
// src/index.ts
|
|
189
188
|
var exports_src2 = {};
|
|
@@ -2771,255 +2770,6 @@ class SlotRenderable extends Renderable {
|
|
|
2771
2770
|
this._mountedNodes = [...desiredNodes];
|
|
2772
2771
|
}
|
|
2773
2772
|
}
|
|
2774
|
-
// src/NativeSpanFeed.ts
|
|
2775
|
-
function toNumber(value) {
|
|
2776
|
-
return typeof value === "bigint" ? Number(value) : value;
|
|
2777
|
-
}
|
|
2778
|
-
|
|
2779
|
-
class NativeSpanFeed {
|
|
2780
|
-
static create(options) {
|
|
2781
|
-
const lib = resolveRenderLib();
|
|
2782
|
-
const streamPtr = lib.createNativeSpanFeed(options);
|
|
2783
|
-
const stream = new NativeSpanFeed(streamPtr);
|
|
2784
|
-
lib.registerNativeSpanFeedStream(streamPtr, stream.eventHandler);
|
|
2785
|
-
const status = lib.attachNativeSpanFeed(streamPtr);
|
|
2786
|
-
if (status !== 0) {
|
|
2787
|
-
lib.unregisterNativeSpanFeedStream(streamPtr);
|
|
2788
|
-
lib.destroyNativeSpanFeed(streamPtr);
|
|
2789
|
-
throw new Error(`Failed to attach stream: ${status}`);
|
|
2790
|
-
}
|
|
2791
|
-
return stream;
|
|
2792
|
-
}
|
|
2793
|
-
static attach(streamPtr, _options) {
|
|
2794
|
-
const lib = resolveRenderLib();
|
|
2795
|
-
const stream = new NativeSpanFeed(streamPtr);
|
|
2796
|
-
lib.registerNativeSpanFeedStream(streamPtr, stream.eventHandler);
|
|
2797
|
-
const status = lib.attachNativeSpanFeed(streamPtr);
|
|
2798
|
-
if (status !== 0) {
|
|
2799
|
-
lib.unregisterNativeSpanFeedStream(streamPtr);
|
|
2800
|
-
throw new Error(`Failed to attach stream: ${status}`);
|
|
2801
|
-
}
|
|
2802
|
-
return stream;
|
|
2803
|
-
}
|
|
2804
|
-
streamPtr;
|
|
2805
|
-
lib = resolveRenderLib();
|
|
2806
|
-
eventHandler;
|
|
2807
|
-
chunkMap = new Map;
|
|
2808
|
-
chunkSizes = new Map;
|
|
2809
|
-
dataHandlers = new Set;
|
|
2810
|
-
errorHandlers = new Set;
|
|
2811
|
-
drainBuffer = null;
|
|
2812
|
-
stateBuffer = null;
|
|
2813
|
-
closed = false;
|
|
2814
|
-
destroyed = false;
|
|
2815
|
-
draining = false;
|
|
2816
|
-
pendingDataAvailable = false;
|
|
2817
|
-
pendingClose = false;
|
|
2818
|
-
closing = false;
|
|
2819
|
-
pendingAsyncHandlers = 0;
|
|
2820
|
-
inCallback = false;
|
|
2821
|
-
closeQueued = false;
|
|
2822
|
-
constructor(streamPtr) {
|
|
2823
|
-
this.streamPtr = streamPtr;
|
|
2824
|
-
this.eventHandler = (eventId, arg0, arg1) => {
|
|
2825
|
-
this.handleEvent(eventId, arg0, arg1);
|
|
2826
|
-
};
|
|
2827
|
-
this.ensureDrainBuffer();
|
|
2828
|
-
}
|
|
2829
|
-
ensureDrainBuffer() {
|
|
2830
|
-
if (this.drainBuffer)
|
|
2831
|
-
return;
|
|
2832
|
-
const capacity = 256;
|
|
2833
|
-
this.drainBuffer = new Uint8Array(capacity * SpanInfoStruct.size);
|
|
2834
|
-
}
|
|
2835
|
-
onData(handler) {
|
|
2836
|
-
this.dataHandlers.add(handler);
|
|
2837
|
-
if (this.pendingDataAvailable) {
|
|
2838
|
-
this.pendingDataAvailable = false;
|
|
2839
|
-
this.drainAll();
|
|
2840
|
-
}
|
|
2841
|
-
return () => this.dataHandlers.delete(handler);
|
|
2842
|
-
}
|
|
2843
|
-
onError(handler) {
|
|
2844
|
-
this.errorHandlers.add(handler);
|
|
2845
|
-
return () => this.errorHandlers.delete(handler);
|
|
2846
|
-
}
|
|
2847
|
-
close() {
|
|
2848
|
-
if (this.destroyed)
|
|
2849
|
-
return;
|
|
2850
|
-
if (this.inCallback || this.draining || this.pendingAsyncHandlers > 0) {
|
|
2851
|
-
this.pendingClose = true;
|
|
2852
|
-
if (!this.closeQueued) {
|
|
2853
|
-
this.closeQueued = true;
|
|
2854
|
-
queueMicrotask(() => {
|
|
2855
|
-
this.closeQueued = false;
|
|
2856
|
-
this.processPendingClose();
|
|
2857
|
-
});
|
|
2858
|
-
}
|
|
2859
|
-
return;
|
|
2860
|
-
}
|
|
2861
|
-
this.performClose();
|
|
2862
|
-
}
|
|
2863
|
-
processPendingClose() {
|
|
2864
|
-
if (!this.pendingClose || this.destroyed)
|
|
2865
|
-
return;
|
|
2866
|
-
if (this.inCallback || this.draining || this.pendingAsyncHandlers > 0)
|
|
2867
|
-
return;
|
|
2868
|
-
this.pendingClose = false;
|
|
2869
|
-
this.performClose();
|
|
2870
|
-
}
|
|
2871
|
-
performClose() {
|
|
2872
|
-
if (this.closing)
|
|
2873
|
-
return;
|
|
2874
|
-
this.closing = true;
|
|
2875
|
-
if (!this.closed) {
|
|
2876
|
-
const status = this.lib.streamClose(this.streamPtr);
|
|
2877
|
-
if (status !== 0) {
|
|
2878
|
-
this.closing = false;
|
|
2879
|
-
return;
|
|
2880
|
-
}
|
|
2881
|
-
this.closed = true;
|
|
2882
|
-
}
|
|
2883
|
-
this.finalizeDestroy();
|
|
2884
|
-
}
|
|
2885
|
-
finalizeDestroy() {
|
|
2886
|
-
if (this.destroyed)
|
|
2887
|
-
return;
|
|
2888
|
-
this.lib.unregisterNativeSpanFeedStream(this.streamPtr);
|
|
2889
|
-
this.lib.destroyNativeSpanFeed(this.streamPtr);
|
|
2890
|
-
this.destroyed = true;
|
|
2891
|
-
this.chunkMap.clear();
|
|
2892
|
-
this.chunkSizes.clear();
|
|
2893
|
-
this.stateBuffer = null;
|
|
2894
|
-
this.drainBuffer = null;
|
|
2895
|
-
this.dataHandlers.clear();
|
|
2896
|
-
this.errorHandlers.clear();
|
|
2897
|
-
this.pendingDataAvailable = false;
|
|
2898
|
-
}
|
|
2899
|
-
handleEvent(eventId, arg0, arg1) {
|
|
2900
|
-
this.inCallback = true;
|
|
2901
|
-
try {
|
|
2902
|
-
switch (eventId) {
|
|
2903
|
-
case 8 /* StateBuffer */: {
|
|
2904
|
-
const len = toNumber(arg1);
|
|
2905
|
-
if (len > 0 && arg0) {
|
|
2906
|
-
const buffer = toArrayBuffer(arg0, 0, len);
|
|
2907
|
-
this.stateBuffer = new Uint8Array(buffer);
|
|
2908
|
-
}
|
|
2909
|
-
break;
|
|
2910
|
-
}
|
|
2911
|
-
case 7 /* DataAvailable */: {
|
|
2912
|
-
if (this.closing)
|
|
2913
|
-
break;
|
|
2914
|
-
if (this.dataHandlers.size === 0) {
|
|
2915
|
-
this.pendingDataAvailable = true;
|
|
2916
|
-
break;
|
|
2917
|
-
}
|
|
2918
|
-
this.drainAll();
|
|
2919
|
-
break;
|
|
2920
|
-
}
|
|
2921
|
-
case 2 /* ChunkAdded */: {
|
|
2922
|
-
const chunkLen = toNumber(arg1);
|
|
2923
|
-
if (chunkLen > 0 && arg0) {
|
|
2924
|
-
if (!this.chunkMap.has(arg0)) {
|
|
2925
|
-
const buffer = toArrayBuffer(arg0, 0, chunkLen);
|
|
2926
|
-
this.chunkMap.set(arg0, buffer);
|
|
2927
|
-
}
|
|
2928
|
-
this.chunkSizes.set(arg0, chunkLen);
|
|
2929
|
-
}
|
|
2930
|
-
break;
|
|
2931
|
-
}
|
|
2932
|
-
case 6 /* Error */: {
|
|
2933
|
-
const code = toNumber(arg0);
|
|
2934
|
-
for (const handler of this.errorHandlers)
|
|
2935
|
-
handler(code);
|
|
2936
|
-
break;
|
|
2937
|
-
}
|
|
2938
|
-
case 5 /* Closed */: {
|
|
2939
|
-
this.closed = true;
|
|
2940
|
-
break;
|
|
2941
|
-
}
|
|
2942
|
-
default:
|
|
2943
|
-
break;
|
|
2944
|
-
}
|
|
2945
|
-
} finally {
|
|
2946
|
-
this.inCallback = false;
|
|
2947
|
-
}
|
|
2948
|
-
}
|
|
2949
|
-
decrementRefcount(chunkIndex) {
|
|
2950
|
-
if (this.stateBuffer && chunkIndex < this.stateBuffer.length) {
|
|
2951
|
-
const prev = this.stateBuffer[chunkIndex];
|
|
2952
|
-
this.stateBuffer[chunkIndex] = prev > 0 ? prev - 1 : 0;
|
|
2953
|
-
}
|
|
2954
|
-
}
|
|
2955
|
-
drainOnce() {
|
|
2956
|
-
if (!this.drainBuffer || this.draining || this.pendingClose)
|
|
2957
|
-
return 0;
|
|
2958
|
-
const capacity = Math.floor(this.drainBuffer.byteLength / SpanInfoStruct.size);
|
|
2959
|
-
if (capacity === 0)
|
|
2960
|
-
return 0;
|
|
2961
|
-
const count = this.lib.streamDrainSpans(this.streamPtr, this.drainBuffer, capacity);
|
|
2962
|
-
if (count === 0)
|
|
2963
|
-
return 0;
|
|
2964
|
-
this.draining = true;
|
|
2965
|
-
const spans = SpanInfoStruct.unpackList(this.drainBuffer.buffer, count);
|
|
2966
|
-
let firstError = null;
|
|
2967
|
-
try {
|
|
2968
|
-
for (const span of spans) {
|
|
2969
|
-
if (span.len === 0)
|
|
2970
|
-
continue;
|
|
2971
|
-
let buffer = this.chunkMap.get(span.chunkPtr);
|
|
2972
|
-
if (!buffer) {
|
|
2973
|
-
const size = this.chunkSizes.get(span.chunkPtr);
|
|
2974
|
-
if (!size)
|
|
2975
|
-
continue;
|
|
2976
|
-
buffer = toArrayBuffer(span.chunkPtr, 0, size);
|
|
2977
|
-
this.chunkMap.set(span.chunkPtr, buffer);
|
|
2978
|
-
}
|
|
2979
|
-
if (span.offset + span.len > buffer.byteLength)
|
|
2980
|
-
continue;
|
|
2981
|
-
const slice = new Uint8Array(buffer, span.offset, span.len);
|
|
2982
|
-
let asyncResults = null;
|
|
2983
|
-
for (const handler of this.dataHandlers) {
|
|
2984
|
-
try {
|
|
2985
|
-
const result = handler(slice);
|
|
2986
|
-
if (result && typeof result.then === "function") {
|
|
2987
|
-
asyncResults ??= [];
|
|
2988
|
-
asyncResults.push(result);
|
|
2989
|
-
}
|
|
2990
|
-
} catch (e) {
|
|
2991
|
-
firstError ??= e;
|
|
2992
|
-
}
|
|
2993
|
-
}
|
|
2994
|
-
const shouldStopAfterThisSpan = this.pendingClose;
|
|
2995
|
-
if (asyncResults) {
|
|
2996
|
-
const chunkIndex = span.chunkIndex;
|
|
2997
|
-
this.pendingAsyncHandlers += 1;
|
|
2998
|
-
Promise.allSettled(asyncResults).then(() => {
|
|
2999
|
-
this.decrementRefcount(chunkIndex);
|
|
3000
|
-
this.pendingAsyncHandlers -= 1;
|
|
3001
|
-
this.processPendingClose();
|
|
3002
|
-
});
|
|
3003
|
-
} else {
|
|
3004
|
-
this.decrementRefcount(span.chunkIndex);
|
|
3005
|
-
}
|
|
3006
|
-
if (shouldStopAfterThisSpan)
|
|
3007
|
-
break;
|
|
3008
|
-
}
|
|
3009
|
-
} finally {
|
|
3010
|
-
this.draining = false;
|
|
3011
|
-
}
|
|
3012
|
-
if (firstError)
|
|
3013
|
-
throw firstError;
|
|
3014
|
-
return count;
|
|
3015
|
-
}
|
|
3016
|
-
drainAll() {
|
|
3017
|
-
let count = this.drainOnce();
|
|
3018
|
-
while (count > 0) {
|
|
3019
|
-
count = this.drainOnce();
|
|
3020
|
-
}
|
|
3021
|
-
}
|
|
3022
|
-
}
|
|
3023
2773
|
// src/audio.ts
|
|
3024
2774
|
import { EventEmitter } from "events";
|
|
3025
2775
|
import { readFile } from "fs/promises";
|
|
@@ -5782,17 +5532,23 @@ var InputRenderableEvents;
|
|
|
5782
5532
|
|
|
5783
5533
|
class InputRenderable extends TextareaRenderable {
|
|
5784
5534
|
_maxLength;
|
|
5535
|
+
_minLength;
|
|
5785
5536
|
_lastCommittedValue = "";
|
|
5786
5537
|
static defaultOptions = {
|
|
5787
5538
|
placeholder: "",
|
|
5788
5539
|
maxLength: 1000,
|
|
5540
|
+
minLength: 0,
|
|
5789
5541
|
value: ""
|
|
5790
5542
|
};
|
|
5791
5543
|
constructor(ctx, options) {
|
|
5792
5544
|
const defaults = InputRenderable.defaultOptions;
|
|
5793
5545
|
const maxLength = options.maxLength ?? defaults.maxLength;
|
|
5546
|
+
const minLength = options.minLength ?? defaults.minLength;
|
|
5794
5547
|
const rawValue = options.value ?? defaults.value;
|
|
5795
5548
|
const initialValue = rawValue.replace(/[\n\r]/g, "").substring(0, maxLength);
|
|
5549
|
+
if (minLength > maxLength) {
|
|
5550
|
+
throw new Error(`InputRenderable: minLength (${minLength}) cannot be greater than maxLength (${maxLength})`);
|
|
5551
|
+
}
|
|
5796
5552
|
super(ctx, {
|
|
5797
5553
|
...options,
|
|
5798
5554
|
placeholder: options.placeholder ?? defaults.placeholder,
|
|
@@ -5807,6 +5563,7 @@ class InputRenderable extends TextareaRenderable {
|
|
|
5807
5563
|
]
|
|
5808
5564
|
});
|
|
5809
5565
|
this._maxLength = maxLength;
|
|
5566
|
+
this._minLength = minLength;
|
|
5810
5567
|
this._lastCommittedValue = this.plainText;
|
|
5811
5568
|
if (initialValue) {
|
|
5812
5569
|
this.cursorOffset = initialValue.length;
|
|
@@ -5861,6 +5618,9 @@ class InputRenderable extends TextareaRenderable {
|
|
|
5861
5618
|
}
|
|
5862
5619
|
submit() {
|
|
5863
5620
|
const currentValue = this.plainText;
|
|
5621
|
+
if (currentValue.length < this._minLength) {
|
|
5622
|
+
return false;
|
|
5623
|
+
}
|
|
5864
5624
|
if (currentValue !== this._lastCommittedValue) {
|
|
5865
5625
|
this._lastCommittedValue = currentValue;
|
|
5866
5626
|
this.emit("change" /* CHANGE */, currentValue);
|
|
@@ -5930,6 +5690,15 @@ class InputRenderable extends TextareaRenderable {
|
|
|
5930
5690
|
get maxLength() {
|
|
5931
5691
|
return this._maxLength;
|
|
5932
5692
|
}
|
|
5693
|
+
set minLength(minLength) {
|
|
5694
|
+
if (minLength > this._maxLength) {
|
|
5695
|
+
throw new Error(`InputRenderable: minLength (${minLength}) cannot be greater than maxLength (${this._maxLength})`);
|
|
5696
|
+
}
|
|
5697
|
+
this._minLength = minLength;
|
|
5698
|
+
}
|
|
5699
|
+
get minLength() {
|
|
5700
|
+
return this._minLength;
|
|
5701
|
+
}
|
|
5933
5702
|
set placeholder(placeholder) {
|
|
5934
5703
|
super.placeholder = placeholder;
|
|
5935
5704
|
}
|
|
@@ -8822,7 +8591,7 @@ class MarkdownRenderable extends Renderable {
|
|
|
8822
8591
|
}
|
|
8823
8592
|
applyListChildRenderable(renderable, token, previousToken, id) {
|
|
8824
8593
|
if ((token.type === "text" || token.type === "paragraph") && renderable instanceof CodeRenderable) {
|
|
8825
|
-
this.applyMarkdownCodeRenderable(renderable, this.
|
|
8594
|
+
this.applyMarkdownCodeRenderable(renderable, this.normalizeScrollbackMarkdownBlockRaw(token.raw), 0);
|
|
8826
8595
|
return true;
|
|
8827
8596
|
}
|
|
8828
8597
|
if (token.type === "list" && renderable instanceof BoxRenderable) {
|
|
@@ -8840,9 +8609,6 @@ class MarkdownRenderable extends Renderable {
|
|
|
8840
8609
|
children[i]?.destroyRecursively();
|
|
8841
8610
|
}
|
|
8842
8611
|
}
|
|
8843
|
-
getListChildMarkdownRaw(token) {
|
|
8844
|
-
return token.type === "paragraph" ? this.normalizeScrollbackMarkdownBlockRaw(token.raw) : token.raw;
|
|
8845
|
-
}
|
|
8846
8612
|
applyListItemMarker(row, input) {
|
|
8847
8613
|
const marker = row.getChildren()[0];
|
|
8848
8614
|
if (!(marker instanceof TextRenderable))
|
|
@@ -8860,7 +8626,7 @@ class MarkdownRenderable extends Renderable {
|
|
|
8860
8626
|
}
|
|
8861
8627
|
createListChildRenderable(token, id) {
|
|
8862
8628
|
if (token.type === "text" || token.type === "paragraph") {
|
|
8863
|
-
return this.createMarkdownCodeRenderable(this.
|
|
8629
|
+
return this.createMarkdownCodeRenderable(this.normalizeScrollbackMarkdownBlockRaw(token.raw), id);
|
|
8864
8630
|
}
|
|
8865
8631
|
if (token.type === "list")
|
|
8866
8632
|
return this.createListRenderable(token, id);
|
|
@@ -8944,10 +8710,19 @@ class MarkdownRenderable extends Renderable {
|
|
|
8944
8710
|
shouldRenderSeparately(token) {
|
|
8945
8711
|
return token.type === "code" || token.type === "table" || token.type === "blockquote" || token.type === "hr";
|
|
8946
8712
|
}
|
|
8947
|
-
getInterBlockMargin(token,
|
|
8948
|
-
if (!
|
|
8713
|
+
getInterBlockMargin(token, nextToken) {
|
|
8714
|
+
if (!nextToken)
|
|
8715
|
+
return 0;
|
|
8716
|
+
if (this.shouldRenderSeparately(token))
|
|
8717
|
+
return 1;
|
|
8718
|
+
if (!this.shouldRenderSeparately(nextToken))
|
|
8949
8719
|
return 0;
|
|
8950
|
-
return
|
|
8720
|
+
return TRAILING_MARKDOWN_BLOCK_NEWLINES_RE.test(token.raw) ? 0 : 1;
|
|
8721
|
+
}
|
|
8722
|
+
applyInterBlockMargin(state, token, nextToken) {
|
|
8723
|
+
if (state.tracksInterBlockMargin === false)
|
|
8724
|
+
return;
|
|
8725
|
+
state.renderable.marginBottom = this.getInterBlockMargin(token, nextToken);
|
|
8951
8726
|
}
|
|
8952
8727
|
createMarkdownBlockToken(raw) {
|
|
8953
8728
|
return {
|
|
@@ -9335,9 +9110,9 @@ class MarkdownRenderable extends Renderable {
|
|
|
9335
9110
|
}
|
|
9336
9111
|
return next ?? this.createTopLevelDefaultRenderable(block, index);
|
|
9337
9112
|
}
|
|
9338
|
-
createDefaultRenderable(token, index,
|
|
9113
|
+
createDefaultRenderable(token, index, nextToken) {
|
|
9339
9114
|
const id = `${this.id}-block-${index}`;
|
|
9340
|
-
const marginBottom = this.getInterBlockMargin(token,
|
|
9115
|
+
const marginBottom = this.getInterBlockMargin(token, nextToken);
|
|
9341
9116
|
if (token.type === "code") {
|
|
9342
9117
|
return this.createCodeRenderable(token, id, marginBottom);
|
|
9343
9118
|
}
|
|
@@ -9361,8 +9136,8 @@ class MarkdownRenderable extends Renderable {
|
|
|
9361
9136
|
}
|
|
9362
9137
|
return this.createMarkdownCodeRenderable(token.raw, id, marginBottom);
|
|
9363
9138
|
}
|
|
9364
|
-
updateBlockRenderable(state, token, index,
|
|
9365
|
-
const marginBottom = this.getInterBlockMargin(token,
|
|
9139
|
+
updateBlockRenderable(state, token, index, nextToken, forceListRefresh = false) {
|
|
9140
|
+
const marginBottom = this.getInterBlockMargin(token, nextToken);
|
|
9366
9141
|
if (token.type === "code") {
|
|
9367
9142
|
this.applyCodeBlockRenderable(state.renderable, token, marginBottom);
|
|
9368
9143
|
return;
|
|
@@ -9448,7 +9223,7 @@ class MarkdownRenderable extends Renderable {
|
|
|
9448
9223
|
continue;
|
|
9449
9224
|
}
|
|
9450
9225
|
if (existing && !forceTableRefresh && !this._renderNode && existing.token.type === block.token.type && this.canUpdateBlockRenderable(existing.renderable, block.token)) {
|
|
9451
|
-
this.updateBlockRenderable(existing, block.token, blockIndex,
|
|
9226
|
+
this.updateBlockRenderable(existing, block.token, blockIndex, blocks[i + 1]?.token);
|
|
9452
9227
|
existing.renderable.marginBottom = 0;
|
|
9453
9228
|
if (existing.marginTop !== block.marginTop) {
|
|
9454
9229
|
this.applyMargins(existing.renderable, block.marginTop, 0);
|
|
@@ -9513,7 +9288,8 @@ class MarkdownRenderable extends Renderable {
|
|
|
9513
9288
|
token: { type: "text", raw: this._content, text: this._content },
|
|
9514
9289
|
tokenRaw: this._content,
|
|
9515
9290
|
marginTop: 0,
|
|
9516
|
-
renderable: fallback
|
|
9291
|
+
renderable: fallback,
|
|
9292
|
+
tracksInterBlockMargin: true
|
|
9517
9293
|
}
|
|
9518
9294
|
];
|
|
9519
9295
|
return;
|
|
@@ -9524,17 +9300,18 @@ class MarkdownRenderable extends Renderable {
|
|
|
9524
9300
|
}
|
|
9525
9301
|
this._stableBlockCount = 0;
|
|
9526
9302
|
const blockTokens = this.buildRenderableTokens(tokens);
|
|
9527
|
-
const lastBlockIndex = blockTokens.length - 1;
|
|
9528
9303
|
let blockIndex = 0;
|
|
9529
9304
|
for (let i = 0;i < blockTokens.length; i++) {
|
|
9530
9305
|
const token = blockTokens[i];
|
|
9531
|
-
const
|
|
9306
|
+
const nextToken = blockTokens[i + 1];
|
|
9532
9307
|
const existing = this._blockStates[blockIndex];
|
|
9533
9308
|
const shouldForceRefresh = forceTableRefresh;
|
|
9534
9309
|
if (existing && existing.token === token) {
|
|
9535
9310
|
if (shouldForceRefresh) {
|
|
9536
|
-
this.updateBlockRenderable(existing, token, blockIndex,
|
|
9311
|
+
this.updateBlockRenderable(existing, token, blockIndex, nextToken);
|
|
9537
9312
|
existing.tokenRaw = token.raw;
|
|
9313
|
+
} else {
|
|
9314
|
+
this.applyInterBlockMargin(existing, token, nextToken);
|
|
9538
9315
|
}
|
|
9539
9316
|
blockIndex++;
|
|
9540
9317
|
continue;
|
|
@@ -9542,16 +9319,19 @@ class MarkdownRenderable extends Renderable {
|
|
|
9542
9319
|
if (existing && existing.tokenRaw === token.raw && existing.token.type === token.type) {
|
|
9543
9320
|
existing.token = token;
|
|
9544
9321
|
if (shouldForceRefresh) {
|
|
9545
|
-
this.updateBlockRenderable(existing, token, blockIndex,
|
|
9322
|
+
this.updateBlockRenderable(existing, token, blockIndex, nextToken);
|
|
9546
9323
|
existing.tokenRaw = token.raw;
|
|
9324
|
+
} else {
|
|
9325
|
+
this.applyInterBlockMargin(existing, token, nextToken);
|
|
9547
9326
|
}
|
|
9548
9327
|
blockIndex++;
|
|
9549
9328
|
continue;
|
|
9550
9329
|
}
|
|
9551
9330
|
if (existing && existing.token.type === token.type) {
|
|
9552
|
-
this.updateBlockRenderable(existing, token, blockIndex,
|
|
9331
|
+
this.updateBlockRenderable(existing, token, blockIndex, nextToken);
|
|
9553
9332
|
existing.token = token;
|
|
9554
9333
|
existing.tokenRaw = token.raw;
|
|
9334
|
+
existing.tracksInterBlockMargin = true;
|
|
9555
9335
|
blockIndex++;
|
|
9556
9336
|
continue;
|
|
9557
9337
|
}
|
|
@@ -9560,26 +9340,32 @@ class MarkdownRenderable extends Renderable {
|
|
|
9560
9340
|
}
|
|
9561
9341
|
let renderable;
|
|
9562
9342
|
let tableContentCache;
|
|
9343
|
+
let tracksInterBlockMargin = true;
|
|
9563
9344
|
if (this._renderNode) {
|
|
9345
|
+
let defaultRenderable;
|
|
9564
9346
|
const context = {
|
|
9565
9347
|
syntaxStyle: this._syntaxStyle,
|
|
9566
9348
|
conceal: this._conceal,
|
|
9567
9349
|
concealCode: this._concealCode,
|
|
9568
9350
|
treeSitterClient: this._treeSitterClient,
|
|
9569
|
-
defaultRender: () =>
|
|
9351
|
+
defaultRender: () => {
|
|
9352
|
+
defaultRenderable = this.createDefaultRenderable(token, blockIndex, nextToken);
|
|
9353
|
+
return defaultRenderable;
|
|
9354
|
+
}
|
|
9570
9355
|
};
|
|
9571
9356
|
const custom = this._renderNode(token, context);
|
|
9572
9357
|
if (custom) {
|
|
9573
9358
|
renderable = custom;
|
|
9359
|
+
tracksInterBlockMargin = custom === defaultRenderable;
|
|
9574
9360
|
}
|
|
9575
9361
|
}
|
|
9576
9362
|
if (!renderable) {
|
|
9577
9363
|
if (token.type === "table") {
|
|
9578
|
-
const tableBlock = this.createTableBlock(token, `${this.id}-block-${blockIndex}`, this.getInterBlockMargin(token,
|
|
9364
|
+
const tableBlock = this.createTableBlock(token, `${this.id}-block-${blockIndex}`, this.getInterBlockMargin(token, nextToken));
|
|
9579
9365
|
renderable = tableBlock.renderable;
|
|
9580
9366
|
tableContentCache = tableBlock.tableContentCache;
|
|
9581
9367
|
} else {
|
|
9582
|
-
renderable = this.createDefaultRenderable(token, blockIndex,
|
|
9368
|
+
renderable = this.createDefaultRenderable(token, blockIndex, nextToken) ?? undefined;
|
|
9583
9369
|
}
|
|
9584
9370
|
}
|
|
9585
9371
|
if (token.type === "table" && !tableContentCache && renderable instanceof TextTableRenderable) {
|
|
@@ -9592,7 +9378,8 @@ class MarkdownRenderable extends Renderable {
|
|
|
9592
9378
|
token,
|
|
9593
9379
|
tokenRaw: token.raw,
|
|
9594
9380
|
renderable,
|
|
9595
|
-
tableContentCache
|
|
9381
|
+
tableContentCache,
|
|
9382
|
+
tracksInterBlockMargin
|
|
9596
9383
|
};
|
|
9597
9384
|
}
|
|
9598
9385
|
blockIndex++;
|
|
@@ -9616,8 +9403,7 @@ class MarkdownRenderable extends Renderable {
|
|
|
9616
9403
|
}
|
|
9617
9404
|
for (let i = 0;i < this._blockStates.length; i++) {
|
|
9618
9405
|
const state = this._blockStates[i];
|
|
9619
|
-
const
|
|
9620
|
-
const marginBottom = this.getInterBlockMargin(state.token, hasNextToken);
|
|
9406
|
+
const marginBottom = this.getInterBlockMargin(state.token, this._blockStates[i + 1]?.token);
|
|
9621
9407
|
if (state.token.type === "code") {
|
|
9622
9408
|
this.applyCodeBlockRenderable(state.renderable, state.token, marginBottom);
|
|
9623
9409
|
continue;
|
|
@@ -9627,7 +9413,7 @@ class MarkdownRenderable extends Renderable {
|
|
|
9627
9413
|
continue;
|
|
9628
9414
|
}
|
|
9629
9415
|
if (state.token.type === "list") {
|
|
9630
|
-
this.updateBlockRenderable(state, state.token, i,
|
|
9416
|
+
this.updateBlockRenderable(state, state.token, i, this._blockStates[i + 1]?.token, true);
|
|
9631
9417
|
continue;
|
|
9632
9418
|
}
|
|
9633
9419
|
if (state.token.type === "hr") {
|
|
@@ -10671,6 +10457,18 @@ class ScrollBoxRenderable extends BoxRenderable {
|
|
|
10671
10457
|
return false;
|
|
10672
10458
|
}
|
|
10673
10459
|
}
|
|
10460
|
+
isAtStickyReengagePoint(stickyStart, maxScrollTop, maxScrollLeft) {
|
|
10461
|
+
switch (stickyStart) {
|
|
10462
|
+
case "top":
|
|
10463
|
+
return maxScrollTop > 0 && this.scrollTop <= 0;
|
|
10464
|
+
case "bottom":
|
|
10465
|
+
return maxScrollTop > 0 && this.scrollTop >= maxScrollTop - 1;
|
|
10466
|
+
case "left":
|
|
10467
|
+
return maxScrollLeft > 0 && this.scrollLeft <= 0;
|
|
10468
|
+
case "right":
|
|
10469
|
+
return maxScrollLeft > 0 && this.scrollLeft >= maxScrollLeft - 1;
|
|
10470
|
+
}
|
|
10471
|
+
}
|
|
10674
10472
|
add(obj, index) {
|
|
10675
10473
|
return this.content.add(obj, index);
|
|
10676
10474
|
}
|
|
@@ -10869,9 +10667,13 @@ class ScrollBoxRenderable extends BoxRenderable {
|
|
|
10869
10667
|
if (this._stickyScroll) {
|
|
10870
10668
|
const newMaxScrollTop = Math.max(0, this.scrollHeight - this.viewport.height);
|
|
10871
10669
|
const newMaxScrollLeft = Math.max(0, this.scrollWidth - this.viewport.width);
|
|
10872
|
-
|
|
10873
|
-
|
|
10874
|
-
|
|
10670
|
+
const stickyStart = this._stickyStart;
|
|
10671
|
+
if (stickyStart && !this._hasManualScroll) {
|
|
10672
|
+
this.applyStickyStart(stickyStart);
|
|
10673
|
+
} else if (stickyStart && this._hasManualScroll && this.isAtStickyReengagePoint(stickyStart, newMaxScrollTop, newMaxScrollLeft)) {
|
|
10674
|
+
this._hasManualScroll = false;
|
|
10675
|
+
this.applyStickyStart(stickyStart);
|
|
10676
|
+
} else if (!this._hasManualScroll) {
|
|
10875
10677
|
if (this._stickyScrollTop) {
|
|
10876
10678
|
this.scrollTop = 0;
|
|
10877
10679
|
} else if (this._stickyScrollBottom && newMaxScrollTop > 0) {
|
|
@@ -11731,7 +11533,7 @@ class TimeToFirstDrawRenderable extends Renderable {
|
|
|
11731
11533
|
return Math.max(0, Math.floor(value));
|
|
11732
11534
|
}
|
|
11733
11535
|
}
|
|
11734
|
-
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,
|
|
11536
|
+
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, 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
11537
|
|
|
11736
|
-
//# debugId=
|
|
11737
|
-
//# sourceMappingURL=index-
|
|
11538
|
+
//# debugId=FF9419E6A578C71164756E2164756E21
|
|
11539
|
+
//# sourceMappingURL=index-sq86yyfz.js.map
|