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