@opentui/core 0.8.0 → 0.8.1
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-ved2tpxm.js} +430 -64
- package/{chunk-bun-6kxdhkdc.js.map → chunk-bun-ved2tpxm.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-tpjmjvn7.js} +430 -64
- package/{chunk-node-q5ccgbk5.js.map → chunk-node-tpjmjvn7.js.map} +10 -10
- package/index.bun.js +670 -391
- package/index.bun.js.map +11 -10
- package/index.d.ts +1 -1
- package/index.node.js +670 -391
- package/index.node.js.map +11 -9
- 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 -1
- 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/renderer.d.ts +22 -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-ved2tpxm.js";
|
|
257
258
|
// src/syntax-style.ts
|
|
258
259
|
function cloneStyle(style) {
|
|
259
260
|
return {
|
|
@@ -6087,6 +6088,7 @@ class VRenderable extends Renderable2 {
|
|
|
6087
6088
|
// src/renderables/LineNumberRenderable.ts
|
|
6088
6089
|
var DEFAULT_GUTTER_FG = "#888888";
|
|
6089
6090
|
var DEFAULT_GUTTER_BG = "transparent";
|
|
6091
|
+
var transparent = RGBA2.fromValues(0, 0, 0, 0);
|
|
6090
6092
|
function cloneLineSign(sign) {
|
|
6091
6093
|
return {
|
|
6092
6094
|
...sign,
|
|
@@ -6109,8 +6111,8 @@ class GutterRenderable extends Renderable2 {
|
|
|
6109
6111
|
_maxBeforeWidth = 0;
|
|
6110
6112
|
_maxAfterWidth = 0;
|
|
6111
6113
|
_lastKnownLineCount = 0;
|
|
6112
|
-
|
|
6113
|
-
|
|
6114
|
+
_signWidths = new Map;
|
|
6115
|
+
_signWidthMethod;
|
|
6114
6116
|
constructor(ctx, target, options) {
|
|
6115
6117
|
super(ctx, {
|
|
6116
6118
|
id: options.id,
|
|
@@ -6135,7 +6137,10 @@ class GutterRenderable extends Renderable2 {
|
|
|
6135
6137
|
this.setupMeasureFunc();
|
|
6136
6138
|
this.onLifecyclePass = () => {
|
|
6137
6139
|
const currentLineCount = this.target.virtualLineCount;
|
|
6138
|
-
|
|
6140
|
+
const signsStale = this._ctx.widthMethod !== this._signWidthMethod;
|
|
6141
|
+
if (signsStale)
|
|
6142
|
+
this.calculateSignWidths();
|
|
6143
|
+
if (currentLineCount !== this._lastKnownLineCount || signsStale) {
|
|
6139
6144
|
this._lastKnownLineCount = currentLineCount;
|
|
6140
6145
|
this.invalidateIntrinsicSize();
|
|
6141
6146
|
this.requestRender();
|
|
@@ -6186,16 +6191,30 @@ class GutterRenderable extends Renderable2 {
|
|
|
6186
6191
|
calculateSignWidths() {
|
|
6187
6192
|
this._maxBeforeWidth = 0;
|
|
6188
6193
|
this._maxAfterWidth = this._layout.minAfterWidth;
|
|
6194
|
+
this._signWidths.clear();
|
|
6195
|
+
this._signWidthMethod = this._ctx.widthMethod;
|
|
6189
6196
|
for (const sign of this._lineSigns.values()) {
|
|
6190
|
-
if (sign.before)
|
|
6191
|
-
|
|
6192
|
-
|
|
6193
|
-
|
|
6194
|
-
|
|
6195
|
-
|
|
6196
|
-
|
|
6197
|
-
|
|
6197
|
+
if (sign.before)
|
|
6198
|
+
this._maxBeforeWidth = Math.max(this._maxBeforeWidth, this.signWidth(sign.before));
|
|
6199
|
+
if (sign.after)
|
|
6200
|
+
this._maxAfterWidth = Math.max(this._maxAfterWidth, this.signWidth(sign.after));
|
|
6201
|
+
}
|
|
6202
|
+
}
|
|
6203
|
+
signWidth(sign) {
|
|
6204
|
+
if (/^[\x20-\x7e]*$/.test(sign))
|
|
6205
|
+
return sign.length;
|
|
6206
|
+
let width = this._signWidths.get(sign);
|
|
6207
|
+
if (width !== undefined)
|
|
6208
|
+
return width;
|
|
6209
|
+
const { context, renderLib } = this._ctx.nativeScene.driver;
|
|
6210
|
+
const unicode = renderLib.createContextUnicode(context, sign, this._signWidthMethod);
|
|
6211
|
+
try {
|
|
6212
|
+
width = renderLib.getContextUnicode(context, unicode).reduce((sum, glyph) => sum + glyph.width, 0);
|
|
6213
|
+
} finally {
|
|
6214
|
+
renderLib.destroyContextUnicode(context, unicode);
|
|
6198
6215
|
}
|
|
6216
|
+
this._signWidths.set(sign, width);
|
|
6217
|
+
return width;
|
|
6199
6218
|
}
|
|
6200
6219
|
calculateWidth() {
|
|
6201
6220
|
const totalLines = Math.max(this.target.lineCount, this.target.virtualLineCount);
|
|
@@ -6251,81 +6270,48 @@ class GutterRenderable extends Renderable2 {
|
|
|
6251
6270
|
getLineSigns() {
|
|
6252
6271
|
return this._lineSigns;
|
|
6253
6272
|
}
|
|
6254
|
-
createFrameBuffer() {}
|
|
6255
|
-
handleFrameBufferResize() {}
|
|
6256
6273
|
renderSelf(buffer) {
|
|
6257
|
-
const x =
|
|
6258
|
-
const y = Math.trunc(this._screenY);
|
|
6274
|
+
const [x, y] = this._paintOrigin(buffer);
|
|
6259
6275
|
const start = Math.max(0, -y);
|
|
6260
6276
|
const end = Math.min(this.height, buffer.height - y);
|
|
6261
6277
|
if (end <= start || x >= buffer.width || x + this.width <= 0)
|
|
6262
6278
|
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) {
|
|
6279
|
+
const startLine = Math.trunc(this.target.scrollY) + start;
|
|
6278
6280
|
const sourceStart = Math.max(0, startLine - 1);
|
|
6279
6281
|
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);
|
|
6282
|
+
const sources = getLineSources(this.target, sourceStart, end - start + sourceOffset);
|
|
6286
6283
|
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;
|
|
6284
|
+
for (let i = sourceOffset;i < end - start + sourceOffset; i++) {
|
|
6285
|
+
const row = y + start + i - sourceOffset;
|
|
6286
|
+
const logicalLine = sources[i];
|
|
6287
|
+
const lineBg = this._lineColorsGutter.get(logicalLine);
|
|
6288
|
+
if (!lineBg || lineBg.a < 1)
|
|
6289
|
+
buffer.fillRect(x, row, this.width, 1, this._bg);
|
|
6290
|
+
if (lineBg)
|
|
6291
|
+
buffer.fillRect(x, row, this.width, 1, lineBg);
|
|
6292
|
+
if (logicalLine !== undefined && logicalLine !== lastSource) {
|
|
6298
6293
|
const sign = this._lineSigns.get(logicalLine);
|
|
6299
6294
|
if (sign?.before) {
|
|
6300
|
-
const
|
|
6301
|
-
const padding = this._maxBeforeWidth - beforeWidth;
|
|
6302
|
-
currentX += padding;
|
|
6295
|
+
const beforeX = x + this._maxBeforeWidth - this.signWidth(sign.before);
|
|
6303
6296
|
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;
|
|
6297
|
+
buffer.drawText(sign.before, beforeX, row, beforeColor, transparent);
|
|
6308
6298
|
}
|
|
6309
6299
|
if (!this._hideLineNumbers.has(logicalLine)) {
|
|
6310
6300
|
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;
|
|
6301
|
+
const lineNumStr = (customLineNum ?? logicalLine + 1 + this._lineNumberOffset).toString();
|
|
6302
|
+
const lineNumX = this.width - this._maxAfterWidth - this._layout.paddingRight - lineNumStr.length;
|
|
6315
6303
|
if (lineNumX >= this._maxBeforeWidth + this._layout.paddingLeft) {
|
|
6316
|
-
buffer.drawText(lineNumStr, lineNumX,
|
|
6304
|
+
buffer.drawText(lineNumStr, x + lineNumX, row, this._fg, transparent);
|
|
6317
6305
|
}
|
|
6318
6306
|
}
|
|
6319
6307
|
if (sign?.after) {
|
|
6320
|
-
const afterX = this.width - this._layout.paddingRight - this._maxAfterWidth;
|
|
6308
|
+
const afterX = x + this.width - this._layout.paddingRight - this._maxAfterWidth;
|
|
6321
6309
|
const afterColor = sign.afterColor ? parseColor2(sign.afterColor) : this._fg;
|
|
6322
|
-
buffer.drawText(sign.after, afterX,
|
|
6310
|
+
buffer.drawText(sign.after, afterX, row, afterColor, transparent);
|
|
6323
6311
|
}
|
|
6324
6312
|
}
|
|
6325
6313
|
lastSource = logicalLine;
|
|
6326
6314
|
}
|
|
6327
|
-
this._paintedSources = sources.slice();
|
|
6328
|
-
this._paintedSourceOffset = sourceOffset;
|
|
6329
6315
|
}
|
|
6330
6316
|
}
|
|
6331
6317
|
function getLineSources(target, startLine, lineCount) {
|
|
@@ -9043,6 +9029,472 @@ class InputRenderable extends TextareaRenderable {
|
|
|
9043
9029
|
}
|
|
9044
9030
|
set initialValue(value) {}
|
|
9045
9031
|
}
|
|
9032
|
+
// src/renderables/Video.ts
|
|
9033
|
+
function validateVolume(value) {
|
|
9034
|
+
if (!Number.isFinite(value) || value < 0 || value > 340282346638528860000000000000000000000)
|
|
9035
|
+
throw new RangeError("volume must be a finite, non-negative 32-bit float");
|
|
9036
|
+
}
|
|
9037
|
+
function validateAvSyncOffset(value) {
|
|
9038
|
+
if (!Number.isFinite(value) || Math.abs(value) > 60000)
|
|
9039
|
+
throw new RangeError("avSyncOffsetMs must be from -60000 to 60000");
|
|
9040
|
+
}
|
|
9041
|
+
function validateMaxFps(value) {
|
|
9042
|
+
if (!Number.isInteger(value) || value < 1 || value > 120)
|
|
9043
|
+
throw new RangeError("maxFps must be an integer from 1 to 120");
|
|
9044
|
+
}
|
|
9045
|
+
function toMicroseconds(seconds, label) {
|
|
9046
|
+
const value = Math.round(seconds * 1e6);
|
|
9047
|
+
if (!Number.isFinite(seconds) || !Number.isSafeInteger(value))
|
|
9048
|
+
throw new RangeError(`${label} must be finite`);
|
|
9049
|
+
return BigInt(value);
|
|
9050
|
+
}
|
|
9051
|
+
|
|
9052
|
+
class VideoRenderable extends Renderable2 {
|
|
9053
|
+
static nativeIntegration = {
|
|
9054
|
+
kind: "video",
|
|
9055
|
+
body: { native: this.prototype.renderSelf, buffered: true },
|
|
9056
|
+
bufferComposition: "native"
|
|
9057
|
+
};
|
|
9058
|
+
_source;
|
|
9059
|
+
_fit;
|
|
9060
|
+
_crop;
|
|
9061
|
+
_loop;
|
|
9062
|
+
_audio;
|
|
9063
|
+
_muted;
|
|
9064
|
+
_volume;
|
|
9065
|
+
_avSyncOffsetMs;
|
|
9066
|
+
_maxFps;
|
|
9067
|
+
_autoplay;
|
|
9068
|
+
_metadata = null;
|
|
9069
|
+
_playRequested = false;
|
|
9070
|
+
stopTick;
|
|
9071
|
+
_opens = 0;
|
|
9072
|
+
onReady;
|
|
9073
|
+
onError;
|
|
9074
|
+
onEnd;
|
|
9075
|
+
onPlay;
|
|
9076
|
+
onPause;
|
|
9077
|
+
onSeek;
|
|
9078
|
+
onTimeUpdate;
|
|
9079
|
+
constructor(ctx, options) {
|
|
9080
|
+
super(ctx, options);
|
|
9081
|
+
try {
|
|
9082
|
+
this._fit = options.fit ?? "fit";
|
|
9083
|
+
this._loop = options.loop ?? false;
|
|
9084
|
+
this._audio = options.audio ?? true;
|
|
9085
|
+
this._muted = options.muted ?? false;
|
|
9086
|
+
this._volume = options.volume ?? 1;
|
|
9087
|
+
validateVolume(this._volume);
|
|
9088
|
+
this._avSyncOffsetMs = options.avSyncOffsetMs ?? 0;
|
|
9089
|
+
validateAvSyncOffset(this._avSyncOffsetMs);
|
|
9090
|
+
this._maxFps = options.maxFps ?? 30;
|
|
9091
|
+
validateMaxFps(this._maxFps);
|
|
9092
|
+
this._autoplay = options.autoplay ?? false;
|
|
9093
|
+
this.onReady = options.onReady;
|
|
9094
|
+
this.onError = options.onError;
|
|
9095
|
+
this.onEnd = options.onEnd;
|
|
9096
|
+
this.onPlay = options.onPlay;
|
|
9097
|
+
this.onPause = options.onPause;
|
|
9098
|
+
this.onSeek = options.onSeek;
|
|
9099
|
+
this.onTimeUpdate = options.onTimeUpdate;
|
|
9100
|
+
this.setNativeSceneVideo();
|
|
9101
|
+
if (options.source !== undefined)
|
|
9102
|
+
this.source = options.source;
|
|
9103
|
+
this.crop = options.crop;
|
|
9104
|
+
} catch (error) {
|
|
9105
|
+
this.abortConstruction(error, () => this.destroySelf());
|
|
9106
|
+
}
|
|
9107
|
+
}
|
|
9108
|
+
get source() {
|
|
9109
|
+
return this._source;
|
|
9110
|
+
}
|
|
9111
|
+
set source(value) {
|
|
9112
|
+
value ??= undefined;
|
|
9113
|
+
if (value === this._source && !this.failed() || this.isDestroyed)
|
|
9114
|
+
return;
|
|
9115
|
+
this.open(value, this.playing);
|
|
9116
|
+
}
|
|
9117
|
+
open(value, resume) {
|
|
9118
|
+
this._opens++;
|
|
9119
|
+
this._source = value;
|
|
9120
|
+
this._metadata = null;
|
|
9121
|
+
this._playRequested = resume;
|
|
9122
|
+
const native = this.native();
|
|
9123
|
+
try {
|
|
9124
|
+
const info = native.lib.videoOpen(native.context, native.node, value ?? "", this._audio);
|
|
9125
|
+
if (!value)
|
|
9126
|
+
return;
|
|
9127
|
+
this._playRequested = resume || this._autoplay;
|
|
9128
|
+
this._metadata = {
|
|
9129
|
+
width: info.width,
|
|
9130
|
+
height: info.height,
|
|
9131
|
+
fps: info.fpsDen > 0 ? info.fpsNum / info.fpsDen : 0,
|
|
9132
|
+
duration: Number(info.durationUs) / 1e6,
|
|
9133
|
+
hasAudio: info.hasAudio
|
|
9134
|
+
};
|
|
9135
|
+
native.lib.videoSetLoop(native.context, native.node, this._loop);
|
|
9136
|
+
native.lib.videoSetMuted(native.context, native.node, this._muted);
|
|
9137
|
+
native.lib.videoSetVolume(native.context, native.node, this._volume);
|
|
9138
|
+
native.lib.videoSetAvSyncOffset(native.context, native.node, toMicroseconds(this._avSyncOffsetMs / 1000, "avSyncOffsetMs"));
|
|
9139
|
+
native.lib.videoSetMaxFps(native.context, native.node, this._maxFps);
|
|
9140
|
+
const metadata = { ...this._metadata };
|
|
9141
|
+
this.afterOpen(() => {
|
|
9142
|
+
this.onReady?.(metadata);
|
|
9143
|
+
this.startRequested();
|
|
9144
|
+
try {
|
|
9145
|
+
if (this._crop)
|
|
9146
|
+
checkCrop2(this._crop, metadata.width, metadata.height);
|
|
9147
|
+
} catch (error) {
|
|
9148
|
+
this.reportError(error, "");
|
|
9149
|
+
}
|
|
9150
|
+
});
|
|
9151
|
+
} catch (error) {
|
|
9152
|
+
this._metadata = null;
|
|
9153
|
+
this._playRequested = false;
|
|
9154
|
+
const detail = this.errorDetail("");
|
|
9155
|
+
this.afterOpen(() => this.reportError(error, detail));
|
|
9156
|
+
} finally {
|
|
9157
|
+
this.syncPlayback();
|
|
9158
|
+
this.requestRender();
|
|
9159
|
+
}
|
|
9160
|
+
}
|
|
9161
|
+
get fit() {
|
|
9162
|
+
return this._fit;
|
|
9163
|
+
}
|
|
9164
|
+
set fit(value) {
|
|
9165
|
+
const next = value ?? "fit";
|
|
9166
|
+
if (this._fit === next || this.isDestroyed)
|
|
9167
|
+
return;
|
|
9168
|
+
this.setNativeSceneVideo(next);
|
|
9169
|
+
this._fit = next;
|
|
9170
|
+
this.requestRender();
|
|
9171
|
+
}
|
|
9172
|
+
get crop() {
|
|
9173
|
+
return this._crop && { ...this._crop };
|
|
9174
|
+
}
|
|
9175
|
+
set crop(value) {
|
|
9176
|
+
if (sameCrop2(this._crop, value ?? undefined) || this.isDestroyed)
|
|
9177
|
+
return;
|
|
9178
|
+
const next = this.acceptCrop(value ?? undefined);
|
|
9179
|
+
if (next === null)
|
|
9180
|
+
return;
|
|
9181
|
+
this._ctx.nativeScene.setCrop(this, next);
|
|
9182
|
+
this._crop = next;
|
|
9183
|
+
this.requestRender();
|
|
9184
|
+
}
|
|
9185
|
+
get loop() {
|
|
9186
|
+
return this._loop;
|
|
9187
|
+
}
|
|
9188
|
+
set loop(value) {
|
|
9189
|
+
const next = value ?? false;
|
|
9190
|
+
if (this._loop === next || this.isDestroyed)
|
|
9191
|
+
return;
|
|
9192
|
+
if (this.applyOption((native) => native.lib.videoSetLoop(native.context, native.node, next)))
|
|
9193
|
+
this._loop = next;
|
|
9194
|
+
}
|
|
9195
|
+
get audio() {
|
|
9196
|
+
return this._audio;
|
|
9197
|
+
}
|
|
9198
|
+
set audio(value) {
|
|
9199
|
+
const next = value ?? true;
|
|
9200
|
+
if (this._audio === next || this.isDestroyed)
|
|
9201
|
+
return;
|
|
9202
|
+
this._audio = next;
|
|
9203
|
+
if (this._metadata)
|
|
9204
|
+
this.open(this._source, this.playing);
|
|
9205
|
+
}
|
|
9206
|
+
get muted() {
|
|
9207
|
+
return this._muted;
|
|
9208
|
+
}
|
|
9209
|
+
set muted(value) {
|
|
9210
|
+
const next = value ?? false;
|
|
9211
|
+
if (this._muted === next || this.isDestroyed)
|
|
9212
|
+
return;
|
|
9213
|
+
if (this.applyOption((native) => native.lib.videoSetMuted(native.context, native.node, next)))
|
|
9214
|
+
this._muted = next;
|
|
9215
|
+
}
|
|
9216
|
+
get volume() {
|
|
9217
|
+
return this._volume;
|
|
9218
|
+
}
|
|
9219
|
+
set volume(value) {
|
|
9220
|
+
const next = value ?? 1;
|
|
9221
|
+
validateVolume(next);
|
|
9222
|
+
if (this._volume === next || this.isDestroyed)
|
|
9223
|
+
return;
|
|
9224
|
+
if (this.applyOption((native) => native.lib.videoSetVolume(native.context, native.node, next)))
|
|
9225
|
+
this._volume = next;
|
|
9226
|
+
}
|
|
9227
|
+
get avSyncOffsetMs() {
|
|
9228
|
+
return this._avSyncOffsetMs;
|
|
9229
|
+
}
|
|
9230
|
+
set avSyncOffsetMs(value) {
|
|
9231
|
+
const next = value ?? 0;
|
|
9232
|
+
validateAvSyncOffset(next);
|
|
9233
|
+
if (this._avSyncOffsetMs === next || this.isDestroyed)
|
|
9234
|
+
return;
|
|
9235
|
+
const offset = toMicroseconds(next / 1000, "avSyncOffsetMs");
|
|
9236
|
+
if (this.applyOption((native) => native.lib.videoSetAvSyncOffset(native.context, native.node, offset)))
|
|
9237
|
+
this._avSyncOffsetMs = next;
|
|
9238
|
+
}
|
|
9239
|
+
get maxFps() {
|
|
9240
|
+
return this._maxFps;
|
|
9241
|
+
}
|
|
9242
|
+
set maxFps(value) {
|
|
9243
|
+
const next = value ?? 30;
|
|
9244
|
+
validateMaxFps(next);
|
|
9245
|
+
if (this._maxFps === next || this.isDestroyed)
|
|
9246
|
+
return;
|
|
9247
|
+
if (!this.applyOption((native) => native.lib.videoSetMaxFps(native.context, native.node, next)))
|
|
9248
|
+
return;
|
|
9249
|
+
this._maxFps = next;
|
|
9250
|
+
this.syncPlayback();
|
|
9251
|
+
}
|
|
9252
|
+
get autoplay() {
|
|
9253
|
+
return this._autoplay;
|
|
9254
|
+
}
|
|
9255
|
+
set autoplay(value) {
|
|
9256
|
+
const next = value ?? false;
|
|
9257
|
+
if (this._autoplay === next || this.isDestroyed)
|
|
9258
|
+
return;
|
|
9259
|
+
this._autoplay = next;
|
|
9260
|
+
if (!next || !this._metadata)
|
|
9261
|
+
return;
|
|
9262
|
+
const requested = this.control((native) => {
|
|
9263
|
+
const state = native.lib.videoGetState(native.context, native.node);
|
|
9264
|
+
if (state.playing || state.ended || state.currentTimeUs !== 0n)
|
|
9265
|
+
return false;
|
|
9266
|
+
this._playRequested = true;
|
|
9267
|
+
});
|
|
9268
|
+
if (requested)
|
|
9269
|
+
this.afterOpen(() => this.startRequested());
|
|
9270
|
+
}
|
|
9271
|
+
get ready() {
|
|
9272
|
+
return this._metadata !== null;
|
|
9273
|
+
}
|
|
9274
|
+
get videoMetadata() {
|
|
9275
|
+
return this._metadata ? { ...this._metadata } : null;
|
|
9276
|
+
}
|
|
9277
|
+
get playing() {
|
|
9278
|
+
if (this.isDestroyed)
|
|
9279
|
+
return false;
|
|
9280
|
+
return this._playRequested || this._metadata !== null && this.readState().playing;
|
|
9281
|
+
}
|
|
9282
|
+
get paused() {
|
|
9283
|
+
return !this.playing;
|
|
9284
|
+
}
|
|
9285
|
+
get ended() {
|
|
9286
|
+
return this._metadata !== null && !this.isDestroyed && this.readState().ended;
|
|
9287
|
+
}
|
|
9288
|
+
get duration() {
|
|
9289
|
+
return this._metadata?.duration ?? 0;
|
|
9290
|
+
}
|
|
9291
|
+
get durationMs() {
|
|
9292
|
+
return this.duration * 1000;
|
|
9293
|
+
}
|
|
9294
|
+
get currentTime() {
|
|
9295
|
+
if (!this._metadata || this.isDestroyed)
|
|
9296
|
+
return 0;
|
|
9297
|
+
return Number(this.readState().currentTimeUs) / 1e6;
|
|
9298
|
+
}
|
|
9299
|
+
set currentTime(value) {
|
|
9300
|
+
if (value == null)
|
|
9301
|
+
return;
|
|
9302
|
+
this.seek(value);
|
|
9303
|
+
}
|
|
9304
|
+
get qualityTier() {
|
|
9305
|
+
if (!this._metadata || this.isDestroyed)
|
|
9306
|
+
return 0;
|
|
9307
|
+
return this.readState().qualityTier;
|
|
9308
|
+
}
|
|
9309
|
+
get currentTimeMs() {
|
|
9310
|
+
return this.currentTime * 1000;
|
|
9311
|
+
}
|
|
9312
|
+
play() {
|
|
9313
|
+
if (this.isDestroyed || this._playRequested)
|
|
9314
|
+
return;
|
|
9315
|
+
if (!this._metadata) {
|
|
9316
|
+
if (this._source !== undefined)
|
|
9317
|
+
this.open(this._source, true);
|
|
9318
|
+
else
|
|
9319
|
+
this._playRequested = true;
|
|
9320
|
+
return;
|
|
9321
|
+
}
|
|
9322
|
+
const started = this.control((native) => {
|
|
9323
|
+
if (native.lib.videoGetState(native.context, native.node).playing)
|
|
9324
|
+
return false;
|
|
9325
|
+
native.lib.videoCall(native.context, native.node, "ot_video_play");
|
|
9326
|
+
});
|
|
9327
|
+
if (started)
|
|
9328
|
+
this.onPlay?.();
|
|
9329
|
+
}
|
|
9330
|
+
resume() {
|
|
9331
|
+
this.play();
|
|
9332
|
+
}
|
|
9333
|
+
pause() {
|
|
9334
|
+
if (this.isDestroyed)
|
|
9335
|
+
return;
|
|
9336
|
+
const requested = this._playRequested;
|
|
9337
|
+
this._playRequested = false;
|
|
9338
|
+
if (!this._metadata)
|
|
9339
|
+
return;
|
|
9340
|
+
const paused = this.control((native) => {
|
|
9341
|
+
if (requested)
|
|
9342
|
+
return;
|
|
9343
|
+
if (!native.lib.videoGetState(native.context, native.node).playing)
|
|
9344
|
+
return false;
|
|
9345
|
+
native.lib.videoCall(native.context, native.node, "ot_video_pause");
|
|
9346
|
+
});
|
|
9347
|
+
if (!paused)
|
|
9348
|
+
return;
|
|
9349
|
+
const time = this.currentTime;
|
|
9350
|
+
this.onPause?.();
|
|
9351
|
+
this.onTimeUpdate?.(time);
|
|
9352
|
+
}
|
|
9353
|
+
toggle() {
|
|
9354
|
+
if (this.playing)
|
|
9355
|
+
this.pause();
|
|
9356
|
+
else
|
|
9357
|
+
this.play();
|
|
9358
|
+
}
|
|
9359
|
+
seek(time) {
|
|
9360
|
+
const target = toMicroseconds(time, "Video time");
|
|
9361
|
+
if (!this._metadata || this.isDestroyed)
|
|
9362
|
+
return;
|
|
9363
|
+
if (!this.control((native) => native.lib.videoSeek(native.context, native.node, target)))
|
|
9364
|
+
return;
|
|
9365
|
+
const position = this.currentTime;
|
|
9366
|
+
this.onSeek?.(position);
|
|
9367
|
+
this.onTimeUpdate?.(position);
|
|
9368
|
+
}
|
|
9369
|
+
seekBy(delta) {
|
|
9370
|
+
if (!Number.isFinite(delta))
|
|
9371
|
+
throw new RangeError("Video seek delta must be finite");
|
|
9372
|
+
this.seek(this.currentTime + delta);
|
|
9373
|
+
}
|
|
9374
|
+
seekToMs(milliseconds) {
|
|
9375
|
+
if (!Number.isFinite(milliseconds))
|
|
9376
|
+
throw new RangeError("Video time must be finite");
|
|
9377
|
+
this.seek(milliseconds / 1000);
|
|
9378
|
+
}
|
|
9379
|
+
createFrameBuffer() {
|
|
9380
|
+
const previous = this.frameBuffer;
|
|
9381
|
+
super.createFrameBuffer();
|
|
9382
|
+
if (this._fit === undefined || this.frameBuffer === previous)
|
|
9383
|
+
return;
|
|
9384
|
+
this.setNativeSceneVideo();
|
|
9385
|
+
}
|
|
9386
|
+
renderSelf(_buffer) {}
|
|
9387
|
+
poll() {
|
|
9388
|
+
if (!this._metadata || this.isDestroyed)
|
|
9389
|
+
return;
|
|
9390
|
+
let state;
|
|
9391
|
+
try {
|
|
9392
|
+
state = this.readState();
|
|
9393
|
+
} catch (error) {
|
|
9394
|
+
this.reportError(error);
|
|
9395
|
+
this.syncPlayback(false);
|
|
9396
|
+
return;
|
|
9397
|
+
}
|
|
9398
|
+
if (state.failed) {
|
|
9399
|
+
this.reportError(new Error(this.errorDetail("Video playback failed")));
|
|
9400
|
+
this.syncPlayback();
|
|
9401
|
+
return;
|
|
9402
|
+
}
|
|
9403
|
+
this.onTimeUpdate?.(Number(state.currentTimeUs) / 1e6);
|
|
9404
|
+
if (state.ended) {
|
|
9405
|
+
this.syncPlayback();
|
|
9406
|
+
this.onEnd?.();
|
|
9407
|
+
}
|
|
9408
|
+
}
|
|
9409
|
+
native() {
|
|
9410
|
+
return this._ctx.nativeScene.videoNode(this);
|
|
9411
|
+
}
|
|
9412
|
+
readState() {
|
|
9413
|
+
const native = this.native();
|
|
9414
|
+
return native.lib.videoGetState(native.context, native.node);
|
|
9415
|
+
}
|
|
9416
|
+
failed() {
|
|
9417
|
+
if (!this._metadata)
|
|
9418
|
+
return false;
|
|
9419
|
+
try {
|
|
9420
|
+
return this.readState().failed;
|
|
9421
|
+
} catch {
|
|
9422
|
+
return true;
|
|
9423
|
+
}
|
|
9424
|
+
}
|
|
9425
|
+
errorDetail(fallback) {
|
|
9426
|
+
try {
|
|
9427
|
+
const native = this.native();
|
|
9428
|
+
return native.lib.videoGetError(native.context, native.node) || fallback;
|
|
9429
|
+
} catch {
|
|
9430
|
+
return fallback;
|
|
9431
|
+
}
|
|
9432
|
+
}
|
|
9433
|
+
applyOption(call) {
|
|
9434
|
+
return !this._metadata || this.control(call);
|
|
9435
|
+
}
|
|
9436
|
+
control(call) {
|
|
9437
|
+
let reported = false;
|
|
9438
|
+
try {
|
|
9439
|
+
return call(this.native()) !== false;
|
|
9440
|
+
} catch (error) {
|
|
9441
|
+
reported = true;
|
|
9442
|
+
this.reportError(error);
|
|
9443
|
+
return false;
|
|
9444
|
+
} finally {
|
|
9445
|
+
this.syncPlayback(!reported);
|
|
9446
|
+
this.requestRender();
|
|
9447
|
+
}
|
|
9448
|
+
}
|
|
9449
|
+
syncPlayback(report = true) {
|
|
9450
|
+
if (this.isDestroyed)
|
|
9451
|
+
return;
|
|
9452
|
+
let active = false;
|
|
9453
|
+
try {
|
|
9454
|
+
active = this._metadata !== null && (this._playRequested || this.readState().playing);
|
|
9455
|
+
} catch (error) {
|
|
9456
|
+
if (report)
|
|
9457
|
+
this.reportError(error);
|
|
9458
|
+
}
|
|
9459
|
+
this.stopTick?.();
|
|
9460
|
+
this.stopTick = active ? this._ctx.onAnimationTick(this._maxFps, () => this.poll()) : undefined;
|
|
9461
|
+
}
|
|
9462
|
+
setNativeSceneVideo(fit = this._fit) {
|
|
9463
|
+
this._ctx.nativeScene.setVideo(this, fit, this.buffered ? this.frameBuffer : null);
|
|
9464
|
+
}
|
|
9465
|
+
acceptCrop(crop) {
|
|
9466
|
+
try {
|
|
9467
|
+
return crop && checkCrop2(crop, this._metadata?.width, this._metadata?.height);
|
|
9468
|
+
} catch (error) {
|
|
9469
|
+
queueMicrotask(() => this.isDestroyed || this.reportError(error, ""));
|
|
9470
|
+
return null;
|
|
9471
|
+
}
|
|
9472
|
+
}
|
|
9473
|
+
startRequested() {
|
|
9474
|
+
if (!this._playRequested)
|
|
9475
|
+
return;
|
|
9476
|
+
this._playRequested = false;
|
|
9477
|
+
if (this.control((native) => native.lib.videoCall(native.context, native.node, "ot_video_play")))
|
|
9478
|
+
this.onPlay?.();
|
|
9479
|
+
}
|
|
9480
|
+
afterOpen(report) {
|
|
9481
|
+
const opens = this._opens;
|
|
9482
|
+
queueMicrotask(() => {
|
|
9483
|
+
if (this._opens === opens && !this.isDestroyed)
|
|
9484
|
+
report();
|
|
9485
|
+
});
|
|
9486
|
+
}
|
|
9487
|
+
reportError(error, detail = this.errorDetail("")) {
|
|
9488
|
+
const value = error instanceof Error ? error : new Error(String(error));
|
|
9489
|
+
this.onError?.(detail && !value.message.includes(detail) ? new Error(`${value.message}: ${detail}`) : value);
|
|
9490
|
+
}
|
|
9491
|
+
destroySelf() {
|
|
9492
|
+
this.runCleanup((run) => {
|
|
9493
|
+
run(() => this.stopTick?.());
|
|
9494
|
+
run(() => super.destroySelf());
|
|
9495
|
+
});
|
|
9496
|
+
}
|
|
9497
|
+
}
|
|
9046
9498
|
// ../../node_modules/.bun/marked@17.0.1/node_modules/marked/lib/marked.esm.js
|
|
9047
9499
|
function L() {
|
|
9048
9500
|
return { async: false, breaks: false, extensions: null, gfm: true, hooks: null, pedantic: false, renderer: null, silent: false, tokenizer: null, walkTokens: null };
|
|
@@ -10417,7 +10869,6 @@ class TextTableRenderable extends Renderable2 {
|
|
|
10417
10869
|
_columnCount = 0;
|
|
10418
10870
|
_layout = this.createEmptyLayout();
|
|
10419
10871
|
_layoutDirty = true;
|
|
10420
|
-
_rasterDirty = true;
|
|
10421
10872
|
_cachedMeasureLayout = null;
|
|
10422
10873
|
_cachedMeasureWidth = undefined;
|
|
10423
10874
|
_defaultOptions = {
|
|
@@ -10444,7 +10895,7 @@ class TextTableRenderable extends Renderable2 {
|
|
|
10444
10895
|
attributes: 0
|
|
10445
10896
|
};
|
|
10446
10897
|
constructor(ctx, options = {}) {
|
|
10447
|
-
super(ctx, { ...options, flexShrink: options.flexShrink ?? 0
|
|
10898
|
+
super(ctx, { ...options, flexShrink: options.flexShrink ?? 0 });
|
|
10448
10899
|
try {
|
|
10449
10900
|
this._content = options.content ?? this._defaultOptions.content;
|
|
10450
10901
|
this._wrapMode = options.wrapMode ?? this._defaultOptions.wrapMode;
|
|
@@ -10491,7 +10942,7 @@ class TextTableRenderable extends Renderable2 {
|
|
|
10491
10942
|
for (const cell of row)
|
|
10492
10943
|
cell.textBufferView.setWrapMode(value);
|
|
10493
10944
|
}
|
|
10494
|
-
this.
|
|
10945
|
+
this.invalidateLayout();
|
|
10495
10946
|
});
|
|
10496
10947
|
}
|
|
10497
10948
|
get columnWidthMode() {
|
|
@@ -10501,7 +10952,7 @@ class TextTableRenderable extends Renderable2 {
|
|
|
10501
10952
|
if (this._columnWidthMode === value)
|
|
10502
10953
|
return;
|
|
10503
10954
|
this._columnWidthMode = value;
|
|
10504
|
-
this.
|
|
10955
|
+
this.invalidateLayout();
|
|
10505
10956
|
}
|
|
10506
10957
|
get columnFitter() {
|
|
10507
10958
|
return this._columnFitter;
|
|
@@ -10511,7 +10962,7 @@ class TextTableRenderable extends Renderable2 {
|
|
|
10511
10962
|
if (this._columnFitter === next)
|
|
10512
10963
|
return;
|
|
10513
10964
|
this._columnFitter = next;
|
|
10514
|
-
this.
|
|
10965
|
+
this.invalidateLayout();
|
|
10515
10966
|
}
|
|
10516
10967
|
get cellPadding() {
|
|
10517
10968
|
return this._cellPaddingX === this._cellPaddingY ? this._cellPaddingX : 0;
|
|
@@ -10522,7 +10973,7 @@ class TextTableRenderable extends Renderable2 {
|
|
|
10522
10973
|
return;
|
|
10523
10974
|
this._cellPaddingX = next;
|
|
10524
10975
|
this._cellPaddingY = next;
|
|
10525
|
-
this.
|
|
10976
|
+
this.invalidateLayout();
|
|
10526
10977
|
}
|
|
10527
10978
|
get cellPaddingX() {
|
|
10528
10979
|
return this._cellPaddingX;
|
|
@@ -10532,7 +10983,7 @@ class TextTableRenderable extends Renderable2 {
|
|
|
10532
10983
|
if (this._cellPaddingX === next)
|
|
10533
10984
|
return;
|
|
10534
10985
|
this._cellPaddingX = next;
|
|
10535
|
-
this.
|
|
10986
|
+
this.invalidateLayout();
|
|
10536
10987
|
}
|
|
10537
10988
|
get cellPaddingY() {
|
|
10538
10989
|
return this._cellPaddingY;
|
|
@@ -10542,7 +10993,7 @@ class TextTableRenderable extends Renderable2 {
|
|
|
10542
10993
|
if (this._cellPaddingY === next)
|
|
10543
10994
|
return;
|
|
10544
10995
|
this._cellPaddingY = next;
|
|
10545
|
-
this.
|
|
10996
|
+
this.invalidateLayout();
|
|
10546
10997
|
}
|
|
10547
10998
|
get columnGap() {
|
|
10548
10999
|
return this._columnGap;
|
|
@@ -10552,7 +11003,7 @@ class TextTableRenderable extends Renderable2 {
|
|
|
10552
11003
|
if (this._columnGap === next)
|
|
10553
11004
|
return;
|
|
10554
11005
|
this._columnGap = next;
|
|
10555
|
-
this.
|
|
11006
|
+
this.invalidateLayout();
|
|
10556
11007
|
}
|
|
10557
11008
|
get showBorders() {
|
|
10558
11009
|
return this._showBorders;
|
|
@@ -10561,7 +11012,7 @@ class TextTableRenderable extends Renderable2 {
|
|
|
10561
11012
|
if (this._showBorders === value)
|
|
10562
11013
|
return;
|
|
10563
11014
|
this._showBorders = value;
|
|
10564
|
-
this.
|
|
11015
|
+
this.requestRender();
|
|
10565
11016
|
}
|
|
10566
11017
|
get outerBorder() {
|
|
10567
11018
|
return this._outerBorder;
|
|
@@ -10574,7 +11025,7 @@ class TextTableRenderable extends Renderable2 {
|
|
|
10574
11025
|
return;
|
|
10575
11026
|
this._hasExplicitOuterBorder = value != null;
|
|
10576
11027
|
this._outerBorder = next;
|
|
10577
|
-
this.
|
|
11028
|
+
this.invalidateLayout();
|
|
10578
11029
|
}
|
|
10579
11030
|
get border() {
|
|
10580
11031
|
return this._border;
|
|
@@ -10586,7 +11037,7 @@ class TextTableRenderable extends Renderable2 {
|
|
|
10586
11037
|
if (!this._hasExplicitOuterBorder) {
|
|
10587
11038
|
this._outerBorder = value;
|
|
10588
11039
|
}
|
|
10589
|
-
this.
|
|
11040
|
+
this.invalidateLayout();
|
|
10590
11041
|
}
|
|
10591
11042
|
get borderStyle() {
|
|
10592
11043
|
return this._borderStyle;
|
|
@@ -10596,14 +11047,14 @@ class TextTableRenderable extends Renderable2 {
|
|
|
10596
11047
|
if (this._borderStyle === next)
|
|
10597
11048
|
return;
|
|
10598
11049
|
this._borderStyle = next;
|
|
10599
|
-
this.
|
|
11050
|
+
this.requestRender();
|
|
10600
11051
|
}
|
|
10601
11052
|
get borderColor() {
|
|
10602
11053
|
return RGBA2.clone(this._borderColor);
|
|
10603
11054
|
}
|
|
10604
11055
|
set borderColor(value) {
|
|
10605
11056
|
this._borderColor = RGBA2.clone(parseColor2(value ?? this._defaultOptions.borderColor));
|
|
10606
|
-
this.
|
|
11057
|
+
this.requestRender();
|
|
10607
11058
|
}
|
|
10608
11059
|
get fg() {
|
|
10609
11060
|
return this._defaultFg;
|
|
@@ -10618,7 +11069,7 @@ class TextTableRenderable extends Renderable2 {
|
|
|
10618
11069
|
cell.textBuffer.setDefaultFg(next);
|
|
10619
11070
|
}
|
|
10620
11071
|
}
|
|
10621
|
-
this.
|
|
11072
|
+
this.requestRender();
|
|
10622
11073
|
}
|
|
10623
11074
|
shouldStartSelection(x, y) {
|
|
10624
11075
|
if (!this.selectable)
|
|
@@ -10630,19 +11081,15 @@ class TextTableRenderable extends Renderable2 {
|
|
|
10630
11081
|
}
|
|
10631
11082
|
onSelectionChanged(selection) {
|
|
10632
11083
|
this.ensureLayoutReady();
|
|
10633
|
-
const previousLocalSelection = this._lastLocalSelection;
|
|
10634
11084
|
const localSelection = convertGlobalToLocalSelection2(selection, Math.trunc(this.x), Math.trunc(this.y));
|
|
10635
11085
|
this._lastLocalSelection = localSelection;
|
|
10636
|
-
const dirtyRows = this.getDirtySelectionRowRange(previousLocalSelection, localSelection);
|
|
10637
11086
|
if (!localSelection?.isActive) {
|
|
10638
11087
|
this.resetCellSelections();
|
|
10639
11088
|
this._lastSelectionMode = null;
|
|
10640
11089
|
} else {
|
|
10641
11090
|
this.applySelectionToCells(localSelection, selection?.isStart ?? false);
|
|
10642
11091
|
}
|
|
10643
|
-
|
|
10644
|
-
this.redrawSelectionRows(dirtyRows.firstRow, dirtyRows.lastRow);
|
|
10645
|
-
}
|
|
11092
|
+
this.requestRender();
|
|
10646
11093
|
return this.hasSelection();
|
|
10647
11094
|
}
|
|
10648
11095
|
hasSelection() {
|
|
@@ -10687,25 +11134,23 @@ class TextTableRenderable extends Renderable2 {
|
|
|
10687
11134
|
`);
|
|
10688
11135
|
}
|
|
10689
11136
|
onResize(width, height) {
|
|
10690
|
-
this.
|
|
11137
|
+
this.invalidateLayout(false);
|
|
10691
11138
|
super.onResize(width, height);
|
|
10692
11139
|
}
|
|
10693
11140
|
renderSelf(buffer) {
|
|
10694
11141
|
if (!this.visible || this.isDestroyed)
|
|
10695
11142
|
return;
|
|
10696
|
-
|
|
10697
|
-
|
|
10698
|
-
|
|
10699
|
-
if (
|
|
10700
|
-
|
|
10701
|
-
|
|
10702
|
-
|
|
10703
|
-
this._rasterDirty = false;
|
|
10704
|
-
return;
|
|
11143
|
+
this.ensureLayoutReady();
|
|
11144
|
+
const [x, y] = this._paintOrigin(buffer);
|
|
11145
|
+
buffer.pushScissorRect(x, y, this._paintWidth, this._paintHeight);
|
|
11146
|
+
if (buffer === this.frameBuffer)
|
|
11147
|
+
buffer.clear(this._backgroundColor);
|
|
11148
|
+
else if (this._backgroundColor.a > 0) {
|
|
11149
|
+
buffer.fillRect(x, y, this._paintWidth, this._paintHeight, this._backgroundColor);
|
|
10705
11150
|
}
|
|
10706
|
-
this.drawBorders(buffer);
|
|
10707
|
-
this.drawCells(buffer);
|
|
10708
|
-
|
|
11151
|
+
this.drawBorders(buffer, x, y);
|
|
11152
|
+
this.drawCells(buffer, x, y);
|
|
11153
|
+
buffer.popScissorRect();
|
|
10709
11154
|
}
|
|
10710
11155
|
destroySelf() {
|
|
10711
11156
|
this.destroyCells();
|
|
@@ -10791,7 +11236,7 @@ class TextTableRenderable extends Renderable2 {
|
|
|
10791
11236
|
this._rowCount = newRowCount;
|
|
10792
11237
|
this._columnCount = newColumnCount;
|
|
10793
11238
|
this.runCleanup((run) => {
|
|
10794
|
-
run(() => this.
|
|
11239
|
+
run(() => this.invalidateLayout());
|
|
10795
11240
|
for (let rowIdx = 0;rowIdx < previous.length; rowIdx++) {
|
|
10796
11241
|
for (let colIdx = 0;colIdx < previous[rowIdx].length; colIdx++) {
|
|
10797
11242
|
const cell = previous[rowIdx][colIdx];
|
|
@@ -11091,7 +11536,7 @@ class TextTableRenderable extends Renderable2 {
|
|
|
11091
11536
|
getHorizontalBorderCount(borderLayout) {
|
|
11092
11537
|
return (borderLayout.top ? 1 : 0) + (borderLayout.bottom ? 1 : 0) + (borderLayout.innerHorizontal ? Math.max(0, this._rowCount - 1) : 0);
|
|
11093
11538
|
}
|
|
11094
|
-
drawBorders(buffer) {
|
|
11539
|
+
drawBorders(buffer, x, y) {
|
|
11095
11540
|
if (!this._showBorders) {
|
|
11096
11541
|
return;
|
|
11097
11542
|
}
|
|
@@ -11099,59 +11544,31 @@ class TextTableRenderable extends Renderable2 {
|
|
|
11099
11544
|
if (this.getVerticalBorderCount(borderLayout) === 0 && this.getHorizontalBorderCount(borderLayout) === 0) {
|
|
11100
11545
|
return;
|
|
11101
11546
|
}
|
|
11547
|
+
const { columnOffsets, rowOffsets, columnOffsetsI32, rowOffsetsI32 } = this._layout;
|
|
11548
|
+
columnOffsets.forEach((offset, index) => columnOffsetsI32[index] = offset + x);
|
|
11549
|
+
rowOffsets.forEach((offset, index) => rowOffsetsI32[index] = offset + y);
|
|
11102
11550
|
buffer.drawGrid({
|
|
11103
11551
|
borderChars: BorderCharArrays2[this._borderStyle],
|
|
11104
11552
|
borderFg: this._borderColor,
|
|
11105
11553
|
borderBg: this._borderBackgroundColor,
|
|
11106
|
-
columnOffsets:
|
|
11107
|
-
rowOffsets:
|
|
11554
|
+
columnOffsets: columnOffsetsI32,
|
|
11555
|
+
rowOffsets: rowOffsetsI32,
|
|
11108
11556
|
drawInner: this._border,
|
|
11109
11557
|
drawOuter: this._outerBorder
|
|
11110
11558
|
});
|
|
11111
11559
|
}
|
|
11112
|
-
drawCells(buffer) {
|
|
11113
|
-
this.drawCellRange(buffer, 0, this._rowCount - 1);
|
|
11114
|
-
}
|
|
11115
|
-
drawCellRange(buffer, firstRow, lastRow) {
|
|
11560
|
+
drawCells(buffer, x, y) {
|
|
11116
11561
|
const colOffsets = this._layout.columnOffsets;
|
|
11117
11562
|
const rowOffsets = this._layout.rowOffsets;
|
|
11118
|
-
const
|
|
11563
|
+
const cellX = x + 1 + this._cellPaddingX;
|
|
11119
11564
|
const cellPaddingY = this._cellPaddingY;
|
|
11120
|
-
for (let rowIdx =
|
|
11121
|
-
const cellY = (rowOffsets[rowIdx] ?? 0) + 1 + cellPaddingY;
|
|
11565
|
+
for (let rowIdx = 0;rowIdx < this._rowCount; rowIdx++) {
|
|
11566
|
+
const cellY = y + (rowOffsets[rowIdx] ?? 0) + 1 + cellPaddingY;
|
|
11122
11567
|
for (let colIdx = 0;colIdx < this._columnCount; colIdx++) {
|
|
11123
11568
|
const cell = this._cells[rowIdx]?.[colIdx];
|
|
11124
11569
|
if (!cell)
|
|
11125
11570
|
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);
|
|
11571
|
+
buffer.drawTextBuffer(cell.textBufferView, cellX + (colOffsets[colIdx] ?? 0), cellY);
|
|
11155
11572
|
}
|
|
11156
11573
|
}
|
|
11157
11574
|
}
|
|
@@ -11307,28 +11724,6 @@ class TextTableRenderable extends Renderable2 {
|
|
|
11307
11724
|
}
|
|
11308
11725
|
return this._rowCount - 1;
|
|
11309
11726
|
}
|
|
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
11727
|
resetRowSelection(rowIdx) {
|
|
11333
11728
|
const row = this._cells[rowIdx];
|
|
11334
11729
|
if (!row)
|
|
@@ -11387,9 +11782,8 @@ class TextTableRenderable extends Renderable2 {
|
|
|
11387
11782
|
}
|
|
11388
11783
|
return Math.max(0, Math.floor(value));
|
|
11389
11784
|
}
|
|
11390
|
-
|
|
11785
|
+
invalidateLayout(markYogaDirty = true) {
|
|
11391
11786
|
this._layoutDirty = true;
|
|
11392
|
-
this._rasterDirty = true;
|
|
11393
11787
|
this._cachedMeasureLayout = null;
|
|
11394
11788
|
this._cachedMeasureWidth = undefined;
|
|
11395
11789
|
if (markYogaDirty) {
|
|
@@ -11397,10 +11791,6 @@ class TextTableRenderable extends Renderable2 {
|
|
|
11397
11791
|
}
|
|
11398
11792
|
this.requestRender();
|
|
11399
11793
|
}
|
|
11400
|
-
invalidateRasterOnly() {
|
|
11401
|
-
this._rasterDirty = true;
|
|
11402
|
-
this.requestRender();
|
|
11403
|
-
}
|
|
11404
11794
|
}
|
|
11405
11795
|
|
|
11406
11796
|
// src/renderables/markdown-parser.ts
|
|
@@ -12229,13 +12619,16 @@ class MarkdownRenderable extends Renderable2 {
|
|
|
12229
12619
|
return this.createTableBlock(token, id).renderable;
|
|
12230
12620
|
return token.raw ? this.createMarkdownCodeRenderable(token.raw, id, 0, this._linkifyMarkdownChunks, undefined, this.createInitialStyledText(token)) : null;
|
|
12231
12621
|
}
|
|
12622
|
+
getHorizontalRuleColor() {
|
|
12623
|
+
return this.getStyle("conceal")?.fg ?? this._fg ?? "#888888";
|
|
12624
|
+
}
|
|
12232
12625
|
createHorizontalRuleRenderable(id, marginBottom = 0) {
|
|
12233
12626
|
return new BoxRenderable2(this.ctx, {
|
|
12234
12627
|
id,
|
|
12235
12628
|
width: "100%",
|
|
12236
12629
|
height: 1,
|
|
12237
12630
|
border: ["top"],
|
|
12238
|
-
borderColor: this.
|
|
12631
|
+
borderColor: this.getHorizontalRuleColor(),
|
|
12239
12632
|
flexShrink: 0,
|
|
12240
12633
|
marginBottom
|
|
12241
12634
|
});
|
|
@@ -12809,6 +13202,8 @@ class MarkdownRenderable extends Renderable2 {
|
|
|
12809
13202
|
return;
|
|
12810
13203
|
}
|
|
12811
13204
|
if (token.type === "hr") {
|
|
13205
|
+
if (state.renderable instanceof BoxRenderable2)
|
|
13206
|
+
state.renderable.borderColor = this.getHorizontalRuleColor();
|
|
12812
13207
|
state.renderable.marginBottom = marginBottom;
|
|
12813
13208
|
return;
|
|
12814
13209
|
}
|
|
@@ -12844,12 +13239,13 @@ class MarkdownRenderable extends Renderable2 {
|
|
|
12844
13239
|
state.tableContentCache = cache;
|
|
12845
13240
|
return;
|
|
12846
13241
|
}
|
|
13242
|
+
const raw = this._internalBlockMode === "top-level" ? this.getTopLevelBlockRaw(token) ?? token.raw : token.raw;
|
|
12847
13243
|
if (state.renderable instanceof CodeRenderable2) {
|
|
12848
|
-
this.applyMarkdownCodeRenderable(state.renderable,
|
|
13244
|
+
this.applyMarkdownCodeRenderable(state.renderable, raw, marginBottom, undefined, this.createInitialStyledText(token));
|
|
12849
13245
|
return;
|
|
12850
13246
|
}
|
|
12851
13247
|
state.renderable.destroyRecursively();
|
|
12852
|
-
const markdownRenderable = this.createMarkdownCodeRenderable(
|
|
13248
|
+
const markdownRenderable = this.createMarkdownCodeRenderable(raw, `${this.id}-block-${index}`, marginBottom, this._linkifyMarkdownChunks, undefined, this.createInitialStyledText(token));
|
|
12853
13249
|
this.add(markdownRenderable, index);
|
|
12854
13250
|
state.renderable = markdownRenderable;
|
|
12855
13251
|
}
|
|
@@ -12876,7 +13272,7 @@ class MarkdownRenderable extends Renderable2 {
|
|
|
12876
13272
|
blockIndex++;
|
|
12877
13273
|
continue;
|
|
12878
13274
|
}
|
|
12879
|
-
if (existing && existing.canUpdateInPlace && existing.token.type === block.token.type &&
|
|
13275
|
+
if (existing && existing.canUpdateInPlace && existing.token.type === block.token.type && (block.token.type !== "table" || block.token.rows.length > 0 === existing.renderable instanceof TextTableRenderable)) {
|
|
12880
13276
|
if (this._renderNode) {
|
|
12881
13277
|
const custom = this.createTopLevelCustomRenderable(block, blockIndex);
|
|
12882
13278
|
if (custom.renderable && !custom.canUpdateInPlace) {
|
|
@@ -12930,19 +13326,6 @@ class MarkdownRenderable extends Renderable2 {
|
|
|
12930
13326
|
removed.renderable.destroyRecursively();
|
|
12931
13327
|
}
|
|
12932
13328
|
}
|
|
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
13329
|
updateBlocks(forceTableRefresh = false) {
|
|
12947
13330
|
if (this.isDestroyed)
|
|
12948
13331
|
return;
|
|
@@ -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
|
-
const shouldForceRefresh = forceTableRefresh;
|
|
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
13369
|
if (existing && existing.tokenRaw === token.raw && existing.token.type === token.type) {
|
|
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
|
}
|
|
@@ -13088,60 +13459,7 @@ class MarkdownRenderable extends Renderable2 {
|
|
|
13088
13459
|
}
|
|
13089
13460
|
for (let i = 0;i < this._blockStates.length; i++) {
|
|
13090
13461
|
const state = this._blockStates[i];
|
|
13091
|
-
|
|
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;
|
|
13462
|
+
this.updateBlockRenderable(state, state.token, i, this._blockStates[i + 1]?.token, true);
|
|
13145
13463
|
}
|
|
13146
13464
|
}
|
|
13147
13465
|
clearCache() {
|
|
@@ -14320,7 +14638,7 @@ class ScrollBoxRenderable extends BoxRenderable2 {
|
|
|
14320
14638
|
horizontalScrollBar;
|
|
14321
14639
|
verticalScrollBar;
|
|
14322
14640
|
static defaultFocusable = true;
|
|
14323
|
-
selectionListener;
|
|
14641
|
+
selectionListener = () => this.stopAutoScroll();
|
|
14324
14642
|
autoScrollMouseX = 0;
|
|
14325
14643
|
autoScrollMouseY = 0;
|
|
14326
14644
|
autoScrollThresholdVertical = 3;
|
|
@@ -14455,15 +14773,6 @@ class ScrollBoxRenderable extends BoxRenderable2 {
|
|
|
14455
14773
|
this._applyScrollArrows(1);
|
|
14456
14774
|
this.content._assign({ ...forwardedContentPadding, ...contentOptions }, ScrollBoxContent.keys);
|
|
14457
14775
|
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
14776
|
this.setNativeScenePaint();
|
|
14468
14777
|
} catch (error) {
|
|
14469
14778
|
this.abortConstruction(error, (run) => run(() => this.destroySelf()));
|
|
@@ -14767,12 +15076,15 @@ class ScrollBoxRenderable extends BoxRenderable2 {
|
|
|
14767
15076
|
this.scrollAccumulatorY = 0;
|
|
14768
15077
|
}
|
|
14769
15078
|
startAutoScroll(mouseX, mouseY) {
|
|
15079
|
+
if (this.isDestroyed)
|
|
15080
|
+
return;
|
|
14770
15081
|
this.stopAutoScroll();
|
|
14771
15082
|
this.autoScrollMouseX = mouseX;
|
|
14772
15083
|
this.autoScrollMouseY = mouseY;
|
|
14773
15084
|
this.cachedAutoScrollSpeed = this.getAutoScrollSpeed(mouseX, mouseY);
|
|
14774
15085
|
this.isAutoScrolling = true;
|
|
14775
15086
|
this.live = true;
|
|
15087
|
+
this._ctx.on("selection", this.selectionListener);
|
|
14776
15088
|
this.refreshNativeSceneHooks();
|
|
14777
15089
|
}
|
|
14778
15090
|
updateAutoScroll(mouseX, mouseY) {
|
|
@@ -14793,6 +15105,7 @@ class ScrollBoxRenderable extends BoxRenderable2 {
|
|
|
14793
15105
|
this.autoScrollAccumulatorX = 0;
|
|
14794
15106
|
this.autoScrollAccumulatorY = 0;
|
|
14795
15107
|
if (wasAutoScrolling) {
|
|
15108
|
+
this._ctx.off("selection", this.selectionListener);
|
|
14796
15109
|
this.live = false;
|
|
14797
15110
|
this.refreshNativeSceneHooks();
|
|
14798
15111
|
}
|
|
@@ -14916,13 +15229,10 @@ class ScrollBoxRenderable extends BoxRenderable2 {
|
|
|
14916
15229
|
destroySelf() {
|
|
14917
15230
|
if (!this.isFreed())
|
|
14918
15231
|
this._scrollState();
|
|
14919
|
-
const selectionListener = this.selectionListener;
|
|
14920
|
-
this.selectionListener = undefined;
|
|
14921
15232
|
this.layoutCallbacks = [];
|
|
14922
15233
|
this.endBarPress();
|
|
14923
15234
|
this.runCleanup((run) => {
|
|
14924
|
-
|
|
14925
|
-
run(() => this._ctx.off("selection", selectionListener));
|
|
15235
|
+
run(() => this._ctx.off("selection", this.selectionListener));
|
|
14926
15236
|
run(() => super.destroySelf());
|
|
14927
15237
|
});
|
|
14928
15238
|
}
|
|
@@ -14936,6 +15246,8 @@ for (const key of SCROLLBOX_PADDING_KEYS) {
|
|
|
14936
15246
|
});
|
|
14937
15247
|
}
|
|
14938
15248
|
// src/renderables/Select.ts
|
|
15249
|
+
var transparent2 = RGBA2.fromValues(0, 0, 0, 0);
|
|
15250
|
+
var indicatorColor = parseColor2("#666666");
|
|
14939
15251
|
var defaultSelectKeybindings = [
|
|
14940
15252
|
{ name: "up", action: "move-up" },
|
|
14941
15253
|
{ name: "k", action: "move-up" },
|
|
@@ -14996,7 +15308,7 @@ class SelectRenderable extends Renderable2 {
|
|
|
14996
15308
|
fastScrollStep: 5
|
|
14997
15309
|
};
|
|
14998
15310
|
constructor(ctx, options) {
|
|
14999
|
-
super(ctx,
|
|
15311
|
+
super(ctx, options);
|
|
15000
15312
|
try {
|
|
15001
15313
|
this._options = options.options || [];
|
|
15002
15314
|
const requestedIndex = options.selectedIndex ?? this._defaultOptions.selectedIndex;
|
|
@@ -15029,74 +15341,65 @@ class SelectRenderable extends Renderable2 {
|
|
|
15029
15341
|
}
|
|
15030
15342
|
}
|
|
15031
15343
|
renderSelf(buffer, deltaTime) {
|
|
15032
|
-
|
|
15033
|
-
|
|
15034
|
-
|
|
15035
|
-
this.refreshFrameBuffer();
|
|
15036
|
-
}
|
|
15037
|
-
}
|
|
15038
|
-
refreshFrameBuffer() {
|
|
15039
|
-
if (!this.frameBuffer)
|
|
15040
|
-
return;
|
|
15344
|
+
const [x, y] = this._paintOrigin(buffer);
|
|
15345
|
+
const width = this._paintWidth;
|
|
15346
|
+
const height = this._paintHeight;
|
|
15041
15347
|
const bgColor = this._focused ? this._focusedBackgroundColor : this._backgroundColor;
|
|
15042
|
-
this.
|
|
15043
|
-
|
|
15044
|
-
|
|
15045
|
-
const
|
|
15046
|
-
const
|
|
15047
|
-
const
|
|
15048
|
-
const
|
|
15348
|
+
const selectedY = (this._selectedIndex - this.scrollOffset) * this.linesPerItem;
|
|
15349
|
+
const selectedHeight = this.linesPerItem - this._itemSpacing;
|
|
15350
|
+
const hole = this._options.length > 0 && selectedY + this.linesPerItem <= height && this._selectedBackgroundColor.a === 1;
|
|
15351
|
+
const top = hole ? selectedY : height;
|
|
15352
|
+
const bottom = hole ? selectedY + selectedHeight : height;
|
|
15353
|
+
const scrolls = this._showScrollIndicator && this._options.length > this.maxVisibleItems;
|
|
15354
|
+
const scrollPercent = this.scrollOffset / (this._options.length - this.maxVisibleItems);
|
|
15355
|
+
const indicatorY = scrolls ? y + 1 + Math.floor(scrollPercent * Math.max(1, height - 2)) : -1;
|
|
15356
|
+
const draw = (text, textX, textY, color) => {
|
|
15357
|
+
const end = textY === indicatorY ? x + width - 1 : x + width;
|
|
15358
|
+
buffer.drawTextFit(text, textX, textY, end - textX, color, transparent2);
|
|
15359
|
+
};
|
|
15360
|
+
buffer.pushScissorRect(x, y, width, height);
|
|
15361
|
+
if (buffer === this.frameBuffer)
|
|
15362
|
+
buffer.clear(bgColor);
|
|
15363
|
+
else {
|
|
15364
|
+
buffer.fillRect(x, y, width, top, bgColor);
|
|
15365
|
+
buffer.fillRect(x, y + bottom, width, height - bottom, bgColor);
|
|
15366
|
+
}
|
|
15049
15367
|
const visibleOptions = this._options.slice(this.scrollOffset, this.scrollOffset + this.maxVisibleItems);
|
|
15050
15368
|
for (let i = 0;i < visibleOptions.length; i++) {
|
|
15051
|
-
const actualIndex = this.scrollOffset + i;
|
|
15052
15369
|
const option = visibleOptions[i];
|
|
15053
|
-
const isSelected =
|
|
15054
|
-
const itemY =
|
|
15055
|
-
if (itemY + this.linesPerItem - 1 >=
|
|
15370
|
+
const isSelected = this.scrollOffset + i === this._selectedIndex;
|
|
15371
|
+
const itemY = y + i * this.linesPerItem;
|
|
15372
|
+
if (itemY + this.linesPerItem - 1 >= y + height)
|
|
15056
15373
|
break;
|
|
15057
15374
|
if (isSelected) {
|
|
15058
|
-
|
|
15059
|
-
this.frameBuffer.fillRect(contentX, itemY, contentWidth, contentHeight, this._selectedBackgroundColor);
|
|
15375
|
+
buffer.fillRect(x, itemY, width, selectedHeight, this._selectedBackgroundColor);
|
|
15060
15376
|
}
|
|
15061
15377
|
const indicator = this._showSelectionIndicator ? isSelected ? "\u25B6 " : " " : "";
|
|
15062
|
-
const indicatorWidth = this._showSelectionIndicator ? 2 : 0;
|
|
15063
|
-
const nameContent = `${indicator}${option.name}`;
|
|
15064
15378
|
const baseTextColor = this._focused ? this._focusedTextColor : this._textColor;
|
|
15065
15379
|
const nameColor = isSelected ? this._selectedTextColor : baseTextColor;
|
|
15066
|
-
const textX =
|
|
15380
|
+
const textX = x + 1 + (this._showSelectionIndicator ? 2 : 0);
|
|
15067
15381
|
if (this._font) {
|
|
15068
|
-
if (indicator)
|
|
15069
|
-
|
|
15070
|
-
|
|
15071
|
-
renderFontToFrameBuffer2(this.frameBuffer, {
|
|
15382
|
+
if (indicator)
|
|
15383
|
+
draw(indicator, x + 1, itemY, nameColor);
|
|
15384
|
+
renderFontToFrameBuffer2(buffer, {
|
|
15072
15385
|
text: option.name,
|
|
15073
15386
|
x: textX,
|
|
15074
15387
|
y: itemY,
|
|
15075
15388
|
color: nameColor,
|
|
15076
|
-
backgroundColor:
|
|
15389
|
+
backgroundColor: transparent2,
|
|
15077
15390
|
font: this._font
|
|
15078
15391
|
});
|
|
15079
15392
|
} else {
|
|
15080
|
-
|
|
15393
|
+
draw(`${indicator}${option.name}`, x + 1, itemY, nameColor);
|
|
15081
15394
|
}
|
|
15082
|
-
if (this._showDescription && itemY + this.fontHeight <
|
|
15395
|
+
if (this._showDescription && itemY + this.fontHeight < y + height) {
|
|
15083
15396
|
const descColor = isSelected ? this._selectedDescriptionColor : this._descriptionColor;
|
|
15084
|
-
|
|
15397
|
+
draw(option.description, textX, itemY + this.fontHeight, descColor);
|
|
15085
15398
|
}
|
|
15086
15399
|
}
|
|
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"));
|
|
15400
|
+
if (scrolls)
|
|
15401
|
+
buffer.drawText("\u2588", x + width - 1, indicatorY, indicatorColor, transparent2);
|
|
15402
|
+
buffer.popScissorRect();
|
|
15100
15403
|
}
|
|
15101
15404
|
get options() {
|
|
15102
15405
|
return this._options;
|
|
@@ -15297,6 +15600,8 @@ class SelectRenderable extends Renderable2 {
|
|
|
15297
15600
|
}
|
|
15298
15601
|
}
|
|
15299
15602
|
// src/renderables/TabSelect.ts
|
|
15603
|
+
var transparent3 = RGBA2.fromValues(0, 0, 0, 0);
|
|
15604
|
+
var arrowColor = parseColor2("#AAAAAA");
|
|
15300
15605
|
var defaultTabSelectKeybindings = [
|
|
15301
15606
|
{ name: "left", action: "move-left" },
|
|
15302
15607
|
{ name: "[", action: "move-left" },
|
|
@@ -15353,7 +15658,7 @@ class TabSelectRenderable extends Renderable2 {
|
|
|
15353
15658
|
_keyBindings;
|
|
15354
15659
|
constructor(ctx, options) {
|
|
15355
15660
|
const calculatedHeight = calculateDynamicHeight(options.showUnderline ?? true, options.showDescription ?? true);
|
|
15356
|
-
super(ctx, { ...options, height: calculatedHeight
|
|
15661
|
+
super(ctx, { ...options, height: calculatedHeight });
|
|
15357
15662
|
try {
|
|
15358
15663
|
this._backgroundColor = RGBA2.clone(parseColor2(options.backgroundColor || defaultColors2.backgroundColor));
|
|
15359
15664
|
this._hasBackgroundColor = !!options.backgroundColor;
|
|
@@ -15385,71 +15690,52 @@ class TabSelectRenderable extends Renderable2 {
|
|
|
15385
15690
|
return kind === "height" ? this.calculateDynamicHeight() : super.defaultDimension(kind);
|
|
15386
15691
|
}
|
|
15387
15692
|
renderSelf(buffer, deltaTime) {
|
|
15388
|
-
|
|
15389
|
-
|
|
15390
|
-
|
|
15391
|
-
this.refreshFrameBuffer();
|
|
15392
|
-
}
|
|
15393
|
-
}
|
|
15394
|
-
refreshFrameBuffer() {
|
|
15395
|
-
if (!this.frameBuffer)
|
|
15396
|
-
return;
|
|
15693
|
+
const [x, y] = this._paintOrigin(buffer);
|
|
15694
|
+
const width = this._paintWidth;
|
|
15695
|
+
const height = this._paintHeight;
|
|
15397
15696
|
const bgColor = this._focused ? this._focusedBackgroundColor : this._backgroundColor;
|
|
15398
|
-
this.
|
|
15399
|
-
|
|
15400
|
-
|
|
15401
|
-
const
|
|
15402
|
-
const
|
|
15403
|
-
|
|
15404
|
-
|
|
15697
|
+
const selectedX = (this.selectedIndex - this.scrollOffset) * this._tabWidth;
|
|
15698
|
+
const selectedWidth = Math.min(this._tabWidth, width - selectedX);
|
|
15699
|
+
const selectedRows = this._showUnderline && height >= 2 ? 2 : 1;
|
|
15700
|
+
const hole = this._options.length > 0 && selectedX < width && this._selectedBackgroundColor.a === 1;
|
|
15701
|
+
const rows = hole ? selectedRows : 0;
|
|
15702
|
+
if (buffer === this.frameBuffer)
|
|
15703
|
+
buffer.clear(bgColor);
|
|
15704
|
+
else {
|
|
15705
|
+
buffer.fillRect(x, y, selectedX, rows, bgColor);
|
|
15706
|
+
buffer.fillRect(x + selectedX + selectedWidth, y, width - selectedX - selectedWidth, rows, bgColor);
|
|
15707
|
+
buffer.fillRect(x, y + rows, width, height - rows, bgColor);
|
|
15708
|
+
}
|
|
15405
15709
|
const visibleOptions = this._options.slice(this.scrollOffset, this.scrollOffset + this.maxVisibleTabs);
|
|
15406
15710
|
for (let i = 0;i < visibleOptions.length; i++) {
|
|
15407
|
-
const actualIndex = this.scrollOffset + i;
|
|
15408
15711
|
const option = visibleOptions[i];
|
|
15409
|
-
const isSelected =
|
|
15410
|
-
const tabX =
|
|
15411
|
-
if (tabX >=
|
|
15712
|
+
const isSelected = this.scrollOffset + i === this.selectedIndex;
|
|
15713
|
+
const tabX = x + i * this._tabWidth;
|
|
15714
|
+
if (tabX >= x + width)
|
|
15412
15715
|
break;
|
|
15413
|
-
const actualTabWidth = Math.min(this._tabWidth,
|
|
15414
|
-
if (isSelected) {
|
|
15415
|
-
this.frameBuffer.fillRect(tabX, contentY, actualTabWidth, 1, this._selectedBackgroundColor);
|
|
15416
|
-
}
|
|
15716
|
+
const actualTabWidth = Math.min(this._tabWidth, width - i * this._tabWidth);
|
|
15417
15717
|
const baseTextColor = this._focused ? this._focusedTextColor : this._textColor;
|
|
15418
15718
|
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);
|
|
15719
|
+
if (isSelected) {
|
|
15720
|
+
buffer.fillRect(tabX, y, actualTabWidth, selectedRows, this._selectedBackgroundColor);
|
|
15423
15721
|
}
|
|
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);
|
|
15722
|
+
buffer.drawTextFit(option.name, tabX + 1, y, actualTabWidth - 2, nameColor, transparent3, true);
|
|
15723
|
+
if (isSelected && selectedRows === 2) {
|
|
15724
|
+
buffer.drawText("\u25AC".repeat(actualTabWidth), tabX, y + 1, nameColor, transparent3);
|
|
15432
15725
|
}
|
|
15433
15726
|
}
|
|
15434
|
-
|
|
15435
|
-
|
|
15727
|
+
const selectedOption = this.getSelectedOption();
|
|
15728
|
+
if (selectedOption && this._showDescription && height >= (this._showUnderline ? 3 : 2)) {
|
|
15729
|
+
const descriptionY = y + (this._showUnderline ? 2 : 1);
|
|
15730
|
+
const description = selectedOption.description;
|
|
15731
|
+
buffer.drawTextFit(description, x + 1, descriptionY, width - 2, this._selectedDescriptionColor, transparent3, true);
|
|
15436
15732
|
}
|
|
15437
|
-
|
|
15438
|
-
|
|
15439
|
-
|
|
15440
|
-
|
|
15441
|
-
|
|
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"));
|
|
15450
|
-
}
|
|
15451
|
-
if (hasMoreRight) {
|
|
15452
|
-
this.frameBuffer.drawText("\u203A", contentX + contentWidth - 1, contentY, parseColor2("#AAAAAA"));
|
|
15733
|
+
if (this._showScrollArrows && this._options.length > this.maxVisibleTabs) {
|
|
15734
|
+
if (this.scrollOffset > 0)
|
|
15735
|
+
buffer.drawText("\u2039", x, y, arrowColor, transparent3);
|
|
15736
|
+
if (this.scrollOffset + this.maxVisibleTabs < this._options.length) {
|
|
15737
|
+
buffer.drawText("\u203A", x + width - 1, y, arrowColor, transparent3);
|
|
15738
|
+
}
|
|
15453
15739
|
}
|
|
15454
15740
|
}
|
|
15455
15741
|
setOptions(options) {
|
|
@@ -15634,28 +15920,19 @@ class TabSelectRenderable extends Renderable2 {
|
|
|
15634
15920
|
}
|
|
15635
15921
|
}
|
|
15636
15922
|
// src/renderables/TimeToFirstDraw.ts
|
|
15637
|
-
var
|
|
15638
|
-
function
|
|
15923
|
+
var transparent4 = RGBA2.fromValues(0, 0, 0, 0);
|
|
15924
|
+
function fittedWidth(buffer, text, maxWidth) {
|
|
15925
|
+
if (/^[\x20-\x7e]*$/.test(text))
|
|
15926
|
+
return Math.min(text.length, maxWidth);
|
|
15639
15927
|
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)
|
|
15928
|
+
let width = 0;
|
|
15929
|
+
for (const glyph of encoded.data) {
|
|
15930
|
+
if (width + glyph.width > maxWidth)
|
|
15654
15931
|
break;
|
|
15655
|
-
|
|
15656
|
-
visibleWidth += segmentWidth;
|
|
15932
|
+
width += glyph.width;
|
|
15657
15933
|
}
|
|
15658
|
-
|
|
15934
|
+
buffer.freeUnicode(encoded);
|
|
15935
|
+
return width;
|
|
15659
15936
|
}
|
|
15660
15937
|
|
|
15661
15938
|
class TimeToFirstDrawRenderable extends Renderable2 {
|
|
@@ -15713,10 +15990,9 @@ class TimeToFirstDrawRenderable extends Renderable2 {
|
|
|
15713
15990
|
}
|
|
15714
15991
|
const content = `${this.label}: ${this._runtimeMs.toFixed(this.precision)}ms`;
|
|
15715
15992
|
const maxWidth = Math.max(this.width, 1);
|
|
15716
|
-
const visibleContent = truncateToCellWidth(buffer, content, maxWidth);
|
|
15717
15993
|
const [x, y] = this._paintOrigin(buffer);
|
|
15718
|
-
const
|
|
15719
|
-
buffer.
|
|
15994
|
+
const width = fittedWidth(buffer, content, maxWidth);
|
|
15995
|
+
buffer.drawTextFit(content, x + Math.floor((maxWidth - width) / 2), y, width, this.textColor, transparent4);
|
|
15720
15996
|
}
|
|
15721
15997
|
normalizePrecision(value) {
|
|
15722
15998
|
if (!Number.isFinite(value)) {
|
|
@@ -15886,6 +16162,7 @@ export {
|
|
|
15886
16162
|
Timeline2 as Timeline,
|
|
15887
16163
|
TreeSitterClient2 as TreeSitterClient,
|
|
15888
16164
|
VRenderable,
|
|
16165
|
+
VideoRenderable,
|
|
15889
16166
|
VignetteEffect,
|
|
15890
16167
|
exports_yoga as Yoga,
|
|
15891
16168
|
acquireSessionBufferLease2 as acquireSessionBufferLease,
|
|
@@ -15926,6 +16203,7 @@ export {
|
|
|
15926
16203
|
buildKittyKeyboardFlags2 as buildKittyKeyboardFlags,
|
|
15927
16204
|
buildTerminalPaletteSignature2 as buildTerminalPaletteSignature,
|
|
15928
16205
|
capture2 as capture,
|
|
16206
|
+
checkCrop2 as checkCrop,
|
|
15929
16207
|
clearEnvCache2 as clearEnvCache,
|
|
15930
16208
|
convertGlobalToLocalSelection2 as convertGlobalToLocalSelection,
|
|
15931
16209
|
convertThemeToStyles,
|
|
@@ -16020,6 +16298,7 @@ export {
|
|
|
16020
16298
|
resolveRenderLib2 as resolveRenderLib,
|
|
16021
16299
|
reverse2 as reverse,
|
|
16022
16300
|
rgbToHex2 as rgbToHex,
|
|
16301
|
+
sameCrop2 as sameCrop,
|
|
16023
16302
|
scrollUnitSize,
|
|
16024
16303
|
setRenderLibPath2 as setRenderLibPath,
|
|
16025
16304
|
setupAudio,
|
|
@@ -16038,5 +16317,5 @@ export {
|
|
|
16038
16317
|
yellow2 as yellow
|
|
16039
16318
|
};
|
|
16040
16319
|
|
|
16041
|
-
//# debugId=
|
|
16320
|
+
//# debugId=3FC176E86CAEA33964756E2164756E21
|
|
16042
16321
|
//# sourceMappingURL=index.bun.js.map
|