@opentui/core 0.8.0 → 0.8.2
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/NativeScene.d.ts +10 -2
- package/NativeSession.d.ts +22 -2
- package/buffer.d.ts +2 -0
- package/{chunk-bun-6kxdhkdc.js → chunk-bun-vd3rj9kv.js} +451 -74
- package/{chunk-bun-6kxdhkdc.js.map → chunk-bun-vd3rj9kv.js.map} +10 -10
- package/{chunk-bun-x6cz4jyg.js → chunk-bun-wdetc10w.js} +222 -10
- package/chunk-bun-wdetc10w.js.map +35 -0
- package/{chunk-node-y0w0hq5m.js → chunk-node-m8mjyx7h.js} +222 -10
- package/chunk-node-m8mjyx7h.js.map +34 -0
- package/{chunk-node-q5ccgbk5.js → chunk-node-s9be55eh.js} +451 -74
- package/{chunk-node-q5ccgbk5.js.map → chunk-node-s9be55eh.js.map} +10 -10
- package/index.bun.js +684 -415
- package/index.bun.js.map +13 -12
- package/index.d.ts +1 -1
- package/index.node.js +684 -415
- package/index.node.js.map +13 -11
- package/native-abi.generated.d.ts +171 -3
- package/package.json +9 -9
- package/renderables/Image.d.ts +13 -1
- package/renderables/LineNumberRenderable.d.ts +1 -1
- package/renderables/Markdown.d.ts +1 -6
- package/renderables/ScrollBox.d.ts +1 -1
- package/renderables/Select.d.ts +0 -2
- package/renderables/TabSelect.d.ts +0 -3
- package/renderables/TextTable.d.ts +1 -8
- package/renderables/Video.d.ts +126 -0
- package/renderables/index.d.ts +1 -0
- package/renderables/markdown-parser.d.ts +1 -0
- package/renderer.d.ts +23 -2
- package/testing.bun.js +2 -2
- package/testing.js +2 -2
- package/yoga.bun.js +1 -1
- package/yoga.js +1 -1
- package/zig.d.ts +54 -2
- package/chunk-bun-x6cz4jyg.js.map +0 -35
- package/chunk-node-y0w0hq5m.js.map +0 -34
package/index.bun.js
CHANGED
|
@@ -7,7 +7,6 @@ import {
|
|
|
7
7
|
generateEnvMarkdown2,
|
|
8
8
|
generateEnvColored2,
|
|
9
9
|
env2,
|
|
10
|
-
stringWidth,
|
|
11
10
|
resolveBundledFilePath2,
|
|
12
11
|
TextAttributes2,
|
|
13
12
|
ATTRIBUTE_BASE_BITS2,
|
|
@@ -121,7 +120,7 @@ import {
|
|
|
121
120
|
Gutter2,
|
|
122
121
|
MeasureMode2,
|
|
123
122
|
exports_yoga
|
|
124
|
-
} from "./chunk-bun-
|
|
123
|
+
} from "./chunk-bun-wdetc10w.js";
|
|
125
124
|
import {
|
|
126
125
|
isValidBorderStyle2,
|
|
127
126
|
parseBorderStyle2,
|
|
@@ -229,6 +228,8 @@ import {
|
|
|
229
228
|
NativeImage2,
|
|
230
229
|
NativeImagePool2,
|
|
231
230
|
resolveImageRenderProtocol2,
|
|
231
|
+
checkCrop2,
|
|
232
|
+
sameCrop2,
|
|
232
233
|
ImageRenderable2,
|
|
233
234
|
isTextNodeRenderable2,
|
|
234
235
|
TextNodeRenderable2,
|
|
@@ -253,7 +254,7 @@ import {
|
|
|
253
254
|
CliRenderEvents2,
|
|
254
255
|
RendererControlState2,
|
|
255
256
|
CliRenderer2
|
|
256
|
-
} from "./chunk-bun-
|
|
257
|
+
} from "./chunk-bun-vd3rj9kv.js";
|
|
257
258
|
// src/syntax-style.ts
|
|
258
259
|
function cloneStyle(style) {
|
|
259
260
|
return {
|
|
@@ -4742,7 +4743,10 @@ class AudioRecorder extends EventEmitter {
|
|
|
4742
4743
|
await this.writeFully(createWavHeader(this.sampleRate, this.channels, Number(this.dataBytesWritten)), 0, "finalize");
|
|
4743
4744
|
if (this.terminationRequest != null)
|
|
4744
4745
|
return;
|
|
4745
|
-
await this.fileHandle.sync()
|
|
4746
|
+
await this.fileHandle.sync().catch((cause) => {
|
|
4747
|
+
if (cause.code !== "ERR_ACCESS_DENIED")
|
|
4748
|
+
throw cause;
|
|
4749
|
+
});
|
|
4746
4750
|
if (this.terminationRequest != null)
|
|
4747
4751
|
return;
|
|
4748
4752
|
await this.fileHandle.close();
|
|
@@ -6087,6 +6091,7 @@ class VRenderable extends Renderable2 {
|
|
|
6087
6091
|
// src/renderables/LineNumberRenderable.ts
|
|
6088
6092
|
var DEFAULT_GUTTER_FG = "#888888";
|
|
6089
6093
|
var DEFAULT_GUTTER_BG = "transparent";
|
|
6094
|
+
var transparent = RGBA2.fromValues(0, 0, 0, 0);
|
|
6090
6095
|
function cloneLineSign(sign) {
|
|
6091
6096
|
return {
|
|
6092
6097
|
...sign,
|
|
@@ -6109,8 +6114,8 @@ class GutterRenderable extends Renderable2 {
|
|
|
6109
6114
|
_maxBeforeWidth = 0;
|
|
6110
6115
|
_maxAfterWidth = 0;
|
|
6111
6116
|
_lastKnownLineCount = 0;
|
|
6112
|
-
|
|
6113
|
-
|
|
6117
|
+
_signWidths = new Map;
|
|
6118
|
+
_signWidthMethod;
|
|
6114
6119
|
constructor(ctx, target, options) {
|
|
6115
6120
|
super(ctx, {
|
|
6116
6121
|
id: options.id,
|
|
@@ -6135,7 +6140,10 @@ class GutterRenderable extends Renderable2 {
|
|
|
6135
6140
|
this.setupMeasureFunc();
|
|
6136
6141
|
this.onLifecyclePass = () => {
|
|
6137
6142
|
const currentLineCount = this.target.virtualLineCount;
|
|
6138
|
-
|
|
6143
|
+
const signsStale = this._ctx.widthMethod !== this._signWidthMethod;
|
|
6144
|
+
if (signsStale)
|
|
6145
|
+
this.calculateSignWidths();
|
|
6146
|
+
if (currentLineCount !== this._lastKnownLineCount || signsStale) {
|
|
6139
6147
|
this._lastKnownLineCount = currentLineCount;
|
|
6140
6148
|
this.invalidateIntrinsicSize();
|
|
6141
6149
|
this.requestRender();
|
|
@@ -6186,16 +6194,30 @@ class GutterRenderable extends Renderable2 {
|
|
|
6186
6194
|
calculateSignWidths() {
|
|
6187
6195
|
this._maxBeforeWidth = 0;
|
|
6188
6196
|
this._maxAfterWidth = this._layout.minAfterWidth;
|
|
6197
|
+
this._signWidths.clear();
|
|
6198
|
+
this._signWidthMethod = this._ctx.widthMethod;
|
|
6189
6199
|
for (const sign of this._lineSigns.values()) {
|
|
6190
|
-
if (sign.before)
|
|
6191
|
-
|
|
6192
|
-
|
|
6193
|
-
|
|
6194
|
-
|
|
6195
|
-
|
|
6196
|
-
|
|
6197
|
-
|
|
6200
|
+
if (sign.before)
|
|
6201
|
+
this._maxBeforeWidth = Math.max(this._maxBeforeWidth, this.signWidth(sign.before));
|
|
6202
|
+
if (sign.after)
|
|
6203
|
+
this._maxAfterWidth = Math.max(this._maxAfterWidth, this.signWidth(sign.after));
|
|
6204
|
+
}
|
|
6205
|
+
}
|
|
6206
|
+
signWidth(sign) {
|
|
6207
|
+
if (/^[\x20-\x7e]*$/.test(sign))
|
|
6208
|
+
return sign.length;
|
|
6209
|
+
let width = this._signWidths.get(sign);
|
|
6210
|
+
if (width !== undefined)
|
|
6211
|
+
return width;
|
|
6212
|
+
const { context, renderLib } = this._ctx.nativeScene.driver;
|
|
6213
|
+
const unicode = renderLib.createContextUnicode(context, sign, this._signWidthMethod);
|
|
6214
|
+
try {
|
|
6215
|
+
width = renderLib.getContextUnicode(context, unicode).reduce((sum, glyph) => sum + glyph.width, 0);
|
|
6216
|
+
} finally {
|
|
6217
|
+
renderLib.destroyContextUnicode(context, unicode);
|
|
6198
6218
|
}
|
|
6219
|
+
this._signWidths.set(sign, width);
|
|
6220
|
+
return width;
|
|
6199
6221
|
}
|
|
6200
6222
|
calculateWidth() {
|
|
6201
6223
|
const totalLines = Math.max(this.target.lineCount, this.target.virtualLineCount);
|
|
@@ -6251,81 +6273,48 @@ class GutterRenderable extends Renderable2 {
|
|
|
6251
6273
|
getLineSigns() {
|
|
6252
6274
|
return this._lineSigns;
|
|
6253
6275
|
}
|
|
6254
|
-
createFrameBuffer() {}
|
|
6255
|
-
handleFrameBufferResize() {}
|
|
6256
6276
|
renderSelf(buffer) {
|
|
6257
|
-
const x =
|
|
6258
|
-
const y = Math.trunc(this._screenY);
|
|
6277
|
+
const [x, y] = this._paintOrigin(buffer);
|
|
6259
6278
|
const start = Math.max(0, -y);
|
|
6260
6279
|
const end = Math.min(this.height, buffer.height - y);
|
|
6261
6280
|
if (end <= start || x >= buffer.width || x + this.width <= 0)
|
|
6262
6281
|
return;
|
|
6263
|
-
|
|
6264
|
-
this.frameBuffer = OptimizedBuffer2.create(this.width, end - start, this._ctx.widthMethod, {
|
|
6265
|
-
respectAlpha: true,
|
|
6266
|
-
id: `framebuffer-${this.id}`,
|
|
6267
|
-
owner: this._ctx.nativeScene
|
|
6268
|
-
});
|
|
6269
|
-
} else if (this.frameBuffer.width !== this.width || this.frameBuffer.height !== end - start) {
|
|
6270
|
-
this.frameBuffer.resize(this.width, end - start);
|
|
6271
|
-
this._paintedSources = undefined;
|
|
6272
|
-
}
|
|
6273
|
-
this.refreshFrameBuffer(this.frameBuffer, Math.trunc(this.target.scrollY) + start);
|
|
6274
|
-
this.markClean();
|
|
6275
|
-
buffer.drawFrameBuffer(x, y + start, this.frameBuffer);
|
|
6276
|
-
}
|
|
6277
|
-
refreshFrameBuffer(buffer, startLine) {
|
|
6282
|
+
const startLine = Math.trunc(this.target.scrollY) + start;
|
|
6278
6283
|
const sourceStart = Math.max(0, startLine - 1);
|
|
6279
6284
|
const sourceOffset = startLine - sourceStart;
|
|
6280
|
-
const sources = getLineSources(this.target, sourceStart,
|
|
6281
|
-
const paintedSources = this._paintedSources;
|
|
6282
|
-
if (!this.isDirty && sourceOffset === this._paintedSourceOffset && paintedSources && sources.length === paintedSources.length && sources.every((source, i) => source === paintedSources[i])) {
|
|
6283
|
-
return;
|
|
6284
|
-
}
|
|
6285
|
-
buffer.clear(this._bg);
|
|
6285
|
+
const sources = getLineSources(this.target, sourceStart, end - start + sourceOffset);
|
|
6286
6286
|
let lastSource = sourceOffset > 0 ? sources[0] : -1;
|
|
6287
|
-
for (let i =
|
|
6288
|
-
const
|
|
6289
|
-
|
|
6290
|
-
|
|
6291
|
-
|
|
6292
|
-
|
|
6293
|
-
if (lineBg
|
|
6294
|
-
buffer.fillRect(
|
|
6295
|
-
|
|
6296
|
-
if (logicalLine === lastSource) {} else {
|
|
6297
|
-
let currentX = 0;
|
|
6287
|
+
for (let i = sourceOffset;i < end - start + sourceOffset; i++) {
|
|
6288
|
+
const row = y + start + i - sourceOffset;
|
|
6289
|
+
const logicalLine = sources[i];
|
|
6290
|
+
const lineBg = this._lineColorsGutter.get(logicalLine);
|
|
6291
|
+
if (!lineBg || lineBg.a < 1)
|
|
6292
|
+
buffer.fillRect(x, row, this.width, 1, this._bg);
|
|
6293
|
+
if (lineBg)
|
|
6294
|
+
buffer.fillRect(x, row, this.width, 1, lineBg);
|
|
6295
|
+
if (logicalLine !== undefined && logicalLine !== lastSource) {
|
|
6298
6296
|
const sign = this._lineSigns.get(logicalLine);
|
|
6299
6297
|
if (sign?.before) {
|
|
6300
|
-
const
|
|
6301
|
-
const padding = this._maxBeforeWidth - beforeWidth;
|
|
6302
|
-
currentX += padding;
|
|
6298
|
+
const beforeX = x + this._maxBeforeWidth - this.signWidth(sign.before);
|
|
6303
6299
|
const beforeColor = sign.beforeColor ? parseColor2(sign.beforeColor) : this._fg;
|
|
6304
|
-
buffer.drawText(sign.before,
|
|
6305
|
-
currentX += beforeWidth;
|
|
6306
|
-
} else if (this._maxBeforeWidth > 0) {
|
|
6307
|
-
currentX += this._maxBeforeWidth;
|
|
6300
|
+
buffer.drawText(sign.before, beforeX, row, beforeColor, transparent);
|
|
6308
6301
|
}
|
|
6309
6302
|
if (!this._hideLineNumbers.has(logicalLine)) {
|
|
6310
6303
|
const customLineNum = this._lineNumbers.get(logicalLine);
|
|
6311
|
-
const
|
|
6312
|
-
const
|
|
6313
|
-
const lineNumWidth = lineNumStr.length;
|
|
6314
|
-
const lineNumX = this.width - this._maxAfterWidth - this._layout.paddingRight - lineNumWidth;
|
|
6304
|
+
const lineNumStr = (customLineNum ?? logicalLine + 1 + this._lineNumberOffset).toString();
|
|
6305
|
+
const lineNumX = this.width - this._maxAfterWidth - this._layout.paddingRight - lineNumStr.length;
|
|
6315
6306
|
if (lineNumX >= this._maxBeforeWidth + this._layout.paddingLeft) {
|
|
6316
|
-
buffer.drawText(lineNumStr, lineNumX,
|
|
6307
|
+
buffer.drawText(lineNumStr, x + lineNumX, row, this._fg, transparent);
|
|
6317
6308
|
}
|
|
6318
6309
|
}
|
|
6319
6310
|
if (sign?.after) {
|
|
6320
|
-
const afterX = this.width - this._layout.paddingRight - this._maxAfterWidth;
|
|
6311
|
+
const afterX = x + this.width - this._layout.paddingRight - this._maxAfterWidth;
|
|
6321
6312
|
const afterColor = sign.afterColor ? parseColor2(sign.afterColor) : this._fg;
|
|
6322
|
-
buffer.drawText(sign.after, afterX,
|
|
6313
|
+
buffer.drawText(sign.after, afterX, row, afterColor, transparent);
|
|
6323
6314
|
}
|
|
6324
6315
|
}
|
|
6325
6316
|
lastSource = logicalLine;
|
|
6326
6317
|
}
|
|
6327
|
-
this._paintedSources = sources.slice();
|
|
6328
|
-
this._paintedSourceOffset = sourceOffset;
|
|
6329
6318
|
}
|
|
6330
6319
|
}
|
|
6331
6320
|
function getLineSources(target, startLine, lineCount) {
|
|
@@ -9043,6 +9032,472 @@ class InputRenderable extends TextareaRenderable {
|
|
|
9043
9032
|
}
|
|
9044
9033
|
set initialValue(value) {}
|
|
9045
9034
|
}
|
|
9035
|
+
// src/renderables/Video.ts
|
|
9036
|
+
function validateVolume(value) {
|
|
9037
|
+
if (!Number.isFinite(value) || value < 0 || value > 340282346638528860000000000000000000000)
|
|
9038
|
+
throw new RangeError("volume must be a finite, non-negative 32-bit float");
|
|
9039
|
+
}
|
|
9040
|
+
function validateAvSyncOffset(value) {
|
|
9041
|
+
if (!Number.isFinite(value) || Math.abs(value) > 60000)
|
|
9042
|
+
throw new RangeError("avSyncOffsetMs must be from -60000 to 60000");
|
|
9043
|
+
}
|
|
9044
|
+
function validateMaxFps(value) {
|
|
9045
|
+
if (!Number.isInteger(value) || value < 1 || value > 120)
|
|
9046
|
+
throw new RangeError("maxFps must be an integer from 1 to 120");
|
|
9047
|
+
}
|
|
9048
|
+
function toMicroseconds(seconds, label) {
|
|
9049
|
+
const value = Math.round(seconds * 1e6);
|
|
9050
|
+
if (!Number.isFinite(seconds) || !Number.isSafeInteger(value))
|
|
9051
|
+
throw new RangeError(`${label} must be finite`);
|
|
9052
|
+
return BigInt(value);
|
|
9053
|
+
}
|
|
9054
|
+
|
|
9055
|
+
class VideoRenderable extends Renderable2 {
|
|
9056
|
+
static nativeIntegration = {
|
|
9057
|
+
kind: "video",
|
|
9058
|
+
body: { native: this.prototype.renderSelf, buffered: true },
|
|
9059
|
+
bufferComposition: "native"
|
|
9060
|
+
};
|
|
9061
|
+
_source;
|
|
9062
|
+
_fit;
|
|
9063
|
+
_crop;
|
|
9064
|
+
_loop;
|
|
9065
|
+
_audio;
|
|
9066
|
+
_muted;
|
|
9067
|
+
_volume;
|
|
9068
|
+
_avSyncOffsetMs;
|
|
9069
|
+
_maxFps;
|
|
9070
|
+
_autoplay;
|
|
9071
|
+
_metadata = null;
|
|
9072
|
+
_playRequested = false;
|
|
9073
|
+
stopTick;
|
|
9074
|
+
_opens = 0;
|
|
9075
|
+
onReady;
|
|
9076
|
+
onError;
|
|
9077
|
+
onEnd;
|
|
9078
|
+
onPlay;
|
|
9079
|
+
onPause;
|
|
9080
|
+
onSeek;
|
|
9081
|
+
onTimeUpdate;
|
|
9082
|
+
constructor(ctx, options) {
|
|
9083
|
+
super(ctx, options);
|
|
9084
|
+
try {
|
|
9085
|
+
this._fit = options.fit ?? "fit";
|
|
9086
|
+
this._loop = options.loop ?? false;
|
|
9087
|
+
this._audio = options.audio ?? true;
|
|
9088
|
+
this._muted = options.muted ?? false;
|
|
9089
|
+
this._volume = options.volume ?? 1;
|
|
9090
|
+
validateVolume(this._volume);
|
|
9091
|
+
this._avSyncOffsetMs = options.avSyncOffsetMs ?? 0;
|
|
9092
|
+
validateAvSyncOffset(this._avSyncOffsetMs);
|
|
9093
|
+
this._maxFps = options.maxFps ?? 30;
|
|
9094
|
+
validateMaxFps(this._maxFps);
|
|
9095
|
+
this._autoplay = options.autoplay ?? false;
|
|
9096
|
+
this.onReady = options.onReady;
|
|
9097
|
+
this.onError = options.onError;
|
|
9098
|
+
this.onEnd = options.onEnd;
|
|
9099
|
+
this.onPlay = options.onPlay;
|
|
9100
|
+
this.onPause = options.onPause;
|
|
9101
|
+
this.onSeek = options.onSeek;
|
|
9102
|
+
this.onTimeUpdate = options.onTimeUpdate;
|
|
9103
|
+
this.setNativeSceneVideo();
|
|
9104
|
+
if (options.source !== undefined)
|
|
9105
|
+
this.source = options.source;
|
|
9106
|
+
this.crop = options.crop;
|
|
9107
|
+
} catch (error) {
|
|
9108
|
+
this.abortConstruction(error, () => this.destroySelf());
|
|
9109
|
+
}
|
|
9110
|
+
}
|
|
9111
|
+
get source() {
|
|
9112
|
+
return this._source;
|
|
9113
|
+
}
|
|
9114
|
+
set source(value) {
|
|
9115
|
+
value ??= undefined;
|
|
9116
|
+
if (value === this._source && !this.failed() || this.isDestroyed)
|
|
9117
|
+
return;
|
|
9118
|
+
this.open(value, this.playing);
|
|
9119
|
+
}
|
|
9120
|
+
open(value, resume) {
|
|
9121
|
+
this._opens++;
|
|
9122
|
+
this._source = value;
|
|
9123
|
+
this._metadata = null;
|
|
9124
|
+
this._playRequested = resume;
|
|
9125
|
+
const native = this.native();
|
|
9126
|
+
try {
|
|
9127
|
+
const info = native.lib.videoOpen(native.context, native.node, value ?? "", this._audio);
|
|
9128
|
+
if (!value)
|
|
9129
|
+
return;
|
|
9130
|
+
this._playRequested = resume || this._autoplay;
|
|
9131
|
+
this._metadata = {
|
|
9132
|
+
width: info.width,
|
|
9133
|
+
height: info.height,
|
|
9134
|
+
fps: info.fpsDen > 0 ? info.fpsNum / info.fpsDen : 0,
|
|
9135
|
+
duration: Number(info.durationUs) / 1e6,
|
|
9136
|
+
hasAudio: info.hasAudio
|
|
9137
|
+
};
|
|
9138
|
+
native.lib.videoSetLoop(native.context, native.node, this._loop);
|
|
9139
|
+
native.lib.videoSetMuted(native.context, native.node, this._muted);
|
|
9140
|
+
native.lib.videoSetVolume(native.context, native.node, this._volume);
|
|
9141
|
+
native.lib.videoSetAvSyncOffset(native.context, native.node, toMicroseconds(this._avSyncOffsetMs / 1000, "avSyncOffsetMs"));
|
|
9142
|
+
native.lib.videoSetMaxFps(native.context, native.node, this._maxFps);
|
|
9143
|
+
const metadata = { ...this._metadata };
|
|
9144
|
+
this.afterOpen(() => {
|
|
9145
|
+
this.onReady?.(metadata);
|
|
9146
|
+
this.startRequested();
|
|
9147
|
+
try {
|
|
9148
|
+
if (this._crop)
|
|
9149
|
+
checkCrop2(this._crop, metadata.width, metadata.height);
|
|
9150
|
+
} catch (error) {
|
|
9151
|
+
this.reportError(error, "");
|
|
9152
|
+
}
|
|
9153
|
+
});
|
|
9154
|
+
} catch (error) {
|
|
9155
|
+
this._metadata = null;
|
|
9156
|
+
this._playRequested = false;
|
|
9157
|
+
const detail = this.errorDetail("");
|
|
9158
|
+
this.afterOpen(() => this.reportError(error, detail));
|
|
9159
|
+
} finally {
|
|
9160
|
+
this.syncPlayback();
|
|
9161
|
+
this.requestRender();
|
|
9162
|
+
}
|
|
9163
|
+
}
|
|
9164
|
+
get fit() {
|
|
9165
|
+
return this._fit;
|
|
9166
|
+
}
|
|
9167
|
+
set fit(value) {
|
|
9168
|
+
const next = value ?? "fit";
|
|
9169
|
+
if (this._fit === next || this.isDestroyed)
|
|
9170
|
+
return;
|
|
9171
|
+
this.setNativeSceneVideo(next);
|
|
9172
|
+
this._fit = next;
|
|
9173
|
+
this.requestRender();
|
|
9174
|
+
}
|
|
9175
|
+
get crop() {
|
|
9176
|
+
return this._crop && { ...this._crop };
|
|
9177
|
+
}
|
|
9178
|
+
set crop(value) {
|
|
9179
|
+
if (sameCrop2(this._crop, value ?? undefined) || this.isDestroyed)
|
|
9180
|
+
return;
|
|
9181
|
+
const next = this.acceptCrop(value ?? undefined);
|
|
9182
|
+
if (next === null)
|
|
9183
|
+
return;
|
|
9184
|
+
this._ctx.nativeScene.setCrop(this, next);
|
|
9185
|
+
this._crop = next;
|
|
9186
|
+
this.requestRender();
|
|
9187
|
+
}
|
|
9188
|
+
get loop() {
|
|
9189
|
+
return this._loop;
|
|
9190
|
+
}
|
|
9191
|
+
set loop(value) {
|
|
9192
|
+
const next = value ?? false;
|
|
9193
|
+
if (this._loop === next || this.isDestroyed)
|
|
9194
|
+
return;
|
|
9195
|
+
if (this.applyOption((native) => native.lib.videoSetLoop(native.context, native.node, next)))
|
|
9196
|
+
this._loop = next;
|
|
9197
|
+
}
|
|
9198
|
+
get audio() {
|
|
9199
|
+
return this._audio;
|
|
9200
|
+
}
|
|
9201
|
+
set audio(value) {
|
|
9202
|
+
const next = value ?? true;
|
|
9203
|
+
if (this._audio === next || this.isDestroyed)
|
|
9204
|
+
return;
|
|
9205
|
+
this._audio = next;
|
|
9206
|
+
if (this._metadata)
|
|
9207
|
+
this.open(this._source, this.playing);
|
|
9208
|
+
}
|
|
9209
|
+
get muted() {
|
|
9210
|
+
return this._muted;
|
|
9211
|
+
}
|
|
9212
|
+
set muted(value) {
|
|
9213
|
+
const next = value ?? false;
|
|
9214
|
+
if (this._muted === next || this.isDestroyed)
|
|
9215
|
+
return;
|
|
9216
|
+
if (this.applyOption((native) => native.lib.videoSetMuted(native.context, native.node, next)))
|
|
9217
|
+
this._muted = next;
|
|
9218
|
+
}
|
|
9219
|
+
get volume() {
|
|
9220
|
+
return this._volume;
|
|
9221
|
+
}
|
|
9222
|
+
set volume(value) {
|
|
9223
|
+
const next = value ?? 1;
|
|
9224
|
+
validateVolume(next);
|
|
9225
|
+
if (this._volume === next || this.isDestroyed)
|
|
9226
|
+
return;
|
|
9227
|
+
if (this.applyOption((native) => native.lib.videoSetVolume(native.context, native.node, next)))
|
|
9228
|
+
this._volume = next;
|
|
9229
|
+
}
|
|
9230
|
+
get avSyncOffsetMs() {
|
|
9231
|
+
return this._avSyncOffsetMs;
|
|
9232
|
+
}
|
|
9233
|
+
set avSyncOffsetMs(value) {
|
|
9234
|
+
const next = value ?? 0;
|
|
9235
|
+
validateAvSyncOffset(next);
|
|
9236
|
+
if (this._avSyncOffsetMs === next || this.isDestroyed)
|
|
9237
|
+
return;
|
|
9238
|
+
const offset = toMicroseconds(next / 1000, "avSyncOffsetMs");
|
|
9239
|
+
if (this.applyOption((native) => native.lib.videoSetAvSyncOffset(native.context, native.node, offset)))
|
|
9240
|
+
this._avSyncOffsetMs = next;
|
|
9241
|
+
}
|
|
9242
|
+
get maxFps() {
|
|
9243
|
+
return this._maxFps;
|
|
9244
|
+
}
|
|
9245
|
+
set maxFps(value) {
|
|
9246
|
+
const next = value ?? 30;
|
|
9247
|
+
validateMaxFps(next);
|
|
9248
|
+
if (this._maxFps === next || this.isDestroyed)
|
|
9249
|
+
return;
|
|
9250
|
+
if (!this.applyOption((native) => native.lib.videoSetMaxFps(native.context, native.node, next)))
|
|
9251
|
+
return;
|
|
9252
|
+
this._maxFps = next;
|
|
9253
|
+
this.syncPlayback();
|
|
9254
|
+
}
|
|
9255
|
+
get autoplay() {
|
|
9256
|
+
return this._autoplay;
|
|
9257
|
+
}
|
|
9258
|
+
set autoplay(value) {
|
|
9259
|
+
const next = value ?? false;
|
|
9260
|
+
if (this._autoplay === next || this.isDestroyed)
|
|
9261
|
+
return;
|
|
9262
|
+
this._autoplay = next;
|
|
9263
|
+
if (!next || !this._metadata)
|
|
9264
|
+
return;
|
|
9265
|
+
const requested = this.control((native) => {
|
|
9266
|
+
const state = native.lib.videoGetState(native.context, native.node);
|
|
9267
|
+
if (state.playing || state.ended || state.currentTimeUs !== 0n)
|
|
9268
|
+
return false;
|
|
9269
|
+
this._playRequested = true;
|
|
9270
|
+
});
|
|
9271
|
+
if (requested)
|
|
9272
|
+
this.afterOpen(() => this.startRequested());
|
|
9273
|
+
}
|
|
9274
|
+
get ready() {
|
|
9275
|
+
return this._metadata !== null;
|
|
9276
|
+
}
|
|
9277
|
+
get videoMetadata() {
|
|
9278
|
+
return this._metadata ? { ...this._metadata } : null;
|
|
9279
|
+
}
|
|
9280
|
+
get playing() {
|
|
9281
|
+
if (this.isDestroyed)
|
|
9282
|
+
return false;
|
|
9283
|
+
return this._playRequested || this._metadata !== null && this.readState().playing;
|
|
9284
|
+
}
|
|
9285
|
+
get paused() {
|
|
9286
|
+
return !this.playing;
|
|
9287
|
+
}
|
|
9288
|
+
get ended() {
|
|
9289
|
+
return this._metadata !== null && !this.isDestroyed && this.readState().ended;
|
|
9290
|
+
}
|
|
9291
|
+
get duration() {
|
|
9292
|
+
return this._metadata?.duration ?? 0;
|
|
9293
|
+
}
|
|
9294
|
+
get durationMs() {
|
|
9295
|
+
return this.duration * 1000;
|
|
9296
|
+
}
|
|
9297
|
+
get currentTime() {
|
|
9298
|
+
if (!this._metadata || this.isDestroyed)
|
|
9299
|
+
return 0;
|
|
9300
|
+
return Number(this.readState().currentTimeUs) / 1e6;
|
|
9301
|
+
}
|
|
9302
|
+
set currentTime(value) {
|
|
9303
|
+
if (value == null)
|
|
9304
|
+
return;
|
|
9305
|
+
this.seek(value);
|
|
9306
|
+
}
|
|
9307
|
+
get qualityTier() {
|
|
9308
|
+
if (!this._metadata || this.isDestroyed)
|
|
9309
|
+
return 0;
|
|
9310
|
+
return this.readState().qualityTier;
|
|
9311
|
+
}
|
|
9312
|
+
get currentTimeMs() {
|
|
9313
|
+
return this.currentTime * 1000;
|
|
9314
|
+
}
|
|
9315
|
+
play() {
|
|
9316
|
+
if (this.isDestroyed || this._playRequested)
|
|
9317
|
+
return;
|
|
9318
|
+
if (!this._metadata) {
|
|
9319
|
+
if (this._source !== undefined)
|
|
9320
|
+
this.open(this._source, true);
|
|
9321
|
+
else
|
|
9322
|
+
this._playRequested = true;
|
|
9323
|
+
return;
|
|
9324
|
+
}
|
|
9325
|
+
const started = this.control((native) => {
|
|
9326
|
+
if (native.lib.videoGetState(native.context, native.node).playing)
|
|
9327
|
+
return false;
|
|
9328
|
+
native.lib.videoCall(native.context, native.node, "ot_video_play");
|
|
9329
|
+
});
|
|
9330
|
+
if (started)
|
|
9331
|
+
this.onPlay?.();
|
|
9332
|
+
}
|
|
9333
|
+
resume() {
|
|
9334
|
+
this.play();
|
|
9335
|
+
}
|
|
9336
|
+
pause() {
|
|
9337
|
+
if (this.isDestroyed)
|
|
9338
|
+
return;
|
|
9339
|
+
const requested = this._playRequested;
|
|
9340
|
+
this._playRequested = false;
|
|
9341
|
+
if (!this._metadata)
|
|
9342
|
+
return;
|
|
9343
|
+
const paused = this.control((native) => {
|
|
9344
|
+
if (requested)
|
|
9345
|
+
return;
|
|
9346
|
+
if (!native.lib.videoGetState(native.context, native.node).playing)
|
|
9347
|
+
return false;
|
|
9348
|
+
native.lib.videoCall(native.context, native.node, "ot_video_pause");
|
|
9349
|
+
});
|
|
9350
|
+
if (!paused)
|
|
9351
|
+
return;
|
|
9352
|
+
const time = this.currentTime;
|
|
9353
|
+
this.onPause?.();
|
|
9354
|
+
this.onTimeUpdate?.(time);
|
|
9355
|
+
}
|
|
9356
|
+
toggle() {
|
|
9357
|
+
if (this.playing)
|
|
9358
|
+
this.pause();
|
|
9359
|
+
else
|
|
9360
|
+
this.play();
|
|
9361
|
+
}
|
|
9362
|
+
seek(time) {
|
|
9363
|
+
const target = toMicroseconds(time, "Video time");
|
|
9364
|
+
if (!this._metadata || this.isDestroyed)
|
|
9365
|
+
return;
|
|
9366
|
+
if (!this.control((native) => native.lib.videoSeek(native.context, native.node, target)))
|
|
9367
|
+
return;
|
|
9368
|
+
const position = this.currentTime;
|
|
9369
|
+
this.onSeek?.(position);
|
|
9370
|
+
this.onTimeUpdate?.(position);
|
|
9371
|
+
}
|
|
9372
|
+
seekBy(delta) {
|
|
9373
|
+
if (!Number.isFinite(delta))
|
|
9374
|
+
throw new RangeError("Video seek delta must be finite");
|
|
9375
|
+
this.seek(this.currentTime + delta);
|
|
9376
|
+
}
|
|
9377
|
+
seekToMs(milliseconds) {
|
|
9378
|
+
if (!Number.isFinite(milliseconds))
|
|
9379
|
+
throw new RangeError("Video time must be finite");
|
|
9380
|
+
this.seek(milliseconds / 1000);
|
|
9381
|
+
}
|
|
9382
|
+
createFrameBuffer() {
|
|
9383
|
+
const previous = this.frameBuffer;
|
|
9384
|
+
super.createFrameBuffer();
|
|
9385
|
+
if (this._fit === undefined || this.frameBuffer === previous)
|
|
9386
|
+
return;
|
|
9387
|
+
this.setNativeSceneVideo();
|
|
9388
|
+
}
|
|
9389
|
+
renderSelf(_buffer) {}
|
|
9390
|
+
poll() {
|
|
9391
|
+
if (!this._metadata || this.isDestroyed)
|
|
9392
|
+
return;
|
|
9393
|
+
let state;
|
|
9394
|
+
try {
|
|
9395
|
+
state = this.readState();
|
|
9396
|
+
} catch (error) {
|
|
9397
|
+
this.reportError(error);
|
|
9398
|
+
this.syncPlayback(false);
|
|
9399
|
+
return;
|
|
9400
|
+
}
|
|
9401
|
+
if (state.failed) {
|
|
9402
|
+
this.reportError(new Error(this.errorDetail("Video playback failed")));
|
|
9403
|
+
this.syncPlayback();
|
|
9404
|
+
return;
|
|
9405
|
+
}
|
|
9406
|
+
this.onTimeUpdate?.(Number(state.currentTimeUs) / 1e6);
|
|
9407
|
+
if (state.ended) {
|
|
9408
|
+
this.syncPlayback();
|
|
9409
|
+
this.onEnd?.();
|
|
9410
|
+
}
|
|
9411
|
+
}
|
|
9412
|
+
native() {
|
|
9413
|
+
return this._ctx.nativeScene.videoNode(this);
|
|
9414
|
+
}
|
|
9415
|
+
readState() {
|
|
9416
|
+
const native = this.native();
|
|
9417
|
+
return native.lib.videoGetState(native.context, native.node);
|
|
9418
|
+
}
|
|
9419
|
+
failed() {
|
|
9420
|
+
if (!this._metadata)
|
|
9421
|
+
return false;
|
|
9422
|
+
try {
|
|
9423
|
+
return this.readState().failed;
|
|
9424
|
+
} catch {
|
|
9425
|
+
return true;
|
|
9426
|
+
}
|
|
9427
|
+
}
|
|
9428
|
+
errorDetail(fallback) {
|
|
9429
|
+
try {
|
|
9430
|
+
const native = this.native();
|
|
9431
|
+
return native.lib.videoGetError(native.context, native.node) || fallback;
|
|
9432
|
+
} catch {
|
|
9433
|
+
return fallback;
|
|
9434
|
+
}
|
|
9435
|
+
}
|
|
9436
|
+
applyOption(call) {
|
|
9437
|
+
return !this._metadata || this.control(call);
|
|
9438
|
+
}
|
|
9439
|
+
control(call) {
|
|
9440
|
+
let reported = false;
|
|
9441
|
+
try {
|
|
9442
|
+
return call(this.native()) !== false;
|
|
9443
|
+
} catch (error) {
|
|
9444
|
+
reported = true;
|
|
9445
|
+
this.reportError(error);
|
|
9446
|
+
return false;
|
|
9447
|
+
} finally {
|
|
9448
|
+
this.syncPlayback(!reported);
|
|
9449
|
+
this.requestRender();
|
|
9450
|
+
}
|
|
9451
|
+
}
|
|
9452
|
+
syncPlayback(report = true) {
|
|
9453
|
+
if (this.isDestroyed)
|
|
9454
|
+
return;
|
|
9455
|
+
let active = false;
|
|
9456
|
+
try {
|
|
9457
|
+
active = this._metadata !== null && (this._playRequested || this.readState().playing);
|
|
9458
|
+
} catch (error) {
|
|
9459
|
+
if (report)
|
|
9460
|
+
this.reportError(error);
|
|
9461
|
+
}
|
|
9462
|
+
this.stopTick?.();
|
|
9463
|
+
this.stopTick = active ? this._ctx.onAnimationTick(this._maxFps, () => this.poll()) : undefined;
|
|
9464
|
+
}
|
|
9465
|
+
setNativeSceneVideo(fit = this._fit) {
|
|
9466
|
+
this._ctx.nativeScene.setVideo(this, fit, this.buffered ? this.frameBuffer : null);
|
|
9467
|
+
}
|
|
9468
|
+
acceptCrop(crop) {
|
|
9469
|
+
try {
|
|
9470
|
+
return crop && checkCrop2(crop, this._metadata?.width, this._metadata?.height);
|
|
9471
|
+
} catch (error) {
|
|
9472
|
+
queueMicrotask(() => this.isDestroyed || this.reportError(error, ""));
|
|
9473
|
+
return null;
|
|
9474
|
+
}
|
|
9475
|
+
}
|
|
9476
|
+
startRequested() {
|
|
9477
|
+
if (!this._playRequested)
|
|
9478
|
+
return;
|
|
9479
|
+
this._playRequested = false;
|
|
9480
|
+
if (this.control((native) => native.lib.videoCall(native.context, native.node, "ot_video_play")))
|
|
9481
|
+
this.onPlay?.();
|
|
9482
|
+
}
|
|
9483
|
+
afterOpen(report) {
|
|
9484
|
+
const opens = this._opens;
|
|
9485
|
+
queueMicrotask(() => {
|
|
9486
|
+
if (this._opens === opens && !this.isDestroyed)
|
|
9487
|
+
report();
|
|
9488
|
+
});
|
|
9489
|
+
}
|
|
9490
|
+
reportError(error, detail = this.errorDetail("")) {
|
|
9491
|
+
const value = error instanceof Error ? error : new Error(String(error));
|
|
9492
|
+
this.onError?.(detail && !value.message.includes(detail) ? new Error(`${value.message}: ${detail}`) : value);
|
|
9493
|
+
}
|
|
9494
|
+
destroySelf() {
|
|
9495
|
+
this.runCleanup((run) => {
|
|
9496
|
+
run(() => this.stopTick?.());
|
|
9497
|
+
run(() => super.destroySelf());
|
|
9498
|
+
});
|
|
9499
|
+
}
|
|
9500
|
+
}
|
|
9046
9501
|
// ../../node_modules/.bun/marked@17.0.1/node_modules/marked/lib/marked.esm.js
|
|
9047
9502
|
function L() {
|
|
9048
9503
|
return { async: false, breaks: false, extensions: null, gfm: true, hooks: null, pedantic: false, renderer: null, silent: false, tokenizer: null, walkTokens: null };
|
|
@@ -10417,7 +10872,6 @@ class TextTableRenderable extends Renderable2 {
|
|
|
10417
10872
|
_columnCount = 0;
|
|
10418
10873
|
_layout = this.createEmptyLayout();
|
|
10419
10874
|
_layoutDirty = true;
|
|
10420
|
-
_rasterDirty = true;
|
|
10421
10875
|
_cachedMeasureLayout = null;
|
|
10422
10876
|
_cachedMeasureWidth = undefined;
|
|
10423
10877
|
_defaultOptions = {
|
|
@@ -10444,7 +10898,7 @@ class TextTableRenderable extends Renderable2 {
|
|
|
10444
10898
|
attributes: 0
|
|
10445
10899
|
};
|
|
10446
10900
|
constructor(ctx, options = {}) {
|
|
10447
|
-
super(ctx, { ...options, flexShrink: options.flexShrink ?? 0
|
|
10901
|
+
super(ctx, { ...options, flexShrink: options.flexShrink ?? 0 });
|
|
10448
10902
|
try {
|
|
10449
10903
|
this._content = options.content ?? this._defaultOptions.content;
|
|
10450
10904
|
this._wrapMode = options.wrapMode ?? this._defaultOptions.wrapMode;
|
|
@@ -10491,7 +10945,7 @@ class TextTableRenderable extends Renderable2 {
|
|
|
10491
10945
|
for (const cell of row)
|
|
10492
10946
|
cell.textBufferView.setWrapMode(value);
|
|
10493
10947
|
}
|
|
10494
|
-
this.
|
|
10948
|
+
this.invalidateLayout();
|
|
10495
10949
|
});
|
|
10496
10950
|
}
|
|
10497
10951
|
get columnWidthMode() {
|
|
@@ -10501,7 +10955,7 @@ class TextTableRenderable extends Renderable2 {
|
|
|
10501
10955
|
if (this._columnWidthMode === value)
|
|
10502
10956
|
return;
|
|
10503
10957
|
this._columnWidthMode = value;
|
|
10504
|
-
this.
|
|
10958
|
+
this.invalidateLayout();
|
|
10505
10959
|
}
|
|
10506
10960
|
get columnFitter() {
|
|
10507
10961
|
return this._columnFitter;
|
|
@@ -10511,7 +10965,7 @@ class TextTableRenderable extends Renderable2 {
|
|
|
10511
10965
|
if (this._columnFitter === next)
|
|
10512
10966
|
return;
|
|
10513
10967
|
this._columnFitter = next;
|
|
10514
|
-
this.
|
|
10968
|
+
this.invalidateLayout();
|
|
10515
10969
|
}
|
|
10516
10970
|
get cellPadding() {
|
|
10517
10971
|
return this._cellPaddingX === this._cellPaddingY ? this._cellPaddingX : 0;
|
|
@@ -10522,7 +10976,7 @@ class TextTableRenderable extends Renderable2 {
|
|
|
10522
10976
|
return;
|
|
10523
10977
|
this._cellPaddingX = next;
|
|
10524
10978
|
this._cellPaddingY = next;
|
|
10525
|
-
this.
|
|
10979
|
+
this.invalidateLayout();
|
|
10526
10980
|
}
|
|
10527
10981
|
get cellPaddingX() {
|
|
10528
10982
|
return this._cellPaddingX;
|
|
@@ -10532,7 +10986,7 @@ class TextTableRenderable extends Renderable2 {
|
|
|
10532
10986
|
if (this._cellPaddingX === next)
|
|
10533
10987
|
return;
|
|
10534
10988
|
this._cellPaddingX = next;
|
|
10535
|
-
this.
|
|
10989
|
+
this.invalidateLayout();
|
|
10536
10990
|
}
|
|
10537
10991
|
get cellPaddingY() {
|
|
10538
10992
|
return this._cellPaddingY;
|
|
@@ -10542,7 +10996,7 @@ class TextTableRenderable extends Renderable2 {
|
|
|
10542
10996
|
if (this._cellPaddingY === next)
|
|
10543
10997
|
return;
|
|
10544
10998
|
this._cellPaddingY = next;
|
|
10545
|
-
this.
|
|
10999
|
+
this.invalidateLayout();
|
|
10546
11000
|
}
|
|
10547
11001
|
get columnGap() {
|
|
10548
11002
|
return this._columnGap;
|
|
@@ -10552,7 +11006,7 @@ class TextTableRenderable extends Renderable2 {
|
|
|
10552
11006
|
if (this._columnGap === next)
|
|
10553
11007
|
return;
|
|
10554
11008
|
this._columnGap = next;
|
|
10555
|
-
this.
|
|
11009
|
+
this.invalidateLayout();
|
|
10556
11010
|
}
|
|
10557
11011
|
get showBorders() {
|
|
10558
11012
|
return this._showBorders;
|
|
@@ -10561,7 +11015,7 @@ class TextTableRenderable extends Renderable2 {
|
|
|
10561
11015
|
if (this._showBorders === value)
|
|
10562
11016
|
return;
|
|
10563
11017
|
this._showBorders = value;
|
|
10564
|
-
this.
|
|
11018
|
+
this.requestRender();
|
|
10565
11019
|
}
|
|
10566
11020
|
get outerBorder() {
|
|
10567
11021
|
return this._outerBorder;
|
|
@@ -10574,7 +11028,7 @@ class TextTableRenderable extends Renderable2 {
|
|
|
10574
11028
|
return;
|
|
10575
11029
|
this._hasExplicitOuterBorder = value != null;
|
|
10576
11030
|
this._outerBorder = next;
|
|
10577
|
-
this.
|
|
11031
|
+
this.invalidateLayout();
|
|
10578
11032
|
}
|
|
10579
11033
|
get border() {
|
|
10580
11034
|
return this._border;
|
|
@@ -10586,7 +11040,7 @@ class TextTableRenderable extends Renderable2 {
|
|
|
10586
11040
|
if (!this._hasExplicitOuterBorder) {
|
|
10587
11041
|
this._outerBorder = value;
|
|
10588
11042
|
}
|
|
10589
|
-
this.
|
|
11043
|
+
this.invalidateLayout();
|
|
10590
11044
|
}
|
|
10591
11045
|
get borderStyle() {
|
|
10592
11046
|
return this._borderStyle;
|
|
@@ -10596,14 +11050,14 @@ class TextTableRenderable extends Renderable2 {
|
|
|
10596
11050
|
if (this._borderStyle === next)
|
|
10597
11051
|
return;
|
|
10598
11052
|
this._borderStyle = next;
|
|
10599
|
-
this.
|
|
11053
|
+
this.requestRender();
|
|
10600
11054
|
}
|
|
10601
11055
|
get borderColor() {
|
|
10602
11056
|
return RGBA2.clone(this._borderColor);
|
|
10603
11057
|
}
|
|
10604
11058
|
set borderColor(value) {
|
|
10605
11059
|
this._borderColor = RGBA2.clone(parseColor2(value ?? this._defaultOptions.borderColor));
|
|
10606
|
-
this.
|
|
11060
|
+
this.requestRender();
|
|
10607
11061
|
}
|
|
10608
11062
|
get fg() {
|
|
10609
11063
|
return this._defaultFg;
|
|
@@ -10618,7 +11072,7 @@ class TextTableRenderable extends Renderable2 {
|
|
|
10618
11072
|
cell.textBuffer.setDefaultFg(next);
|
|
10619
11073
|
}
|
|
10620
11074
|
}
|
|
10621
|
-
this.
|
|
11075
|
+
this.requestRender();
|
|
10622
11076
|
}
|
|
10623
11077
|
shouldStartSelection(x, y) {
|
|
10624
11078
|
if (!this.selectable)
|
|
@@ -10630,19 +11084,15 @@ class TextTableRenderable extends Renderable2 {
|
|
|
10630
11084
|
}
|
|
10631
11085
|
onSelectionChanged(selection) {
|
|
10632
11086
|
this.ensureLayoutReady();
|
|
10633
|
-
const previousLocalSelection = this._lastLocalSelection;
|
|
10634
11087
|
const localSelection = convertGlobalToLocalSelection2(selection, Math.trunc(this.x), Math.trunc(this.y));
|
|
10635
11088
|
this._lastLocalSelection = localSelection;
|
|
10636
|
-
const dirtyRows = this.getDirtySelectionRowRange(previousLocalSelection, localSelection);
|
|
10637
11089
|
if (!localSelection?.isActive) {
|
|
10638
11090
|
this.resetCellSelections();
|
|
10639
11091
|
this._lastSelectionMode = null;
|
|
10640
11092
|
} else {
|
|
10641
11093
|
this.applySelectionToCells(localSelection, selection?.isStart ?? false);
|
|
10642
11094
|
}
|
|
10643
|
-
|
|
10644
|
-
this.redrawSelectionRows(dirtyRows.firstRow, dirtyRows.lastRow);
|
|
10645
|
-
}
|
|
11095
|
+
this.requestRender();
|
|
10646
11096
|
return this.hasSelection();
|
|
10647
11097
|
}
|
|
10648
11098
|
hasSelection() {
|
|
@@ -10687,25 +11137,23 @@ class TextTableRenderable extends Renderable2 {
|
|
|
10687
11137
|
`);
|
|
10688
11138
|
}
|
|
10689
11139
|
onResize(width, height) {
|
|
10690
|
-
this.
|
|
11140
|
+
this.invalidateLayout(false);
|
|
10691
11141
|
super.onResize(width, height);
|
|
10692
11142
|
}
|
|
10693
11143
|
renderSelf(buffer) {
|
|
10694
11144
|
if (!this.visible || this.isDestroyed)
|
|
10695
11145
|
return;
|
|
10696
|
-
|
|
10697
|
-
|
|
10698
|
-
|
|
10699
|
-
if (
|
|
10700
|
-
|
|
10701
|
-
|
|
10702
|
-
|
|
10703
|
-
this._rasterDirty = false;
|
|
10704
|
-
return;
|
|
11146
|
+
this.ensureLayoutReady();
|
|
11147
|
+
const [x, y] = this._paintOrigin(buffer);
|
|
11148
|
+
buffer.pushScissorRect(x, y, this._paintWidth, this._paintHeight);
|
|
11149
|
+
if (buffer === this.frameBuffer)
|
|
11150
|
+
buffer.clear(this._backgroundColor);
|
|
11151
|
+
else if (this._backgroundColor.a > 0) {
|
|
11152
|
+
buffer.fillRect(x, y, this._paintWidth, this._paintHeight, this._backgroundColor);
|
|
10705
11153
|
}
|
|
10706
|
-
this.drawBorders(buffer);
|
|
10707
|
-
this.drawCells(buffer);
|
|
10708
|
-
|
|
11154
|
+
this.drawBorders(buffer, x, y);
|
|
11155
|
+
this.drawCells(buffer, x, y);
|
|
11156
|
+
buffer.popScissorRect();
|
|
10709
11157
|
}
|
|
10710
11158
|
destroySelf() {
|
|
10711
11159
|
this.destroyCells();
|
|
@@ -10791,7 +11239,7 @@ class TextTableRenderable extends Renderable2 {
|
|
|
10791
11239
|
this._rowCount = newRowCount;
|
|
10792
11240
|
this._columnCount = newColumnCount;
|
|
10793
11241
|
this.runCleanup((run) => {
|
|
10794
|
-
run(() => this.
|
|
11242
|
+
run(() => this.invalidateLayout());
|
|
10795
11243
|
for (let rowIdx = 0;rowIdx < previous.length; rowIdx++) {
|
|
10796
11244
|
for (let colIdx = 0;colIdx < previous[rowIdx].length; colIdx++) {
|
|
10797
11245
|
const cell = previous[rowIdx][colIdx];
|
|
@@ -11091,7 +11539,7 @@ class TextTableRenderable extends Renderable2 {
|
|
|
11091
11539
|
getHorizontalBorderCount(borderLayout) {
|
|
11092
11540
|
return (borderLayout.top ? 1 : 0) + (borderLayout.bottom ? 1 : 0) + (borderLayout.innerHorizontal ? Math.max(0, this._rowCount - 1) : 0);
|
|
11093
11541
|
}
|
|
11094
|
-
drawBorders(buffer) {
|
|
11542
|
+
drawBorders(buffer, x, y) {
|
|
11095
11543
|
if (!this._showBorders) {
|
|
11096
11544
|
return;
|
|
11097
11545
|
}
|
|
@@ -11099,59 +11547,31 @@ class TextTableRenderable extends Renderable2 {
|
|
|
11099
11547
|
if (this.getVerticalBorderCount(borderLayout) === 0 && this.getHorizontalBorderCount(borderLayout) === 0) {
|
|
11100
11548
|
return;
|
|
11101
11549
|
}
|
|
11550
|
+
const { columnOffsets, rowOffsets, columnOffsetsI32, rowOffsetsI32 } = this._layout;
|
|
11551
|
+
columnOffsets.forEach((offset, index) => columnOffsetsI32[index] = offset + x);
|
|
11552
|
+
rowOffsets.forEach((offset, index) => rowOffsetsI32[index] = offset + y);
|
|
11102
11553
|
buffer.drawGrid({
|
|
11103
11554
|
borderChars: BorderCharArrays2[this._borderStyle],
|
|
11104
11555
|
borderFg: this._borderColor,
|
|
11105
11556
|
borderBg: this._borderBackgroundColor,
|
|
11106
|
-
columnOffsets:
|
|
11107
|
-
rowOffsets:
|
|
11557
|
+
columnOffsets: columnOffsetsI32,
|
|
11558
|
+
rowOffsets: rowOffsetsI32,
|
|
11108
11559
|
drawInner: this._border,
|
|
11109
11560
|
drawOuter: this._outerBorder
|
|
11110
11561
|
});
|
|
11111
11562
|
}
|
|
11112
|
-
drawCells(buffer) {
|
|
11113
|
-
this.drawCellRange(buffer, 0, this._rowCount - 1);
|
|
11114
|
-
}
|
|
11115
|
-
drawCellRange(buffer, firstRow, lastRow) {
|
|
11563
|
+
drawCells(buffer, x, y) {
|
|
11116
11564
|
const colOffsets = this._layout.columnOffsets;
|
|
11117
11565
|
const rowOffsets = this._layout.rowOffsets;
|
|
11118
|
-
const
|
|
11566
|
+
const cellX = x + 1 + this._cellPaddingX;
|
|
11119
11567
|
const cellPaddingY = this._cellPaddingY;
|
|
11120
|
-
for (let rowIdx =
|
|
11121
|
-
const cellY = (rowOffsets[rowIdx] ?? 0) + 1 + cellPaddingY;
|
|
11568
|
+
for (let rowIdx = 0;rowIdx < this._rowCount; rowIdx++) {
|
|
11569
|
+
const cellY = y + (rowOffsets[rowIdx] ?? 0) + 1 + cellPaddingY;
|
|
11122
11570
|
for (let colIdx = 0;colIdx < this._columnCount; colIdx++) {
|
|
11123
11571
|
const cell = this._cells[rowIdx]?.[colIdx];
|
|
11124
11572
|
if (!cell)
|
|
11125
11573
|
continue;
|
|
11126
|
-
buffer.drawTextBuffer(cell.textBufferView, (colOffsets[colIdx] ?? 0)
|
|
11127
|
-
}
|
|
11128
|
-
}
|
|
11129
|
-
}
|
|
11130
|
-
redrawSelectionRows(firstRow, lastRow) {
|
|
11131
|
-
if (firstRow > lastRow)
|
|
11132
|
-
return;
|
|
11133
|
-
if (this._backgroundColor.a < 1) {
|
|
11134
|
-
this.invalidateRasterOnly();
|
|
11135
|
-
return;
|
|
11136
|
-
}
|
|
11137
|
-
const buffer = this.frameBuffer;
|
|
11138
|
-
if (!buffer)
|
|
11139
|
-
return;
|
|
11140
|
-
this.clearCellRange(buffer, firstRow, lastRow);
|
|
11141
|
-
this.drawCellRange(buffer, firstRow, lastRow);
|
|
11142
|
-
this.requestRender();
|
|
11143
|
-
}
|
|
11144
|
-
clearCellRange(buffer, firstRow, lastRow) {
|
|
11145
|
-
const colWidths = this._layout.columnWidths;
|
|
11146
|
-
const rowHeights = this._layout.rowHeights;
|
|
11147
|
-
const colOffsets = this._layout.columnOffsets;
|
|
11148
|
-
const rowOffsets = this._layout.rowOffsets;
|
|
11149
|
-
for (let rowIdx = firstRow;rowIdx <= lastRow; rowIdx++) {
|
|
11150
|
-
const cellY = (rowOffsets[rowIdx] ?? 0) + 1;
|
|
11151
|
-
const rowHeight = rowHeights[rowIdx] ?? 1;
|
|
11152
|
-
for (let colIdx = 0;colIdx < this._columnCount; colIdx++) {
|
|
11153
|
-
const cellX = (colOffsets[colIdx] ?? 0) + 1;
|
|
11154
|
-
buffer.fillRect(cellX, cellY, colWidths[colIdx] ?? 1, rowHeight, this._backgroundColor);
|
|
11574
|
+
buffer.drawTextBuffer(cell.textBufferView, cellX + (colOffsets[colIdx] ?? 0), cellY);
|
|
11155
11575
|
}
|
|
11156
11576
|
}
|
|
11157
11577
|
}
|
|
@@ -11307,28 +11727,6 @@ class TextTableRenderable extends Renderable2 {
|
|
|
11307
11727
|
}
|
|
11308
11728
|
return this._rowCount - 1;
|
|
11309
11729
|
}
|
|
11310
|
-
getSelectionRowRange(selection) {
|
|
11311
|
-
if (!selection?.isActive || this._rowCount === 0)
|
|
11312
|
-
return null;
|
|
11313
|
-
const minSelY = Math.min(selection.anchorY, selection.focusY);
|
|
11314
|
-
const maxSelY = Math.max(selection.anchorY, selection.focusY);
|
|
11315
|
-
return {
|
|
11316
|
-
firstRow: this.findRowForLocalY(minSelY),
|
|
11317
|
-
lastRow: this.findRowForLocalY(maxSelY)
|
|
11318
|
-
};
|
|
11319
|
-
}
|
|
11320
|
-
getDirtySelectionRowRange(previousSelection, currentSelection) {
|
|
11321
|
-
const previousRange = this.getSelectionRowRange(previousSelection);
|
|
11322
|
-
const currentRange = this.getSelectionRowRange(currentSelection);
|
|
11323
|
-
if (previousRange === null)
|
|
11324
|
-
return currentRange;
|
|
11325
|
-
if (currentRange === null)
|
|
11326
|
-
return previousRange;
|
|
11327
|
-
return {
|
|
11328
|
-
firstRow: Math.min(previousRange.firstRow, currentRange.firstRow),
|
|
11329
|
-
lastRow: Math.max(previousRange.lastRow, currentRange.lastRow)
|
|
11330
|
-
};
|
|
11331
|
-
}
|
|
11332
11730
|
resetRowSelection(rowIdx) {
|
|
11333
11731
|
const row = this._cells[rowIdx];
|
|
11334
11732
|
if (!row)
|
|
@@ -11387,9 +11785,8 @@ class TextTableRenderable extends Renderable2 {
|
|
|
11387
11785
|
}
|
|
11388
11786
|
return Math.max(0, Math.floor(value));
|
|
11389
11787
|
}
|
|
11390
|
-
|
|
11788
|
+
invalidateLayout(markYogaDirty = true) {
|
|
11391
11789
|
this._layoutDirty = true;
|
|
11392
|
-
this._rasterDirty = true;
|
|
11393
11790
|
this._cachedMeasureLayout = null;
|
|
11394
11791
|
this._cachedMeasureWidth = undefined;
|
|
11395
11792
|
if (markYogaDirty) {
|
|
@@ -11397,15 +11794,13 @@ class TextTableRenderable extends Renderable2 {
|
|
|
11397
11794
|
}
|
|
11398
11795
|
this.requestRender();
|
|
11399
11796
|
}
|
|
11400
|
-
invalidateRasterOnly() {
|
|
11401
|
-
this._rasterDirty = true;
|
|
11402
|
-
this.requestRender();
|
|
11403
|
-
}
|
|
11404
11797
|
}
|
|
11405
11798
|
|
|
11406
11799
|
// src/renderables/markdown-parser.ts
|
|
11407
11800
|
function parseMarkdownIncremental(newContent, prevState, trailingUnstable = 2) {
|
|
11408
|
-
if (
|
|
11801
|
+
if (trailingUnstable === 0 && prevState?.content === newContent && prevState.stableTokenCount === prevState.tokens.length)
|
|
11802
|
+
return prevState;
|
|
11803
|
+
if (!prevState || prevState.tokens.length === 0 || trailingUnstable === 0) {
|
|
11409
11804
|
try {
|
|
11410
11805
|
const tokens = x.lex(newContent, { gfm: true });
|
|
11411
11806
|
return {
|
|
@@ -11435,19 +11830,12 @@ function parseMarkdownIncremental(newContent, prevState, trailingUnstable = 2) {
|
|
|
11435
11830
|
}
|
|
11436
11831
|
const stableTokens = prevState.tokens.slice(0, reuseCount);
|
|
11437
11832
|
const remainingContent = newContent.slice(offset);
|
|
11438
|
-
if (!remainingContent) {
|
|
11439
|
-
return {
|
|
11440
|
-
content: newContent,
|
|
11441
|
-
tokens: stableTokens,
|
|
11442
|
-
stableTokenCount: stableTokens.length
|
|
11443
|
-
};
|
|
11444
|
-
}
|
|
11445
11833
|
try {
|
|
11446
11834
|
const newTokens = x.lex(remainingContent, { gfm: true });
|
|
11447
11835
|
return {
|
|
11448
11836
|
content: newContent,
|
|
11449
11837
|
tokens: [...stableTokens, ...newTokens],
|
|
11450
|
-
stableTokenCount:
|
|
11838
|
+
stableTokenCount: stableTokens.length
|
|
11451
11839
|
};
|
|
11452
11840
|
} catch {
|
|
11453
11841
|
try {
|
|
@@ -11697,6 +12085,7 @@ class MarkdownRenderable extends Renderable2 {
|
|
|
11697
12085
|
if (this._streaming !== value) {
|
|
11698
12086
|
this.assertMutable();
|
|
11699
12087
|
this._streaming = value;
|
|
12088
|
+
this._parseState = parseMarkdownIncremental(this._content, this._parseState, value ? 2 : 0);
|
|
11700
12089
|
this.updateBlocks(true);
|
|
11701
12090
|
}
|
|
11702
12091
|
}
|
|
@@ -12229,13 +12618,16 @@ class MarkdownRenderable extends Renderable2 {
|
|
|
12229
12618
|
return this.createTableBlock(token, id).renderable;
|
|
12230
12619
|
return token.raw ? this.createMarkdownCodeRenderable(token.raw, id, 0, this._linkifyMarkdownChunks, undefined, this.createInitialStyledText(token)) : null;
|
|
12231
12620
|
}
|
|
12621
|
+
getHorizontalRuleColor() {
|
|
12622
|
+
return this.getStyle("conceal")?.fg ?? this._fg ?? "#888888";
|
|
12623
|
+
}
|
|
12232
12624
|
createHorizontalRuleRenderable(id, marginBottom = 0) {
|
|
12233
12625
|
return new BoxRenderable2(this.ctx, {
|
|
12234
12626
|
id,
|
|
12235
12627
|
width: "100%",
|
|
12236
12628
|
height: 1,
|
|
12237
12629
|
border: ["top"],
|
|
12238
|
-
borderColor: this.
|
|
12630
|
+
borderColor: this.getHorizontalRuleColor(),
|
|
12239
12631
|
flexShrink: 0,
|
|
12240
12632
|
marginBottom
|
|
12241
12633
|
});
|
|
@@ -12809,6 +13201,8 @@ class MarkdownRenderable extends Renderable2 {
|
|
|
12809
13201
|
return;
|
|
12810
13202
|
}
|
|
12811
13203
|
if (token.type === "hr") {
|
|
13204
|
+
if (state.renderable instanceof BoxRenderable2)
|
|
13205
|
+
state.renderable.borderColor = this.getHorizontalRuleColor();
|
|
12812
13206
|
state.renderable.marginBottom = marginBottom;
|
|
12813
13207
|
return;
|
|
12814
13208
|
}
|
|
@@ -12844,12 +13238,13 @@ class MarkdownRenderable extends Renderable2 {
|
|
|
12844
13238
|
state.tableContentCache = cache;
|
|
12845
13239
|
return;
|
|
12846
13240
|
}
|
|
13241
|
+
const raw = this._internalBlockMode === "top-level" ? this.getTopLevelBlockRaw(token) ?? token.raw : token.raw;
|
|
12847
13242
|
if (state.renderable instanceof CodeRenderable2) {
|
|
12848
|
-
this.applyMarkdownCodeRenderable(state.renderable,
|
|
13243
|
+
this.applyMarkdownCodeRenderable(state.renderable, raw, marginBottom, undefined, this.createInitialStyledText(token));
|
|
12849
13244
|
return;
|
|
12850
13245
|
}
|
|
12851
13246
|
state.renderable.destroyRecursively();
|
|
12852
|
-
const markdownRenderable = this.createMarkdownCodeRenderable(
|
|
13247
|
+
const markdownRenderable = this.createMarkdownCodeRenderable(raw, `${this.id}-block-${index}`, marginBottom, this._linkifyMarkdownChunks, undefined, this.createInitialStyledText(token));
|
|
12853
13248
|
this.add(markdownRenderable, index);
|
|
12854
13249
|
state.renderable = markdownRenderable;
|
|
12855
13250
|
}
|
|
@@ -12876,7 +13271,7 @@ class MarkdownRenderable extends Renderable2 {
|
|
|
12876
13271
|
blockIndex++;
|
|
12877
13272
|
continue;
|
|
12878
13273
|
}
|
|
12879
|
-
if (existing && existing.canUpdateInPlace && existing.token.type === block.token.type &&
|
|
13274
|
+
if (existing && existing.canUpdateInPlace && existing.token.type === block.token.type && (block.token.type !== "table" || block.token.rows.length > 0 === existing.renderable instanceof TextTableRenderable)) {
|
|
12880
13275
|
if (this._renderNode) {
|
|
12881
13276
|
const custom = this.createTopLevelCustomRenderable(block, blockIndex);
|
|
12882
13277
|
if (custom.renderable && !custom.canUpdateInPlace) {
|
|
@@ -12930,19 +13325,6 @@ class MarkdownRenderable extends Renderable2 {
|
|
|
12930
13325
|
removed.renderable.destroyRecursively();
|
|
12931
13326
|
}
|
|
12932
13327
|
}
|
|
12933
|
-
canUpdateBlockRenderable(renderable, token) {
|
|
12934
|
-
if (token.type === "code")
|
|
12935
|
-
return renderable instanceof CodeRenderable2;
|
|
12936
|
-
if (token.type === "table")
|
|
12937
|
-
return renderable instanceof TextTableRenderable;
|
|
12938
|
-
if (token.type === "blockquote")
|
|
12939
|
-
return renderable instanceof BoxRenderable2;
|
|
12940
|
-
if (token.type === "list")
|
|
12941
|
-
return renderable instanceof BoxRenderable2;
|
|
12942
|
-
if (token.type === "hr")
|
|
12943
|
-
return renderable instanceof BoxRenderable2;
|
|
12944
|
-
return renderable instanceof CodeRenderable2;
|
|
12945
|
-
}
|
|
12946
13328
|
updateBlocks(forceTableRefresh = false) {
|
|
12947
13329
|
if (this.isDestroyed)
|
|
12948
13330
|
return;
|
|
@@ -12952,8 +13334,9 @@ class MarkdownRenderable extends Renderable2 {
|
|
|
12952
13334
|
this._stableBlockCount = 0;
|
|
12953
13335
|
return;
|
|
12954
13336
|
}
|
|
12955
|
-
|
|
12956
|
-
|
|
13337
|
+
if (this._parseState?.content !== this._content) {
|
|
13338
|
+
this._parseState = parseMarkdownIncremental(this._content, this._parseState, this._streaming ? 2 : 0);
|
|
13339
|
+
}
|
|
12957
13340
|
const tokens = this._parseState.tokens;
|
|
12958
13341
|
if (tokens.length === 0 && this._content.length > 0) {
|
|
12959
13342
|
this.clearBlockStates();
|
|
@@ -12983,22 +13366,10 @@ class MarkdownRenderable extends Renderable2 {
|
|
|
12983
13366
|
const token = blockTokens[i];
|
|
12984
13367
|
const nextToken = blockTokens[i + 1];
|
|
12985
13368
|
const existing = this._blockStates[blockIndex];
|
|
12986
|
-
|
|
12987
|
-
if (existing && existing.token === token) {
|
|
12988
|
-
if (shouldForceRefresh) {
|
|
12989
|
-
this.updateBlockRenderable(existing, token, blockIndex, nextToken);
|
|
12990
|
-
existing.tokenRaw = token.raw;
|
|
12991
|
-
} else {
|
|
12992
|
-
this.applyInterBlockMargin(existing, token, nextToken);
|
|
12993
|
-
}
|
|
12994
|
-
blockIndex++;
|
|
12995
|
-
continue;
|
|
12996
|
-
}
|
|
12997
|
-
if (existing && existing.tokenRaw === token.raw && existing.token.type === token.type) {
|
|
13369
|
+
if (existing && existing.tokenRaw === token.raw && existing.token.type === token.type && (existing.canUpdateInPlace || !forceTableRefresh)) {
|
|
12998
13370
|
existing.token = token;
|
|
12999
|
-
if (
|
|
13000
|
-
this.updateBlockRenderable(existing, token, blockIndex, nextToken);
|
|
13001
|
-
existing.tokenRaw = token.raw;
|
|
13371
|
+
if (forceTableRefresh) {
|
|
13372
|
+
this.updateBlockRenderable(existing, token, blockIndex, nextToken, true);
|
|
13002
13373
|
} else {
|
|
13003
13374
|
this.applyInterBlockMargin(existing, token, nextToken);
|
|
13004
13375
|
}
|
|
@@ -13081,69 +13452,6 @@ class MarkdownRenderable extends Renderable2 {
|
|
|
13081
13452
|
this._blockStates = [];
|
|
13082
13453
|
this._stableBlockCount = 0;
|
|
13083
13454
|
}
|
|
13084
|
-
rerenderBlocks() {
|
|
13085
|
-
if (this._internalBlockMode === "top-level") {
|
|
13086
|
-
this.updateBlocks(true);
|
|
13087
|
-
return;
|
|
13088
|
-
}
|
|
13089
|
-
for (let i = 0;i < this._blockStates.length; i++) {
|
|
13090
|
-
const state = this._blockStates[i];
|
|
13091
|
-
const marginBottom = this.getInterBlockMargin(state.token, this._blockStates[i + 1]?.token);
|
|
13092
|
-
if (state.token.type === "code") {
|
|
13093
|
-
this.applyCodeBlockRenderable(state.renderable, state.token, marginBottom);
|
|
13094
|
-
continue;
|
|
13095
|
-
}
|
|
13096
|
-
if (state.token.type === "blockquote") {
|
|
13097
|
-
this.applyBlockquoteRenderable(state.renderable, state.token, marginBottom);
|
|
13098
|
-
continue;
|
|
13099
|
-
}
|
|
13100
|
-
if (state.token.type === "list") {
|
|
13101
|
-
this.updateBlockRenderable(state, state.token, i, this._blockStates[i + 1]?.token, true);
|
|
13102
|
-
continue;
|
|
13103
|
-
}
|
|
13104
|
-
if (state.token.type === "hr") {
|
|
13105
|
-
state.renderable.marginBottom = marginBottom;
|
|
13106
|
-
continue;
|
|
13107
|
-
}
|
|
13108
|
-
if (state.token.type === "table") {
|
|
13109
|
-
const tableToken = state.token;
|
|
13110
|
-
const { cache } = this.buildTableContentCache(tableToken, state.tableContentCache, true);
|
|
13111
|
-
if (!cache) {
|
|
13112
|
-
if (state.renderable instanceof CodeRenderable2) {
|
|
13113
|
-
this.applyMarkdownCodeRenderable(state.renderable, tableToken.raw, marginBottom);
|
|
13114
|
-
} else {
|
|
13115
|
-
state.renderable.destroyRecursively();
|
|
13116
|
-
const fallbackRenderable = this.createMarkdownCodeRenderable(tableToken.raw, `${this.id}-block-${i}`, marginBottom);
|
|
13117
|
-
this.add(fallbackRenderable, i);
|
|
13118
|
-
state.renderable = fallbackRenderable;
|
|
13119
|
-
}
|
|
13120
|
-
state.tableContentCache = undefined;
|
|
13121
|
-
continue;
|
|
13122
|
-
}
|
|
13123
|
-
if (state.renderable instanceof TextTableRenderable) {
|
|
13124
|
-
state.renderable.content = cache.content;
|
|
13125
|
-
this.applyTableRenderableOptions(state.renderable, this.resolveTableRenderableOptions());
|
|
13126
|
-
state.renderable.marginBottom = marginBottom;
|
|
13127
|
-
state.tableContentCache = cache;
|
|
13128
|
-
continue;
|
|
13129
|
-
}
|
|
13130
|
-
state.renderable.destroyRecursively();
|
|
13131
|
-
const tableRenderable = this.createTextTableRenderable(cache.content, `${this.id}-block-${i}`, marginBottom);
|
|
13132
|
-
this.add(tableRenderable, i);
|
|
13133
|
-
state.renderable = tableRenderable;
|
|
13134
|
-
state.tableContentCache = cache;
|
|
13135
|
-
continue;
|
|
13136
|
-
}
|
|
13137
|
-
if (state.renderable instanceof CodeRenderable2) {
|
|
13138
|
-
this.applyMarkdownCodeRenderable(state.renderable, this.getTopLevelBlockRaw(state.token) ?? state.token.raw, marginBottom, undefined, this.createInitialStyledText(state.token));
|
|
13139
|
-
continue;
|
|
13140
|
-
}
|
|
13141
|
-
state.renderable.destroyRecursively();
|
|
13142
|
-
const markdownRenderable = this.createMarkdownCodeRenderable(this.getTopLevelBlockRaw(state.token) ?? state.token.raw, `${this.id}-block-${i}`, marginBottom, this._linkifyMarkdownChunks, undefined, this.createInitialStyledText(state.token));
|
|
13143
|
-
this.add(markdownRenderable, i);
|
|
13144
|
-
state.renderable = markdownRenderable;
|
|
13145
|
-
}
|
|
13146
|
-
}
|
|
13147
13455
|
clearCache() {
|
|
13148
13456
|
this._parseState = null;
|
|
13149
13457
|
this.clearBlockStates();
|
|
@@ -13153,7 +13461,7 @@ class MarkdownRenderable extends Renderable2 {
|
|
|
13153
13461
|
refreshStyles() {
|
|
13154
13462
|
this._styleDirty = false;
|
|
13155
13463
|
this._ctx.nativeScene.lifecyclePasses.refresh(this);
|
|
13156
|
-
this.
|
|
13464
|
+
this.updateBlocks(true);
|
|
13157
13465
|
this.requestRender();
|
|
13158
13466
|
}
|
|
13159
13467
|
markStyleDirty() {
|
|
@@ -13165,7 +13473,7 @@ class MarkdownRenderable extends Renderable2 {
|
|
|
13165
13473
|
return;
|
|
13166
13474
|
this._styleDirty = false;
|
|
13167
13475
|
this._ctx.nativeScene.lifecyclePasses.refresh(this);
|
|
13168
|
-
this.
|
|
13476
|
+
this.updateBlocks(true);
|
|
13169
13477
|
}
|
|
13170
13478
|
_needsLifecyclePass() {
|
|
13171
13479
|
if (this.onLifecyclePass !== this.applyStyleChanges)
|
|
@@ -14320,7 +14628,7 @@ class ScrollBoxRenderable extends BoxRenderable2 {
|
|
|
14320
14628
|
horizontalScrollBar;
|
|
14321
14629
|
verticalScrollBar;
|
|
14322
14630
|
static defaultFocusable = true;
|
|
14323
|
-
selectionListener;
|
|
14631
|
+
selectionListener = () => this.stopAutoScroll();
|
|
14324
14632
|
autoScrollMouseX = 0;
|
|
14325
14633
|
autoScrollMouseY = 0;
|
|
14326
14634
|
autoScrollThresholdVertical = 3;
|
|
@@ -14455,15 +14763,6 @@ class ScrollBoxRenderable extends BoxRenderable2 {
|
|
|
14455
14763
|
this._applyScrollArrows(1);
|
|
14456
14764
|
this.content._assign({ ...forwardedContentPadding, ...contentOptions }, ScrollBoxContent.keys);
|
|
14457
14765
|
this._refreshScrollHook();
|
|
14458
|
-
this.selectionListener = () => {
|
|
14459
|
-
if (this.isDestroyed)
|
|
14460
|
-
return;
|
|
14461
|
-
const selection = this._ctx.getSelection();
|
|
14462
|
-
if (!selection || !selection.isDragging) {
|
|
14463
|
-
this.stopAutoScroll();
|
|
14464
|
-
}
|
|
14465
|
-
};
|
|
14466
|
-
this._ctx.on("selection", this.selectionListener);
|
|
14467
14766
|
this.setNativeScenePaint();
|
|
14468
14767
|
} catch (error) {
|
|
14469
14768
|
this.abortConstruction(error, (run) => run(() => this.destroySelf()));
|
|
@@ -14767,12 +15066,15 @@ class ScrollBoxRenderable extends BoxRenderable2 {
|
|
|
14767
15066
|
this.scrollAccumulatorY = 0;
|
|
14768
15067
|
}
|
|
14769
15068
|
startAutoScroll(mouseX, mouseY) {
|
|
15069
|
+
if (this.isDestroyed)
|
|
15070
|
+
return;
|
|
14770
15071
|
this.stopAutoScroll();
|
|
14771
15072
|
this.autoScrollMouseX = mouseX;
|
|
14772
15073
|
this.autoScrollMouseY = mouseY;
|
|
14773
15074
|
this.cachedAutoScrollSpeed = this.getAutoScrollSpeed(mouseX, mouseY);
|
|
14774
15075
|
this.isAutoScrolling = true;
|
|
14775
15076
|
this.live = true;
|
|
15077
|
+
this._ctx.on("selection", this.selectionListener);
|
|
14776
15078
|
this.refreshNativeSceneHooks();
|
|
14777
15079
|
}
|
|
14778
15080
|
updateAutoScroll(mouseX, mouseY) {
|
|
@@ -14793,6 +15095,7 @@ class ScrollBoxRenderable extends BoxRenderable2 {
|
|
|
14793
15095
|
this.autoScrollAccumulatorX = 0;
|
|
14794
15096
|
this.autoScrollAccumulatorY = 0;
|
|
14795
15097
|
if (wasAutoScrolling) {
|
|
15098
|
+
this._ctx.off("selection", this.selectionListener);
|
|
14796
15099
|
this.live = false;
|
|
14797
15100
|
this.refreshNativeSceneHooks();
|
|
14798
15101
|
}
|
|
@@ -14916,13 +15219,10 @@ class ScrollBoxRenderable extends BoxRenderable2 {
|
|
|
14916
15219
|
destroySelf() {
|
|
14917
15220
|
if (!this.isFreed())
|
|
14918
15221
|
this._scrollState();
|
|
14919
|
-
const selectionListener = this.selectionListener;
|
|
14920
|
-
this.selectionListener = undefined;
|
|
14921
15222
|
this.layoutCallbacks = [];
|
|
14922
15223
|
this.endBarPress();
|
|
14923
15224
|
this.runCleanup((run) => {
|
|
14924
|
-
|
|
14925
|
-
run(() => this._ctx.off("selection", selectionListener));
|
|
15225
|
+
run(() => this._ctx.off("selection", this.selectionListener));
|
|
14926
15226
|
run(() => super.destroySelf());
|
|
14927
15227
|
});
|
|
14928
15228
|
}
|
|
@@ -14936,6 +15236,8 @@ for (const key of SCROLLBOX_PADDING_KEYS) {
|
|
|
14936
15236
|
});
|
|
14937
15237
|
}
|
|
14938
15238
|
// src/renderables/Select.ts
|
|
15239
|
+
var transparent2 = RGBA2.fromValues(0, 0, 0, 0);
|
|
15240
|
+
var indicatorColor = parseColor2("#666666");
|
|
14939
15241
|
var defaultSelectKeybindings = [
|
|
14940
15242
|
{ name: "up", action: "move-up" },
|
|
14941
15243
|
{ name: "k", action: "move-up" },
|
|
@@ -14996,7 +15298,7 @@ class SelectRenderable extends Renderable2 {
|
|
|
14996
15298
|
fastScrollStep: 5
|
|
14997
15299
|
};
|
|
14998
15300
|
constructor(ctx, options) {
|
|
14999
|
-
super(ctx,
|
|
15301
|
+
super(ctx, options);
|
|
15000
15302
|
try {
|
|
15001
15303
|
this._options = options.options || [];
|
|
15002
15304
|
const requestedIndex = options.selectedIndex ?? this._defaultOptions.selectedIndex;
|
|
@@ -15029,74 +15331,65 @@ class SelectRenderable extends Renderable2 {
|
|
|
15029
15331
|
}
|
|
15030
15332
|
}
|
|
15031
15333
|
renderSelf(buffer, deltaTime) {
|
|
15032
|
-
|
|
15033
|
-
|
|
15034
|
-
|
|
15035
|
-
this.refreshFrameBuffer();
|
|
15036
|
-
}
|
|
15037
|
-
}
|
|
15038
|
-
refreshFrameBuffer() {
|
|
15039
|
-
if (!this.frameBuffer)
|
|
15040
|
-
return;
|
|
15334
|
+
const [x, y] = this._paintOrigin(buffer);
|
|
15335
|
+
const width = this._paintWidth;
|
|
15336
|
+
const height = this._paintHeight;
|
|
15041
15337
|
const bgColor = this._focused ? this._focusedBackgroundColor : this._backgroundColor;
|
|
15042
|
-
this.
|
|
15043
|
-
|
|
15044
|
-
|
|
15045
|
-
const
|
|
15046
|
-
const
|
|
15047
|
-
const
|
|
15048
|
-
const
|
|
15338
|
+
const selectedY = (this._selectedIndex - this.scrollOffset) * this.linesPerItem;
|
|
15339
|
+
const selectedHeight = this.linesPerItem - this._itemSpacing;
|
|
15340
|
+
const hole = this._options.length > 0 && selectedY + this.linesPerItem <= height && this._selectedBackgroundColor.a === 1;
|
|
15341
|
+
const top = hole ? selectedY : height;
|
|
15342
|
+
const bottom = hole ? selectedY + selectedHeight : height;
|
|
15343
|
+
const scrolls = this._showScrollIndicator && this._options.length > this.maxVisibleItems;
|
|
15344
|
+
const scrollPercent = this.scrollOffset / (this._options.length - this.maxVisibleItems);
|
|
15345
|
+
const indicatorY = scrolls ? y + 1 + Math.floor(scrollPercent * Math.max(1, height - 2)) : -1;
|
|
15346
|
+
const draw = (text, textX, textY, color) => {
|
|
15347
|
+
const end = textY === indicatorY ? x + width - 1 : x + width;
|
|
15348
|
+
buffer.drawTextFit(text, textX, textY, end - textX, color, transparent2);
|
|
15349
|
+
};
|
|
15350
|
+
buffer.pushScissorRect(x, y, width, height);
|
|
15351
|
+
if (buffer === this.frameBuffer)
|
|
15352
|
+
buffer.clear(bgColor);
|
|
15353
|
+
else {
|
|
15354
|
+
buffer.fillRect(x, y, width, top, bgColor);
|
|
15355
|
+
buffer.fillRect(x, y + bottom, width, height - bottom, bgColor);
|
|
15356
|
+
}
|
|
15049
15357
|
const visibleOptions = this._options.slice(this.scrollOffset, this.scrollOffset + this.maxVisibleItems);
|
|
15050
15358
|
for (let i = 0;i < visibleOptions.length; i++) {
|
|
15051
|
-
const actualIndex = this.scrollOffset + i;
|
|
15052
15359
|
const option = visibleOptions[i];
|
|
15053
|
-
const isSelected =
|
|
15054
|
-
const itemY =
|
|
15055
|
-
if (itemY + this.linesPerItem - 1 >=
|
|
15360
|
+
const isSelected = this.scrollOffset + i === this._selectedIndex;
|
|
15361
|
+
const itemY = y + i * this.linesPerItem;
|
|
15362
|
+
if (itemY + this.linesPerItem - 1 >= y + height)
|
|
15056
15363
|
break;
|
|
15057
15364
|
if (isSelected) {
|
|
15058
|
-
|
|
15059
|
-
this.frameBuffer.fillRect(contentX, itemY, contentWidth, contentHeight, this._selectedBackgroundColor);
|
|
15365
|
+
buffer.fillRect(x, itemY, width, selectedHeight, this._selectedBackgroundColor);
|
|
15060
15366
|
}
|
|
15061
15367
|
const indicator = this._showSelectionIndicator ? isSelected ? "\u25B6 " : " " : "";
|
|
15062
|
-
const indicatorWidth = this._showSelectionIndicator ? 2 : 0;
|
|
15063
|
-
const nameContent = `${indicator}${option.name}`;
|
|
15064
15368
|
const baseTextColor = this._focused ? this._focusedTextColor : this._textColor;
|
|
15065
15369
|
const nameColor = isSelected ? this._selectedTextColor : baseTextColor;
|
|
15066
|
-
const textX =
|
|
15370
|
+
const textX = x + 1 + (this._showSelectionIndicator ? 2 : 0);
|
|
15067
15371
|
if (this._font) {
|
|
15068
|
-
if (indicator)
|
|
15069
|
-
|
|
15070
|
-
|
|
15071
|
-
renderFontToFrameBuffer2(this.frameBuffer, {
|
|
15372
|
+
if (indicator)
|
|
15373
|
+
draw(indicator, x + 1, itemY, nameColor);
|
|
15374
|
+
renderFontToFrameBuffer2(buffer, {
|
|
15072
15375
|
text: option.name,
|
|
15073
15376
|
x: textX,
|
|
15074
15377
|
y: itemY,
|
|
15075
15378
|
color: nameColor,
|
|
15076
|
-
backgroundColor:
|
|
15379
|
+
backgroundColor: transparent2,
|
|
15077
15380
|
font: this._font
|
|
15078
15381
|
});
|
|
15079
15382
|
} else {
|
|
15080
|
-
|
|
15383
|
+
draw(`${indicator}${option.name}`, x + 1, itemY, nameColor);
|
|
15081
15384
|
}
|
|
15082
|
-
if (this._showDescription && itemY + this.fontHeight <
|
|
15385
|
+
if (this._showDescription && itemY + this.fontHeight < y + height) {
|
|
15083
15386
|
const descColor = isSelected ? this._selectedDescriptionColor : this._descriptionColor;
|
|
15084
|
-
|
|
15387
|
+
draw(option.description, textX, itemY + this.fontHeight, descColor);
|
|
15085
15388
|
}
|
|
15086
15389
|
}
|
|
15087
|
-
if (
|
|
15088
|
-
|
|
15089
|
-
|
|
15090
|
-
}
|
|
15091
|
-
renderScrollIndicatorToFrameBuffer(contentX, contentY, contentWidth, contentHeight) {
|
|
15092
|
-
if (!this.frameBuffer)
|
|
15093
|
-
return;
|
|
15094
|
-
const maxScrollOffset = this._options.length - this.maxVisibleItems;
|
|
15095
|
-
const scrollPercent = this.scrollOffset / maxScrollOffset;
|
|
15096
|
-
const indicatorHeight = Math.max(1, contentHeight - 2);
|
|
15097
|
-
const indicatorY = contentY + 1 + Math.floor(scrollPercent * indicatorHeight);
|
|
15098
|
-
const indicatorX = contentX + contentWidth - 1;
|
|
15099
|
-
this.frameBuffer.drawText("\u2588", indicatorX, indicatorY, parseColor2("#666666"));
|
|
15390
|
+
if (scrolls)
|
|
15391
|
+
buffer.drawText("\u2588", x + width - 1, indicatorY, indicatorColor, transparent2);
|
|
15392
|
+
buffer.popScissorRect();
|
|
15100
15393
|
}
|
|
15101
15394
|
get options() {
|
|
15102
15395
|
return this._options;
|
|
@@ -15297,6 +15590,8 @@ class SelectRenderable extends Renderable2 {
|
|
|
15297
15590
|
}
|
|
15298
15591
|
}
|
|
15299
15592
|
// src/renderables/TabSelect.ts
|
|
15593
|
+
var transparent3 = RGBA2.fromValues(0, 0, 0, 0);
|
|
15594
|
+
var arrowColor = parseColor2("#AAAAAA");
|
|
15300
15595
|
var defaultTabSelectKeybindings = [
|
|
15301
15596
|
{ name: "left", action: "move-left" },
|
|
15302
15597
|
{ name: "[", action: "move-left" },
|
|
@@ -15353,7 +15648,7 @@ class TabSelectRenderable extends Renderable2 {
|
|
|
15353
15648
|
_keyBindings;
|
|
15354
15649
|
constructor(ctx, options) {
|
|
15355
15650
|
const calculatedHeight = calculateDynamicHeight(options.showUnderline ?? true, options.showDescription ?? true);
|
|
15356
|
-
super(ctx, { ...options, height: calculatedHeight
|
|
15651
|
+
super(ctx, { ...options, height: calculatedHeight });
|
|
15357
15652
|
try {
|
|
15358
15653
|
this._backgroundColor = RGBA2.clone(parseColor2(options.backgroundColor || defaultColors2.backgroundColor));
|
|
15359
15654
|
this._hasBackgroundColor = !!options.backgroundColor;
|
|
@@ -15385,71 +15680,52 @@ class TabSelectRenderable extends Renderable2 {
|
|
|
15385
15680
|
return kind === "height" ? this.calculateDynamicHeight() : super.defaultDimension(kind);
|
|
15386
15681
|
}
|
|
15387
15682
|
renderSelf(buffer, deltaTime) {
|
|
15388
|
-
|
|
15389
|
-
|
|
15390
|
-
|
|
15391
|
-
this.refreshFrameBuffer();
|
|
15392
|
-
}
|
|
15393
|
-
}
|
|
15394
|
-
refreshFrameBuffer() {
|
|
15395
|
-
if (!this.frameBuffer)
|
|
15396
|
-
return;
|
|
15683
|
+
const [x, y] = this._paintOrigin(buffer);
|
|
15684
|
+
const width = this._paintWidth;
|
|
15685
|
+
const height = this._paintHeight;
|
|
15397
15686
|
const bgColor = this._focused ? this._focusedBackgroundColor : this._backgroundColor;
|
|
15398
|
-
this.
|
|
15399
|
-
|
|
15400
|
-
|
|
15401
|
-
const
|
|
15402
|
-
const
|
|
15403
|
-
|
|
15404
|
-
|
|
15687
|
+
const selectedX = (this.selectedIndex - this.scrollOffset) * this._tabWidth;
|
|
15688
|
+
const selectedWidth = Math.min(this._tabWidth, width - selectedX);
|
|
15689
|
+
const selectedRows = this._showUnderline && height >= 2 ? 2 : 1;
|
|
15690
|
+
const hole = this._options.length > 0 && selectedX < width && this._selectedBackgroundColor.a === 1;
|
|
15691
|
+
const rows = hole ? selectedRows : 0;
|
|
15692
|
+
if (buffer === this.frameBuffer)
|
|
15693
|
+
buffer.clear(bgColor);
|
|
15694
|
+
else {
|
|
15695
|
+
buffer.fillRect(x, y, selectedX, rows, bgColor);
|
|
15696
|
+
buffer.fillRect(x + selectedX + selectedWidth, y, width - selectedX - selectedWidth, rows, bgColor);
|
|
15697
|
+
buffer.fillRect(x, y + rows, width, height - rows, bgColor);
|
|
15698
|
+
}
|
|
15405
15699
|
const visibleOptions = this._options.slice(this.scrollOffset, this.scrollOffset + this.maxVisibleTabs);
|
|
15406
15700
|
for (let i = 0;i < visibleOptions.length; i++) {
|
|
15407
|
-
const actualIndex = this.scrollOffset + i;
|
|
15408
15701
|
const option = visibleOptions[i];
|
|
15409
|
-
const isSelected =
|
|
15410
|
-
const tabX =
|
|
15411
|
-
if (tabX >=
|
|
15702
|
+
const isSelected = this.scrollOffset + i === this.selectedIndex;
|
|
15703
|
+
const tabX = x + i * this._tabWidth;
|
|
15704
|
+
if (tabX >= x + width)
|
|
15412
15705
|
break;
|
|
15413
|
-
const actualTabWidth = Math.min(this._tabWidth,
|
|
15414
|
-
if (isSelected) {
|
|
15415
|
-
this.frameBuffer.fillRect(tabX, contentY, actualTabWidth, 1, this._selectedBackgroundColor);
|
|
15416
|
-
}
|
|
15706
|
+
const actualTabWidth = Math.min(this._tabWidth, width - i * this._tabWidth);
|
|
15417
15707
|
const baseTextColor = this._focused ? this._focusedTextColor : this._textColor;
|
|
15418
15708
|
const nameColor = isSelected ? this._selectedTextColor : baseTextColor;
|
|
15419
|
-
|
|
15420
|
-
|
|
15421
|
-
if (isSelected && this._showUnderline && contentHeight >= 2) {
|
|
15422
|
-
this.frameBuffer.drawText("\u25AC".repeat(actualTabWidth), tabX, contentY + 1, nameColor, this._selectedBackgroundColor);
|
|
15709
|
+
if (isSelected) {
|
|
15710
|
+
buffer.fillRect(tabX, y, actualTabWidth, selectedRows, this._selectedBackgroundColor);
|
|
15423
15711
|
}
|
|
15424
|
-
|
|
15425
|
-
|
|
15426
|
-
|
|
15427
|
-
if (selectedOption) {
|
|
15428
|
-
const descriptionY = contentY + (this._showUnderline ? 2 : 1);
|
|
15429
|
-
const descColor = this._selectedDescriptionColor;
|
|
15430
|
-
const descContent = this.truncateText(selectedOption.description, contentWidth - 2);
|
|
15431
|
-
this.frameBuffer.drawText(descContent, contentX + 1, descriptionY, descColor);
|
|
15712
|
+
buffer.drawTextFit(option.name, tabX + 1, y, actualTabWidth - 2, nameColor, transparent3, true);
|
|
15713
|
+
if (isSelected && selectedRows === 2) {
|
|
15714
|
+
buffer.drawText("\u25AC".repeat(actualTabWidth), tabX, y + 1, nameColor, transparent3);
|
|
15432
15715
|
}
|
|
15433
15716
|
}
|
|
15434
|
-
|
|
15435
|
-
|
|
15436
|
-
|
|
15437
|
-
|
|
15438
|
-
|
|
15439
|
-
if (text.length <= maxWidth)
|
|
15440
|
-
return text;
|
|
15441
|
-
return text.substring(0, Math.max(0, maxWidth - 1)) + "\u2026";
|
|
15442
|
-
}
|
|
15443
|
-
renderScrollArrowsToFrameBuffer(contentX, contentY, contentWidth, contentHeight) {
|
|
15444
|
-
if (!this.frameBuffer)
|
|
15445
|
-
return;
|
|
15446
|
-
const hasMoreLeft = this.scrollOffset > 0;
|
|
15447
|
-
const hasMoreRight = this.scrollOffset + this.maxVisibleTabs < this._options.length;
|
|
15448
|
-
if (hasMoreLeft) {
|
|
15449
|
-
this.frameBuffer.drawText("\u2039", contentX, contentY, parseColor2("#AAAAAA"));
|
|
15717
|
+
const selectedOption = this.getSelectedOption();
|
|
15718
|
+
if (selectedOption && this._showDescription && height >= (this._showUnderline ? 3 : 2)) {
|
|
15719
|
+
const descriptionY = y + (this._showUnderline ? 2 : 1);
|
|
15720
|
+
const description = selectedOption.description;
|
|
15721
|
+
buffer.drawTextFit(description, x + 1, descriptionY, width - 2, this._selectedDescriptionColor, transparent3, true);
|
|
15450
15722
|
}
|
|
15451
|
-
if (
|
|
15452
|
-
this.
|
|
15723
|
+
if (this._showScrollArrows && this._options.length > this.maxVisibleTabs) {
|
|
15724
|
+
if (this.scrollOffset > 0)
|
|
15725
|
+
buffer.drawText("\u2039", x, y, arrowColor, transparent3);
|
|
15726
|
+
if (this.scrollOffset + this.maxVisibleTabs < this._options.length) {
|
|
15727
|
+
buffer.drawText("\u203A", x + width - 1, y, arrowColor, transparent3);
|
|
15728
|
+
}
|
|
15453
15729
|
}
|
|
15454
15730
|
}
|
|
15455
15731
|
setOptions(options) {
|
|
@@ -15634,28 +15910,19 @@ class TabSelectRenderable extends Renderable2 {
|
|
|
15634
15910
|
}
|
|
15635
15911
|
}
|
|
15636
15912
|
// src/renderables/TimeToFirstDraw.ts
|
|
15637
|
-
var
|
|
15638
|
-
function
|
|
15913
|
+
var transparent4 = RGBA2.fromValues(0, 0, 0, 0);
|
|
15914
|
+
function fittedWidth(buffer, text, maxWidth) {
|
|
15915
|
+
if (/^[\x20-\x7e]*$/.test(text))
|
|
15916
|
+
return Math.min(text.length, maxWidth);
|
|
15639
15917
|
const encoded = buffer.encodeUnicode(text);
|
|
15640
|
-
|
|
15641
|
-
|
|
15642
|
-
|
|
15643
|
-
return encoded.data.reduce((width, glyph) => width + glyph.width, 0);
|
|
15644
|
-
} finally {
|
|
15645
|
-
buffer.freeUnicode(encoded);
|
|
15646
|
-
}
|
|
15647
|
-
}
|
|
15648
|
-
function truncateToCellWidth(buffer, text, maxWidth) {
|
|
15649
|
-
let visibleText = "";
|
|
15650
|
-
let visibleWidth = 0;
|
|
15651
|
-
for (const { segment } of graphemeSegmenter.segment(text)) {
|
|
15652
|
-
const segmentWidth = measureCellWidth(buffer, segment);
|
|
15653
|
-
if (visibleWidth + segmentWidth > maxWidth)
|
|
15918
|
+
let width = 0;
|
|
15919
|
+
for (const glyph of encoded.data) {
|
|
15920
|
+
if (width + glyph.width > maxWidth)
|
|
15654
15921
|
break;
|
|
15655
|
-
|
|
15656
|
-
visibleWidth += segmentWidth;
|
|
15922
|
+
width += glyph.width;
|
|
15657
15923
|
}
|
|
15658
|
-
|
|
15924
|
+
buffer.freeUnicode(encoded);
|
|
15925
|
+
return width;
|
|
15659
15926
|
}
|
|
15660
15927
|
|
|
15661
15928
|
class TimeToFirstDrawRenderable extends Renderable2 {
|
|
@@ -15713,10 +15980,9 @@ class TimeToFirstDrawRenderable extends Renderable2 {
|
|
|
15713
15980
|
}
|
|
15714
15981
|
const content = `${this.label}: ${this._runtimeMs.toFixed(this.precision)}ms`;
|
|
15715
15982
|
const maxWidth = Math.max(this.width, 1);
|
|
15716
|
-
const visibleContent = truncateToCellWidth(buffer, content, maxWidth);
|
|
15717
15983
|
const [x, y] = this._paintOrigin(buffer);
|
|
15718
|
-
const
|
|
15719
|
-
buffer.
|
|
15984
|
+
const width = fittedWidth(buffer, content, maxWidth);
|
|
15985
|
+
buffer.drawTextFit(content, x + Math.floor((maxWidth - width) / 2), y, width, this.textColor, transparent4);
|
|
15720
15986
|
}
|
|
15721
15987
|
normalizePrecision(value) {
|
|
15722
15988
|
if (!Number.isFinite(value)) {
|
|
@@ -15886,6 +16152,7 @@ export {
|
|
|
15886
16152
|
Timeline2 as Timeline,
|
|
15887
16153
|
TreeSitterClient2 as TreeSitterClient,
|
|
15888
16154
|
VRenderable,
|
|
16155
|
+
VideoRenderable,
|
|
15889
16156
|
VignetteEffect,
|
|
15890
16157
|
exports_yoga as Yoga,
|
|
15891
16158
|
acquireSessionBufferLease2 as acquireSessionBufferLease,
|
|
@@ -15926,6 +16193,7 @@ export {
|
|
|
15926
16193
|
buildKittyKeyboardFlags2 as buildKittyKeyboardFlags,
|
|
15927
16194
|
buildTerminalPaletteSignature2 as buildTerminalPaletteSignature,
|
|
15928
16195
|
capture2 as capture,
|
|
16196
|
+
checkCrop2 as checkCrop,
|
|
15929
16197
|
clearEnvCache2 as clearEnvCache,
|
|
15930
16198
|
convertGlobalToLocalSelection2 as convertGlobalToLocalSelection,
|
|
15931
16199
|
convertThemeToStyles,
|
|
@@ -16020,6 +16288,7 @@ export {
|
|
|
16020
16288
|
resolveRenderLib2 as resolveRenderLib,
|
|
16021
16289
|
reverse2 as reverse,
|
|
16022
16290
|
rgbToHex2 as rgbToHex,
|
|
16291
|
+
sameCrop2 as sameCrop,
|
|
16023
16292
|
scrollUnitSize,
|
|
16024
16293
|
setRenderLibPath2 as setRenderLibPath,
|
|
16025
16294
|
setupAudio,
|
|
@@ -16038,5 +16307,5 @@ export {
|
|
|
16038
16307
|
yellow2 as yellow
|
|
16039
16308
|
};
|
|
16040
16309
|
|
|
16041
|
-
//# debugId=
|
|
16310
|
+
//# debugId=A87CBF6EE7DB0E5D64756E2164756E21
|
|
16042
16311
|
//# sourceMappingURL=index.bun.js.map
|