@opentui/core 0.7.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.
Files changed (54) hide show
  1. package/NativeScene.d.ts +18 -4
  2. package/NativeSession.d.ts +22 -2
  3. package/Renderable.d.ts +20 -2
  4. package/animation/Timeline.d.ts +9 -0
  5. package/buffer.d.ts +8 -2
  6. package/{chunk-bun-zevtbcf6.js → chunk-bun-ved2tpxm.js} +834 -320
  7. package/chunk-bun-ved2tpxm.js.map +70 -0
  8. package/{chunk-bun-qkpm62w1.js → chunk-bun-wdetc10w.js} +483 -29
  9. package/chunk-bun-wdetc10w.js.map +35 -0
  10. package/{chunk-node-mzgnr3sw.js → chunk-node-m8mjyx7h.js} +483 -29
  11. package/chunk-node-m8mjyx7h.js.map +34 -0
  12. package/{chunk-node-7bcmqh18.js → chunk-node-tpjmjvn7.js} +834 -320
  13. package/chunk-node-tpjmjvn7.js.map +70 -0
  14. package/edit-buffer.d.ts +4 -0
  15. package/index.bun.js +1453 -859
  16. package/index.bun.js.map +15 -13
  17. package/index.d.ts +1 -1
  18. package/index.node.js +1453 -859
  19. package/index.node.js.map +16 -12
  20. package/lib/extmarks.d.ts +3 -1
  21. package/lib/stdin-parser-native.d.ts +2 -0
  22. package/lib/stdin-parser.d.ts +2 -0
  23. package/lib/terminal-capability-detection.d.ts +6 -1
  24. package/native-abi.generated.d.ts +478 -6
  25. package/package.json +9 -9
  26. package/renderables/FrameBuffer.d.ts +1 -0
  27. package/renderables/Image.d.ts +13 -1
  28. package/renderables/LineNumberRenderable.d.ts +1 -1
  29. package/renderables/Markdown.d.ts +1 -1
  30. package/renderables/ScrollBar.d.ts +6 -0
  31. package/renderables/ScrollBox.d.ts +84 -44
  32. package/renderables/ScrollBoxParts.d.ts +165 -0
  33. package/renderables/Select.d.ts +0 -2
  34. package/renderables/TabSelect.d.ts +0 -3
  35. package/renderables/TextTable.d.ts +1 -8
  36. package/renderables/Video.d.ts +126 -0
  37. package/renderables/index.d.ts +2 -1
  38. package/renderer-theme-mode.d.ts +1 -6
  39. package/renderer.d.ts +44 -5
  40. package/testing/test-renderer.d.ts +2 -0
  41. package/testing.bun.js +7 -6
  42. package/testing.bun.js.map +3 -3
  43. package/testing.js +7 -6
  44. package/testing.js.map +3 -3
  45. package/types.d.ts +11 -0
  46. package/yoga.bun.js +1 -1
  47. package/yoga.internal.d.ts +3 -3
  48. package/yoga.js +1 -1
  49. package/zig-structs.d.ts +1 -0
  50. package/zig.d.ts +132 -10
  51. package/chunk-bun-qkpm62w1.js.map +0 -35
  52. package/chunk-bun-zevtbcf6.js.map +0 -70
  53. package/chunk-node-7bcmqh18.js.map +0 -70
  54. package/chunk-node-mzgnr3sw.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,
@@ -66,6 +65,12 @@ import {
66
65
  bg2,
67
66
  link2,
68
67
  t2,
68
+ YogaEnumKind,
69
+ YogaFloatKind,
70
+ YogaValueKind,
71
+ sceneSetEnum,
72
+ sceneSetFloat,
73
+ sceneSetValue,
69
74
  SpanInfoStruct,
70
75
  NativeAudioStreamFormat2,
71
76
  NativeAudioStreamState2,
@@ -84,11 +89,13 @@ import {
84
89
  NativeEditorSelectionOperation2,
85
90
  NativeEditorPositionQuery2,
86
91
  NativeEditEvent2,
92
+ NativeStyleFlags,
87
93
  NATIVE_EDGE_NONE2,
88
94
  NativeBorder2,
89
95
  NativeSceneHook2,
90
96
  NativeSceneFrame2,
91
97
  NativeScenePaintPhase2,
98
+ emptySceneScrollState,
92
99
  NATIVE_BUFFER_TEXT_BYTES_MAX2,
93
100
  NativeSessionState2,
94
101
  NativeSessionRenderStatus2,
@@ -107,9 +114,12 @@ import {
107
114
  FFIRenderLib2,
108
115
  setRenderLibPath2,
109
116
  resolveRenderLib2,
117
+ Edge2,
118
+ FlexDirection2,
119
+ Gutter2,
110
120
  MeasureMode2,
111
121
  exports_yoga
112
- } from "./chunk-node-mzgnr3sw.js";
122
+ } from "./chunk-node-m8mjyx7h.js";
113
123
  import {
114
124
  isValidBorderStyle2,
115
125
  parseBorderStyle2,
@@ -217,6 +227,8 @@ import {
217
227
  NativeImage2,
218
228
  NativeImagePool2,
219
229
  resolveImageRenderProtocol2,
230
+ checkCrop2,
231
+ sameCrop2,
220
232
  ImageRenderable2,
221
233
  isTextNodeRenderable2,
222
234
  TextNodeRenderable2,
@@ -241,7 +253,7 @@ import {
241
253
  CliRenderEvents2,
242
254
  RendererControlState2,
243
255
  CliRenderer2
244
- } from "./chunk-node-7bcmqh18.js";
256
+ } from "./chunk-node-tpjmjvn7.js";
245
257
  // src/syntax-style.ts
246
258
  function cloneStyle(style) {
247
259
  return {
@@ -6075,6 +6087,7 @@ class VRenderable extends Renderable2 {
6075
6087
  // src/renderables/LineNumberRenderable.ts
6076
6088
  var DEFAULT_GUTTER_FG = "#888888";
6077
6089
  var DEFAULT_GUTTER_BG = "transparent";
6090
+ var transparent = RGBA2.fromValues(0, 0, 0, 0);
6078
6091
  function cloneLineSign(sign) {
6079
6092
  return {
6080
6093
  ...sign,
@@ -6097,8 +6110,8 @@ class GutterRenderable extends Renderable2 {
6097
6110
  _maxBeforeWidth = 0;
6098
6111
  _maxAfterWidth = 0;
6099
6112
  _lastKnownLineCount = 0;
6100
- _paintedSources;
6101
- _paintedSourceOffset = 0;
6113
+ _signWidths = new Map;
6114
+ _signWidthMethod;
6102
6115
  constructor(ctx, target, options) {
6103
6116
  super(ctx, {
6104
6117
  id: options.id,
@@ -6123,7 +6136,10 @@ class GutterRenderable extends Renderable2 {
6123
6136
  this.setupMeasureFunc();
6124
6137
  this.onLifecyclePass = () => {
6125
6138
  const currentLineCount = this.target.virtualLineCount;
6126
- if (currentLineCount !== this._lastKnownLineCount) {
6139
+ const signsStale = this._ctx.widthMethod !== this._signWidthMethod;
6140
+ if (signsStale)
6141
+ this.calculateSignWidths();
6142
+ if (currentLineCount !== this._lastKnownLineCount || signsStale) {
6127
6143
  this._lastKnownLineCount = currentLineCount;
6128
6144
  this.invalidateIntrinsicSize();
6129
6145
  this.requestRender();
@@ -6174,16 +6190,30 @@ class GutterRenderable extends Renderable2 {
6174
6190
  calculateSignWidths() {
6175
6191
  this._maxBeforeWidth = 0;
6176
6192
  this._maxAfterWidth = this._layout.minAfterWidth;
6193
+ this._signWidths.clear();
6194
+ this._signWidthMethod = this._ctx.widthMethod;
6177
6195
  for (const sign of this._lineSigns.values()) {
6178
- if (sign.before) {
6179
- const width = stringWidth(sign.before);
6180
- this._maxBeforeWidth = Math.max(this._maxBeforeWidth, width);
6181
- }
6182
- if (sign.after) {
6183
- const width = stringWidth(sign.after);
6184
- this._maxAfterWidth = Math.max(this._maxAfterWidth, width);
6185
- }
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);
6186
6214
  }
6215
+ this._signWidths.set(sign, width);
6216
+ return width;
6187
6217
  }
6188
6218
  calculateWidth() {
6189
6219
  const totalLines = Math.max(this.target.lineCount, this.target.virtualLineCount);
@@ -6239,81 +6269,48 @@ class GutterRenderable extends Renderable2 {
6239
6269
  getLineSigns() {
6240
6270
  return this._lineSigns;
6241
6271
  }
6242
- createFrameBuffer() {}
6243
- handleFrameBufferResize() {}
6244
6272
  renderSelf(buffer) {
6245
- const x = Math.trunc(this._screenX);
6246
- const y = Math.trunc(this._screenY);
6273
+ const [x, y] = this._paintOrigin(buffer);
6247
6274
  const start = Math.max(0, -y);
6248
6275
  const end = Math.min(this.height, buffer.height - y);
6249
6276
  if (end <= start || x >= buffer.width || x + this.width <= 0)
6250
6277
  return;
6251
- if (!this.frameBuffer) {
6252
- this.frameBuffer = OptimizedBuffer2.create(this.width, end - start, this._ctx.widthMethod, {
6253
- respectAlpha: true,
6254
- id: `framebuffer-${this.id}`,
6255
- owner: this._ctx.nativeScene
6256
- });
6257
- } else if (this.frameBuffer.width !== this.width || this.frameBuffer.height !== end - start) {
6258
- this.frameBuffer.resize(this.width, end - start);
6259
- this._paintedSources = undefined;
6260
- }
6261
- this.refreshFrameBuffer(this.frameBuffer, Math.trunc(this.target.scrollY) + start);
6262
- this.markClean();
6263
- buffer.drawFrameBuffer(x, y + start, this.frameBuffer);
6264
- }
6265
- refreshFrameBuffer(buffer, startLine) {
6278
+ const startLine = Math.trunc(this.target.scrollY) + start;
6266
6279
  const sourceStart = Math.max(0, startLine - 1);
6267
6280
  const sourceOffset = startLine - sourceStart;
6268
- const sources = getLineSources(this.target, sourceStart, buffer.height + sourceOffset);
6269
- const paintedSources = this._paintedSources;
6270
- if (!this.isDirty && sourceOffset === this._paintedSourceOffset && paintedSources && sources.length === paintedSources.length && sources.every((source, i) => source === paintedSources[i])) {
6271
- return;
6272
- }
6273
- buffer.clear(this._bg);
6281
+ const sources = getLineSources(this.target, sourceStart, end - start + sourceOffset);
6274
6282
  let lastSource = sourceOffset > 0 ? sources[0] : -1;
6275
- for (let i = 0;i < buffer.height; i++) {
6276
- const visualLineIndex = sourceOffset + i;
6277
- if (visualLineIndex >= sources.length)
6278
- break;
6279
- const logicalLine = sources[visualLineIndex];
6280
- const lineBg = this._lineColorsGutter.get(logicalLine) ?? this._bg;
6281
- if (lineBg !== this._bg) {
6282
- buffer.fillRect(0, i, this.width, 1, lineBg);
6283
- }
6284
- if (logicalLine === lastSource) {} else {
6285
- 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) {
6286
6292
  const sign = this._lineSigns.get(logicalLine);
6287
6293
  if (sign?.before) {
6288
- const beforeWidth = stringWidth(sign.before);
6289
- const padding = this._maxBeforeWidth - beforeWidth;
6290
- currentX += padding;
6294
+ const beforeX = x + this._maxBeforeWidth - this.signWidth(sign.before);
6291
6295
  const beforeColor = sign.beforeColor ? parseColor2(sign.beforeColor) : this._fg;
6292
- buffer.drawText(sign.before, currentX, i, beforeColor, lineBg);
6293
- currentX += beforeWidth;
6294
- } else if (this._maxBeforeWidth > 0) {
6295
- currentX += this._maxBeforeWidth;
6296
+ buffer.drawText(sign.before, beforeX, row, beforeColor, transparent);
6296
6297
  }
6297
6298
  if (!this._hideLineNumbers.has(logicalLine)) {
6298
6299
  const customLineNum = this._lineNumbers.get(logicalLine);
6299
- const lineNum = customLineNum !== undefined ? customLineNum : logicalLine + 1 + this._lineNumberOffset;
6300
- const lineNumStr = lineNum.toString();
6301
- const lineNumWidth = lineNumStr.length;
6302
- 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;
6303
6302
  if (lineNumX >= this._maxBeforeWidth + this._layout.paddingLeft) {
6304
- buffer.drawText(lineNumStr, lineNumX, i, this._fg, lineBg);
6303
+ buffer.drawText(lineNumStr, x + lineNumX, row, this._fg, transparent);
6305
6304
  }
6306
6305
  }
6307
6306
  if (sign?.after) {
6308
- const afterX = this.width - this._layout.paddingRight - this._maxAfterWidth;
6307
+ const afterX = x + this.width - this._layout.paddingRight - this._maxAfterWidth;
6309
6308
  const afterColor = sign.afterColor ? parseColor2(sign.afterColor) : this._fg;
6310
- buffer.drawText(sign.after, afterX, i, afterColor, lineBg);
6309
+ buffer.drawText(sign.after, afterX, row, afterColor, transparent);
6311
6310
  }
6312
6311
  }
6313
6312
  lastSource = logicalLine;
6314
6313
  }
6315
- this._paintedSources = sources.slice();
6316
- this._paintedSourceOffset = sourceOffset;
6317
6314
  }
6318
6315
  }
6319
6316
  function getLineSources(target, startLine, lineCount) {
@@ -6505,10 +6502,10 @@ class LineNumberRenderable extends Renderable2 {
6505
6502
  renderSelf(buffer) {
6506
6503
  if (!this.target || !this.gutter || this._lineColorsContent.size === 0)
6507
6504
  return;
6508
- const y = Math.trunc(this.y);
6505
+ const [x, y] = this._paintOrigin(buffer);
6509
6506
  const start = Math.max(0, -y);
6510
6507
  const end = Math.min(this.height, buffer.height - y);
6511
- if (end <= start || this.x >= buffer.width || this.x + this.width <= 0)
6508
+ if (end <= start || x >= buffer.width || x + this.width <= 0)
6512
6509
  return;
6513
6510
  const sources = getLineSources(this.target, Math.trunc(this.target.scrollY) + start, end - start);
6514
6511
  const gutterWidth = this.gutter.visible ? this.gutter.width : 0;
@@ -6517,7 +6514,7 @@ class LineNumberRenderable extends Renderable2 {
6517
6514
  const logicalLine = sources[i];
6518
6515
  const lineBg = this._lineColorsContent.get(logicalLine);
6519
6516
  if (lineBg) {
6520
- buffer.fillRect(this.x + gutterWidth, y + start + i, contentWidth, 1, lineBg);
6517
+ buffer.fillRect(x + gutterWidth, y + start + i, contentWidth, 1, lineBg);
6521
6518
  }
6522
6519
  }
6523
6520
  }
@@ -9031,6 +9028,472 @@ class InputRenderable extends TextareaRenderable {
9031
9028
  }
9032
9029
  set initialValue(value) {}
9033
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
+ }
9034
9497
  // ../../node_modules/.bun/marked@17.0.1/node_modules/marked/lib/marked.esm.js
9035
9498
  function L() {
9036
9499
  return { async: false, breaks: false, extensions: null, gfm: true, hooks: null, pedantic: false, renderer: null, silent: false, tokenizer: null, walkTokens: null };
@@ -10405,7 +10868,6 @@ class TextTableRenderable extends Renderable2 {
10405
10868
  _columnCount = 0;
10406
10869
  _layout = this.createEmptyLayout();
10407
10870
  _layoutDirty = true;
10408
- _rasterDirty = true;
10409
10871
  _cachedMeasureLayout = null;
10410
10872
  _cachedMeasureWidth = undefined;
10411
10873
  _defaultOptions = {
@@ -10432,7 +10894,7 @@ class TextTableRenderable extends Renderable2 {
10432
10894
  attributes: 0
10433
10895
  };
10434
10896
  constructor(ctx, options = {}) {
10435
- super(ctx, { ...options, flexShrink: options.flexShrink ?? 0, buffered: true });
10897
+ super(ctx, { ...options, flexShrink: options.flexShrink ?? 0 });
10436
10898
  try {
10437
10899
  this._content = options.content ?? this._defaultOptions.content;
10438
10900
  this._wrapMode = options.wrapMode ?? this._defaultOptions.wrapMode;
@@ -10479,7 +10941,7 @@ class TextTableRenderable extends Renderable2 {
10479
10941
  for (const cell of row)
10480
10942
  cell.textBufferView.setWrapMode(value);
10481
10943
  }
10482
- this.invalidateLayoutAndRaster();
10944
+ this.invalidateLayout();
10483
10945
  });
10484
10946
  }
10485
10947
  get columnWidthMode() {
@@ -10489,7 +10951,7 @@ class TextTableRenderable extends Renderable2 {
10489
10951
  if (this._columnWidthMode === value)
10490
10952
  return;
10491
10953
  this._columnWidthMode = value;
10492
- this.invalidateLayoutAndRaster();
10954
+ this.invalidateLayout();
10493
10955
  }
10494
10956
  get columnFitter() {
10495
10957
  return this._columnFitter;
@@ -10499,7 +10961,7 @@ class TextTableRenderable extends Renderable2 {
10499
10961
  if (this._columnFitter === next)
10500
10962
  return;
10501
10963
  this._columnFitter = next;
10502
- this.invalidateLayoutAndRaster();
10964
+ this.invalidateLayout();
10503
10965
  }
10504
10966
  get cellPadding() {
10505
10967
  return this._cellPaddingX === this._cellPaddingY ? this._cellPaddingX : 0;
@@ -10510,7 +10972,7 @@ class TextTableRenderable extends Renderable2 {
10510
10972
  return;
10511
10973
  this._cellPaddingX = next;
10512
10974
  this._cellPaddingY = next;
10513
- this.invalidateLayoutAndRaster();
10975
+ this.invalidateLayout();
10514
10976
  }
10515
10977
  get cellPaddingX() {
10516
10978
  return this._cellPaddingX;
@@ -10520,7 +10982,7 @@ class TextTableRenderable extends Renderable2 {
10520
10982
  if (this._cellPaddingX === next)
10521
10983
  return;
10522
10984
  this._cellPaddingX = next;
10523
- this.invalidateLayoutAndRaster();
10985
+ this.invalidateLayout();
10524
10986
  }
10525
10987
  get cellPaddingY() {
10526
10988
  return this._cellPaddingY;
@@ -10530,7 +10992,7 @@ class TextTableRenderable extends Renderable2 {
10530
10992
  if (this._cellPaddingY === next)
10531
10993
  return;
10532
10994
  this._cellPaddingY = next;
10533
- this.invalidateLayoutAndRaster();
10995
+ this.invalidateLayout();
10534
10996
  }
10535
10997
  get columnGap() {
10536
10998
  return this._columnGap;
@@ -10540,7 +11002,7 @@ class TextTableRenderable extends Renderable2 {
10540
11002
  if (this._columnGap === next)
10541
11003
  return;
10542
11004
  this._columnGap = next;
10543
- this.invalidateLayoutAndRaster();
11005
+ this.invalidateLayout();
10544
11006
  }
10545
11007
  get showBorders() {
10546
11008
  return this._showBorders;
@@ -10549,7 +11011,7 @@ class TextTableRenderable extends Renderable2 {
10549
11011
  if (this._showBorders === value)
10550
11012
  return;
10551
11013
  this._showBorders = value;
10552
- this.invalidateRasterOnly();
11014
+ this.requestRender();
10553
11015
  }
10554
11016
  get outerBorder() {
10555
11017
  return this._outerBorder;
@@ -10562,7 +11024,7 @@ class TextTableRenderable extends Renderable2 {
10562
11024
  return;
10563
11025
  this._hasExplicitOuterBorder = value != null;
10564
11026
  this._outerBorder = next;
10565
- this.invalidateLayoutAndRaster();
11027
+ this.invalidateLayout();
10566
11028
  }
10567
11029
  get border() {
10568
11030
  return this._border;
@@ -10574,7 +11036,7 @@ class TextTableRenderable extends Renderable2 {
10574
11036
  if (!this._hasExplicitOuterBorder) {
10575
11037
  this._outerBorder = value;
10576
11038
  }
10577
- this.invalidateLayoutAndRaster();
11039
+ this.invalidateLayout();
10578
11040
  }
10579
11041
  get borderStyle() {
10580
11042
  return this._borderStyle;
@@ -10584,14 +11046,14 @@ class TextTableRenderable extends Renderable2 {
10584
11046
  if (this._borderStyle === next)
10585
11047
  return;
10586
11048
  this._borderStyle = next;
10587
- this.invalidateRasterOnly();
11049
+ this.requestRender();
10588
11050
  }
10589
11051
  get borderColor() {
10590
11052
  return RGBA2.clone(this._borderColor);
10591
11053
  }
10592
11054
  set borderColor(value) {
10593
11055
  this._borderColor = RGBA2.clone(parseColor2(value ?? this._defaultOptions.borderColor));
10594
- this.invalidateRasterOnly();
11056
+ this.requestRender();
10595
11057
  }
10596
11058
  get fg() {
10597
11059
  return this._defaultFg;
@@ -10606,7 +11068,7 @@ class TextTableRenderable extends Renderable2 {
10606
11068
  cell.textBuffer.setDefaultFg(next);
10607
11069
  }
10608
11070
  }
10609
- this.invalidateRasterOnly();
11071
+ this.requestRender();
10610
11072
  }
10611
11073
  shouldStartSelection(x, y) {
10612
11074
  if (!this.selectable)
@@ -10618,19 +11080,15 @@ class TextTableRenderable extends Renderable2 {
10618
11080
  }
10619
11081
  onSelectionChanged(selection) {
10620
11082
  this.ensureLayoutReady();
10621
- const previousLocalSelection = this._lastLocalSelection;
10622
11083
  const localSelection = convertGlobalToLocalSelection2(selection, Math.trunc(this.x), Math.trunc(this.y));
10623
11084
  this._lastLocalSelection = localSelection;
10624
- const dirtyRows = this.getDirtySelectionRowRange(previousLocalSelection, localSelection);
10625
11085
  if (!localSelection?.isActive) {
10626
11086
  this.resetCellSelections();
10627
11087
  this._lastSelectionMode = null;
10628
11088
  } else {
10629
11089
  this.applySelectionToCells(localSelection, selection?.isStart ?? false);
10630
11090
  }
10631
- if (dirtyRows !== null) {
10632
- this.redrawSelectionRows(dirtyRows.firstRow, dirtyRows.lastRow);
10633
- }
11091
+ this.requestRender();
10634
11092
  return this.hasSelection();
10635
11093
  }
10636
11094
  hasSelection() {
@@ -10675,25 +11133,23 @@ class TextTableRenderable extends Renderable2 {
10675
11133
  `);
10676
11134
  }
10677
11135
  onResize(width, height) {
10678
- this.invalidateLayoutAndRaster(false);
11136
+ this.invalidateLayout(false);
10679
11137
  super.onResize(width, height);
10680
11138
  }
10681
11139
  renderSelf(buffer) {
10682
11140
  if (!this.visible || this.isDestroyed)
10683
11141
  return;
10684
- if (this._layoutDirty) {
10685
- this.rebuildLayoutForCurrentWidth();
10686
- }
10687
- if (!this._rasterDirty)
10688
- return;
10689
- buffer.clear(this._backgroundColor);
10690
- if (this._rowCount === 0 || this._columnCount === 0) {
10691
- this._rasterDirty = false;
10692
- 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);
10693
11149
  }
10694
- this.drawBorders(buffer);
10695
- this.drawCells(buffer);
10696
- this._rasterDirty = false;
11150
+ this.drawBorders(buffer, x, y);
11151
+ this.drawCells(buffer, x, y);
11152
+ buffer.popScissorRect();
10697
11153
  }
10698
11154
  destroySelf() {
10699
11155
  this.destroyCells();
@@ -10779,7 +11235,7 @@ class TextTableRenderable extends Renderable2 {
10779
11235
  this._rowCount = newRowCount;
10780
11236
  this._columnCount = newColumnCount;
10781
11237
  this.runCleanup((run) => {
10782
- run(() => this.invalidateLayoutAndRaster());
11238
+ run(() => this.invalidateLayout());
10783
11239
  for (let rowIdx = 0;rowIdx < previous.length; rowIdx++) {
10784
11240
  for (let colIdx = 0;colIdx < previous[rowIdx].length; colIdx++) {
10785
11241
  const cell = previous[rowIdx][colIdx];
@@ -11079,7 +11535,7 @@ class TextTableRenderable extends Renderable2 {
11079
11535
  getHorizontalBorderCount(borderLayout) {
11080
11536
  return (borderLayout.top ? 1 : 0) + (borderLayout.bottom ? 1 : 0) + (borderLayout.innerHorizontal ? Math.max(0, this._rowCount - 1) : 0);
11081
11537
  }
11082
- drawBorders(buffer) {
11538
+ drawBorders(buffer, x, y) {
11083
11539
  if (!this._showBorders) {
11084
11540
  return;
11085
11541
  }
@@ -11087,59 +11543,31 @@ class TextTableRenderable extends Renderable2 {
11087
11543
  if (this.getVerticalBorderCount(borderLayout) === 0 && this.getHorizontalBorderCount(borderLayout) === 0) {
11088
11544
  return;
11089
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);
11090
11549
  buffer.drawGrid({
11091
11550
  borderChars: BorderCharArrays2[this._borderStyle],
11092
11551
  borderFg: this._borderColor,
11093
11552
  borderBg: this._borderBackgroundColor,
11094
- columnOffsets: this._layout.columnOffsetsI32,
11095
- rowOffsets: this._layout.rowOffsetsI32,
11553
+ columnOffsets: columnOffsetsI32,
11554
+ rowOffsets: rowOffsetsI32,
11096
11555
  drawInner: this._border,
11097
11556
  drawOuter: this._outerBorder
11098
11557
  });
11099
11558
  }
11100
- drawCells(buffer) {
11101
- this.drawCellRange(buffer, 0, this._rowCount - 1);
11102
- }
11103
- drawCellRange(buffer, firstRow, lastRow) {
11559
+ drawCells(buffer, x, y) {
11104
11560
  const colOffsets = this._layout.columnOffsets;
11105
11561
  const rowOffsets = this._layout.rowOffsets;
11106
- const cellPaddingX = this._cellPaddingX;
11562
+ const cellX = x + 1 + this._cellPaddingX;
11107
11563
  const cellPaddingY = this._cellPaddingY;
11108
- for (let rowIdx = firstRow;rowIdx <= lastRow; rowIdx++) {
11109
- 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;
11110
11566
  for (let colIdx = 0;colIdx < this._columnCount; colIdx++) {
11111
11567
  const cell = this._cells[rowIdx]?.[colIdx];
11112
11568
  if (!cell)
11113
11569
  continue;
11114
- buffer.drawTextBuffer(cell.textBufferView, (colOffsets[colIdx] ?? 0) + 1 + cellPaddingX, cellY);
11115
- }
11116
- }
11117
- }
11118
- redrawSelectionRows(firstRow, lastRow) {
11119
- if (firstRow > lastRow)
11120
- return;
11121
- if (this._backgroundColor.a < 1) {
11122
- this.invalidateRasterOnly();
11123
- return;
11124
- }
11125
- const buffer = this.frameBuffer;
11126
- if (!buffer)
11127
- return;
11128
- this.clearCellRange(buffer, firstRow, lastRow);
11129
- this.drawCellRange(buffer, firstRow, lastRow);
11130
- this.requestRender();
11131
- }
11132
- clearCellRange(buffer, firstRow, lastRow) {
11133
- const colWidths = this._layout.columnWidths;
11134
- const rowHeights = this._layout.rowHeights;
11135
- const colOffsets = this._layout.columnOffsets;
11136
- const rowOffsets = this._layout.rowOffsets;
11137
- for (let rowIdx = firstRow;rowIdx <= lastRow; rowIdx++) {
11138
- const cellY = (rowOffsets[rowIdx] ?? 0) + 1;
11139
- const rowHeight = rowHeights[rowIdx] ?? 1;
11140
- for (let colIdx = 0;colIdx < this._columnCount; colIdx++) {
11141
- const cellX = (colOffsets[colIdx] ?? 0) + 1;
11142
- buffer.fillRect(cellX, cellY, colWidths[colIdx] ?? 1, rowHeight, this._backgroundColor);
11570
+ buffer.drawTextBuffer(cell.textBufferView, cellX + (colOffsets[colIdx] ?? 0), cellY);
11143
11571
  }
11144
11572
  }
11145
11573
  }
@@ -11295,28 +11723,6 @@ class TextTableRenderable extends Renderable2 {
11295
11723
  }
11296
11724
  return this._rowCount - 1;
11297
11725
  }
11298
- getSelectionRowRange(selection) {
11299
- if (!selection?.isActive || this._rowCount === 0)
11300
- return null;
11301
- const minSelY = Math.min(selection.anchorY, selection.focusY);
11302
- const maxSelY = Math.max(selection.anchorY, selection.focusY);
11303
- return {
11304
- firstRow: this.findRowForLocalY(minSelY),
11305
- lastRow: this.findRowForLocalY(maxSelY)
11306
- };
11307
- }
11308
- getDirtySelectionRowRange(previousSelection, currentSelection) {
11309
- const previousRange = this.getSelectionRowRange(previousSelection);
11310
- const currentRange = this.getSelectionRowRange(currentSelection);
11311
- if (previousRange === null)
11312
- return currentRange;
11313
- if (currentRange === null)
11314
- return previousRange;
11315
- return {
11316
- firstRow: Math.min(previousRange.firstRow, currentRange.firstRow),
11317
- lastRow: Math.max(previousRange.lastRow, currentRange.lastRow)
11318
- };
11319
- }
11320
11726
  resetRowSelection(rowIdx) {
11321
11727
  const row = this._cells[rowIdx];
11322
11728
  if (!row)
@@ -11375,9 +11781,8 @@ class TextTableRenderable extends Renderable2 {
11375
11781
  }
11376
11782
  return Math.max(0, Math.floor(value));
11377
11783
  }
11378
- invalidateLayoutAndRaster(markYogaDirty = true) {
11784
+ invalidateLayout(markYogaDirty = true) {
11379
11785
  this._layoutDirty = true;
11380
- this._rasterDirty = true;
11381
11786
  this._cachedMeasureLayout = null;
11382
11787
  this._cachedMeasureWidth = undefined;
11383
11788
  if (markYogaDirty) {
@@ -11385,10 +11790,6 @@ class TextTableRenderable extends Renderable2 {
11385
11790
  }
11386
11791
  this.requestRender();
11387
11792
  }
11388
- invalidateRasterOnly() {
11389
- this._rasterDirty = true;
11390
- this.requestRender();
11391
- }
11392
11793
  }
11393
11794
 
11394
11795
  // src/renderables/markdown-parser.ts
@@ -12107,7 +12508,7 @@ class MarkdownRenderable extends Renderable2 {
12107
12508
  }
12108
12509
  }
12109
12510
  applyListItemRenderable(row, input, previousItem) {
12110
- this.applyListItemMarker(row, input);
12511
+ this.applyListItemMarker(row, input, previousItem);
12111
12512
  const content = row.getChildren()[1];
12112
12513
  if (!(content instanceof BoxRenderable2))
12113
12514
  return false;
@@ -12174,6 +12575,10 @@ class MarkdownRenderable extends Renderable2 {
12174
12575
  this.applyCodeBlockRenderable(renderable, token, 0);
12175
12576
  return true;
12176
12577
  }
12578
+ if (token.type === "blockquote" && renderable instanceof BoxRenderable2) {
12579
+ this.applyBlockquoteRenderable(renderable, token, 0);
12580
+ return true;
12581
+ }
12177
12582
  return previousToken?.raw === token.raw;
12178
12583
  }
12179
12584
  destroyListItemChildrenAfter(content, index) {
@@ -12182,7 +12587,7 @@ class MarkdownRenderable extends Renderable2 {
12182
12587
  children[i]?.destroyRecursively();
12183
12588
  }
12184
12589
  }
12185
- applyListItemMarker(row, input) {
12590
+ applyListItemMarker(row, input, previousItem) {
12186
12591
  const marker = row.getChildren()[0];
12187
12592
  if (!(marker instanceof TextRenderable2))
12188
12593
  return;
@@ -12193,7 +12598,7 @@ class MarkdownRenderable extends Renderable2 {
12193
12598
  row.marginBottom = marginBottom;
12194
12599
  if (marker.width !== markerWidth)
12195
12600
  marker.width = markerWidth;
12196
- if (marker.chunks[0]?.text !== markerText) {
12601
+ if (!previousItem || marker.chunks[0]?.text !== markerText) {
12197
12602
  marker.content = new StyledText2([this.createChunk(markerText, "markup.list")]);
12198
12603
  }
12199
12604
  }
@@ -12213,13 +12618,16 @@ class MarkdownRenderable extends Renderable2 {
12213
12618
  return this.createTableBlock(token, id).renderable;
12214
12619
  return token.raw ? this.createMarkdownCodeRenderable(token.raw, id, 0, this._linkifyMarkdownChunks, undefined, this.createInitialStyledText(token)) : null;
12215
12620
  }
12621
+ getHorizontalRuleColor() {
12622
+ return this.getStyle("conceal")?.fg ?? this._fg ?? "#888888";
12623
+ }
12216
12624
  createHorizontalRuleRenderable(id, marginBottom = 0) {
12217
12625
  return new BoxRenderable2(this.ctx, {
12218
12626
  id,
12219
12627
  width: "100%",
12220
12628
  height: 1,
12221
12629
  border: ["top"],
12222
- borderColor: this.getStyle("conceal")?.fg ?? this._fg ?? "#888888",
12630
+ borderColor: this.getHorizontalRuleColor(),
12223
12631
  flexShrink: 0,
12224
12632
  marginBottom
12225
12633
  });
@@ -12774,7 +13182,7 @@ class MarkdownRenderable extends Renderable2 {
12774
13182
  return;
12775
13183
  renderable.destroyRecursively();
12776
13184
  }
12777
- updateBlockRenderable(state, token, index, nextToken, forceListRefresh = false) {
13185
+ updateBlockRenderable(state, token, index, nextToken, forceRefresh = false) {
12778
13186
  const marginBottom = this.getInterBlockMargin(token, nextToken);
12779
13187
  if (token.type === "code") {
12780
13188
  this.applyCodeBlockRenderable(state.renderable, token, marginBottom);
@@ -12785,7 +13193,7 @@ class MarkdownRenderable extends Renderable2 {
12785
13193
  return;
12786
13194
  }
12787
13195
  if (token.type === "list") {
12788
- if (!this.applyListRenderable(state.renderable, token, forceListRefresh ? undefined : state.token, `${this.id}-block-${index}`, marginBottom)) {
13196
+ if (!this.applyListRenderable(state.renderable, token, forceRefresh ? undefined : state.token, `${this.id}-block-${index}`, marginBottom)) {
12789
13197
  state.renderable.destroyRecursively();
12790
13198
  state.renderable = this.createListRenderable(token, `${this.id}-block-${index}`, marginBottom);
12791
13199
  this.add(state.renderable, index);
@@ -12793,12 +13201,14 @@ class MarkdownRenderable extends Renderable2 {
12793
13201
  return;
12794
13202
  }
12795
13203
  if (token.type === "hr") {
13204
+ if (state.renderable instanceof BoxRenderable2)
13205
+ state.renderable.borderColor = this.getHorizontalRuleColor();
12796
13206
  state.renderable.marginBottom = marginBottom;
12797
13207
  return;
12798
13208
  }
12799
13209
  if (token.type === "table") {
12800
13210
  const tableToken = token;
12801
- const { cache, changed } = this.buildTableContentCache(tableToken, state.tableContentCache);
13211
+ const { cache, changed } = this.buildTableContentCache(tableToken, state.tableContentCache, forceRefresh);
12802
13212
  if (!cache) {
12803
13213
  if (state.renderable instanceof CodeRenderable2) {
12804
13214
  this.applyMarkdownCodeRenderable(state.renderable, tableToken.raw, marginBottom);
@@ -12828,12 +13238,13 @@ class MarkdownRenderable extends Renderable2 {
12828
13238
  state.tableContentCache = cache;
12829
13239
  return;
12830
13240
  }
13241
+ const raw = this._internalBlockMode === "top-level" ? this.getTopLevelBlockRaw(token) ?? token.raw : token.raw;
12831
13242
  if (state.renderable instanceof CodeRenderable2) {
12832
- this.applyMarkdownCodeRenderable(state.renderable, this.getTopLevelBlockRaw(token) ?? token.raw, marginBottom, undefined, this.createInitialStyledText(token));
13243
+ this.applyMarkdownCodeRenderable(state.renderable, raw, marginBottom, undefined, this.createInitialStyledText(token));
12833
13244
  return;
12834
13245
  }
12835
13246
  state.renderable.destroyRecursively();
12836
- const markdownRenderable = this.createMarkdownCodeRenderable(this.getTopLevelBlockRaw(token) ?? token.raw, `${this.id}-block-${index}`, marginBottom, this._linkifyMarkdownChunks, undefined, this.createInitialStyledText(token));
13247
+ const markdownRenderable = this.createMarkdownCodeRenderable(raw, `${this.id}-block-${index}`, marginBottom, this._linkifyMarkdownChunks, undefined, this.createInitialStyledText(token));
12837
13248
  this.add(markdownRenderable, index);
12838
13249
  state.renderable = markdownRenderable;
12839
13250
  }
@@ -12860,7 +13271,7 @@ class MarkdownRenderable extends Renderable2 {
12860
13271
  blockIndex++;
12861
13272
  continue;
12862
13273
  }
12863
- if (existing && existing.canUpdateInPlace && existing.token.type === block.token.type && this.canUpdateBlockRenderable(existing.renderable, block.token)) {
13274
+ if (existing && existing.canUpdateInPlace && existing.token.type === block.token.type && (block.token.type !== "table" || block.token.rows.length > 0 === existing.renderable instanceof TextTableRenderable)) {
12864
13275
  if (this._renderNode) {
12865
13276
  const custom = this.createTopLevelCustomRenderable(block, blockIndex);
12866
13277
  if (custom.renderable && !custom.canUpdateInPlace) {
@@ -12883,7 +13294,7 @@ class MarkdownRenderable extends Renderable2 {
12883
13294
  }
12884
13295
  this.destroyUnusedDefaultRenderable(custom.renderable);
12885
13296
  }
12886
- this.updateBlockRenderable(existing, block.token, blockIndex, blocks[i + 1]?.token);
13297
+ this.updateBlockRenderable(existing, block.token, blockIndex, blocks[i + 1]?.token, forceTableRefresh);
12887
13298
  existing.renderable.marginBottom = 0;
12888
13299
  if (existing.marginTop !== block.marginTop) {
12889
13300
  this.applyMargins(existing.renderable, block.marginTop, 0);
@@ -12914,19 +13325,6 @@ class MarkdownRenderable extends Renderable2 {
12914
13325
  removed.renderable.destroyRecursively();
12915
13326
  }
12916
13327
  }
12917
- canUpdateBlockRenderable(renderable, token) {
12918
- if (token.type === "code")
12919
- return renderable instanceof CodeRenderable2;
12920
- if (token.type === "table")
12921
- return renderable instanceof TextTableRenderable;
12922
- if (token.type === "blockquote")
12923
- return renderable instanceof BoxRenderable2;
12924
- if (token.type === "list")
12925
- return renderable instanceof BoxRenderable2;
12926
- if (token.type === "hr")
12927
- return renderable instanceof BoxRenderable2;
12928
- return renderable instanceof CodeRenderable2;
12929
- }
12930
13328
  updateBlocks(forceTableRefresh = false) {
12931
13329
  if (this.isDestroyed)
12932
13330
  return;
@@ -12967,22 +13365,10 @@ class MarkdownRenderable extends Renderable2 {
12967
13365
  const token = blockTokens[i];
12968
13366
  const nextToken = blockTokens[i + 1];
12969
13367
  const existing = this._blockStates[blockIndex];
12970
- const shouldForceRefresh = forceTableRefresh;
12971
- if (existing && existing.token === token) {
12972
- if (shouldForceRefresh) {
12973
- this.updateBlockRenderable(existing, token, blockIndex, nextToken);
12974
- existing.tokenRaw = token.raw;
12975
- } else {
12976
- this.applyInterBlockMargin(existing, token, nextToken);
12977
- }
12978
- blockIndex++;
12979
- continue;
12980
- }
12981
13368
  if (existing && existing.tokenRaw === token.raw && existing.token.type === token.type) {
12982
13369
  existing.token = token;
12983
- if (shouldForceRefresh) {
12984
- this.updateBlockRenderable(existing, token, blockIndex, nextToken);
12985
- existing.tokenRaw = token.raw;
13370
+ if (forceTableRefresh) {
13371
+ this.updateBlockRenderable(existing, token, blockIndex, nextToken, true);
12986
13372
  } else {
12987
13373
  this.applyInterBlockMargin(existing, token, nextToken);
12988
13374
  }
@@ -13072,60 +13458,7 @@ class MarkdownRenderable extends Renderable2 {
13072
13458
  }
13073
13459
  for (let i = 0;i < this._blockStates.length; i++) {
13074
13460
  const state = this._blockStates[i];
13075
- const marginBottom = this.getInterBlockMargin(state.token, this._blockStates[i + 1]?.token);
13076
- if (state.token.type === "code") {
13077
- this.applyCodeBlockRenderable(state.renderable, state.token, marginBottom);
13078
- continue;
13079
- }
13080
- if (state.token.type === "blockquote") {
13081
- this.applyBlockquoteRenderable(state.renderable, state.token, marginBottom);
13082
- continue;
13083
- }
13084
- if (state.token.type === "list") {
13085
- this.updateBlockRenderable(state, state.token, i, this._blockStates[i + 1]?.token, true);
13086
- continue;
13087
- }
13088
- if (state.token.type === "hr") {
13089
- state.renderable.marginBottom = marginBottom;
13090
- continue;
13091
- }
13092
- if (state.token.type === "table") {
13093
- const tableToken = state.token;
13094
- const { cache } = this.buildTableContentCache(tableToken, state.tableContentCache, true);
13095
- if (!cache) {
13096
- if (state.renderable instanceof CodeRenderable2) {
13097
- this.applyMarkdownCodeRenderable(state.renderable, tableToken.raw, marginBottom);
13098
- } else {
13099
- state.renderable.destroyRecursively();
13100
- const fallbackRenderable = this.createMarkdownCodeRenderable(tableToken.raw, `${this.id}-block-${i}`, marginBottom);
13101
- this.add(fallbackRenderable, i);
13102
- state.renderable = fallbackRenderable;
13103
- }
13104
- state.tableContentCache = undefined;
13105
- continue;
13106
- }
13107
- if (state.renderable instanceof TextTableRenderable) {
13108
- state.renderable.content = cache.content;
13109
- this.applyTableRenderableOptions(state.renderable, this.resolveTableRenderableOptions());
13110
- state.renderable.marginBottom = marginBottom;
13111
- state.tableContentCache = cache;
13112
- continue;
13113
- }
13114
- state.renderable.destroyRecursively();
13115
- const tableRenderable = this.createTextTableRenderable(cache.content, `${this.id}-block-${i}`, marginBottom);
13116
- this.add(tableRenderable, i);
13117
- state.renderable = tableRenderable;
13118
- state.tableContentCache = cache;
13119
- continue;
13120
- }
13121
- if (state.renderable instanceof CodeRenderable2) {
13122
- this.applyMarkdownCodeRenderable(state.renderable, this.getTopLevelBlockRaw(state.token) ?? state.token.raw, marginBottom, undefined, this.createInitialStyledText(state.token));
13123
- continue;
13124
- }
13125
- state.renderable.destroyRecursively();
13126
- const markdownRenderable = this.createMarkdownCodeRenderable(this.getTopLevelBlockRaw(state.token) ?? state.token.raw, `${this.id}-block-${i}`, marginBottom, this._linkifyMarkdownChunks, undefined, this.createInitialStyledText(state.token));
13127
- this.add(markdownRenderable, i);
13128
- state.renderable = markdownRenderable;
13461
+ this.updateBlockRenderable(state, state.token, i, this._blockStates[i + 1]?.token, true);
13129
13462
  }
13130
13463
  }
13131
13464
  clearCache() {
@@ -13403,56 +13736,7 @@ class SliderRenderable extends Renderable2 {
13403
13736
  }
13404
13737
  }
13405
13738
  renderSelf(buffer) {
13406
- const x = this.x;
13407
- const y = this.y;
13408
- const width = this.width;
13409
- const height = this.height;
13410
- const bufferWidth = buffer.width;
13411
- const bufferHeight = buffer.height;
13412
- const left = Math.max(0, Math.trunc(x));
13413
- const top = Math.max(0, Math.trunc(y));
13414
- const right = Math.min(bufferWidth, Math.trunc(x) + Math.trunc(width));
13415
- const bottom = Math.min(bufferHeight, Math.trunc(y) + Math.trunc(height));
13416
- if (right > left && bottom > top) {
13417
- buffer.fillRect(left, top, right - left, bottom - top, this._backgroundColor);
13418
- }
13419
- const horizontal = this.orientation === "horizontal";
13420
- const origin = horizontal ? x : y;
13421
- const crossOrigin = horizontal ? y : x;
13422
- const length = horizontal ? width : height;
13423
- const crossLength = horizontal ? height : width;
13424
- const limit = horizontal ? bufferWidth : bufferHeight;
13425
- const crossLimit = horizontal ? bufferHeight : bufferWidth;
13426
- const thumb = this._ctx.nativeScene.getSliderThumb(this);
13427
- const virtualThumbSize = thumb.size;
13428
- const virtualThumbStart = thumb.start;
13429
- const virtualThumbEnd = virtualThumbStart + virtualThumbSize;
13430
- const start = Math.max(0, Math.floor(virtualThumbStart / 2), Math.floor(-1 - origin));
13431
- const end = Math.min(Math.floor(length), Math.ceil(virtualThumbEnd / 2), Math.ceil(limit - origin) + 1);
13432
- const crossStart = Math.max(0, Math.floor(-1 - crossOrigin));
13433
- const crossEnd = Math.min(Math.ceil(crossLength), Math.ceil(crossLimit - crossOrigin) + 1);
13434
- for (let along = start;along < end; along++) {
13435
- const cell = Math.trunc(origin + along);
13436
- if (cell < 0 || cell >= limit)
13437
- continue;
13438
- const virtualCellStart = along * 2;
13439
- const thumbStartInCell = Math.max(virtualThumbStart, virtualCellStart);
13440
- const coverage = Math.min(virtualThumbEnd, virtualCellStart + 2) - thumbStartInCell;
13441
- let char = " ";
13442
- if (coverage >= 2) {
13443
- char = "█";
13444
- } else if (horizontal) {
13445
- char = thumbStartInCell === virtualCellStart ? "▌" : "▐";
13446
- } else if (coverage > 0) {
13447
- char = thumbStartInCell === virtualCellStart ? "▀" : "▄";
13448
- }
13449
- for (let across = crossStart;across < crossEnd; across++) {
13450
- const crossCell = Math.trunc(crossOrigin + across);
13451
- if (crossCell < 0 || crossCell >= crossLimit)
13452
- continue;
13453
- buffer.setCellWithAlphaBlending(horizontal ? cell : crossCell, horizontal ? crossCell : cell, char, this._foregroundColor, this._backgroundColor);
13454
- }
13455
- }
13739
+ this._drawNativeBody(buffer);
13456
13740
  }
13457
13741
  }
13458
13742
 
@@ -13718,9 +14002,7 @@ class ScrollBarRenderable extends Renderable2 {
13718
14002
  this.slider.value = Math.min(this._scrollPosition, scrollRange);
13719
14003
  }
13720
14004
  scrollBy(delta, unit = "absolute") {
13721
- const multiplier = unit === "viewport" ? this.viewportSize : unit === "content" ? this.scrollSize : unit === "step" ? this.scrollStep ?? 1 : 1;
13722
- const resolvedDelta = multiplier * delta;
13723
- this.scrollPosition += resolvedDelta;
14005
+ this.scrollPosition += scrollUnitSize(this, unit) * delta;
13724
14006
  }
13725
14007
  recalculateVisibility() {
13726
14008
  if (!this._manualVisibility) {
@@ -13866,8 +14148,7 @@ class ArrowRenderable extends Renderable2 {
13866
14148
  });
13867
14149
  }
13868
14150
  renderSelf(buffer) {
13869
- const char = this.getArrowChar();
13870
- buffer.drawText(char, this.x, this.y, this._foregroundColor, this._backgroundColor, this._attributes);
14151
+ this._drawNativeBody(buffer);
13871
14152
  }
13872
14153
  defaultDimension(kind) {
13873
14154
  return kind === "width" ? this.glyphWidth() : super.defaultDimension(kind);
@@ -13885,31 +14166,428 @@ class ArrowRenderable extends Renderable2 {
13885
14166
  return this._arrowChars[this._direction];
13886
14167
  }
13887
14168
  }
13888
- // src/renderables/ScrollBox.ts
13889
- class ContentRenderable extends BoxRenderable2 {
13890
- static nativeIntegration = BoxRenderable2.nativeIntegration;
13891
- viewport;
13892
- _viewportCulling;
13893
- constructor(ctx, viewport, viewportCulling, options) {
13894
- super(ctx, options);
13895
- try {
13896
- this.viewport = viewport;
13897
- ctx.nativeScene.setViewport(this, viewportCulling ? viewport : null);
13898
- this._viewportCulling = viewportCulling;
13899
- } catch (error) {
13900
- this.abortConstruction(error);
14169
+ function scrollUnitSize(bar, unit) {
14170
+ if (unit === "viewport")
14171
+ return bar.viewportSize;
14172
+ if (unit === "content")
14173
+ return bar.scrollSize;
14174
+ return unit === "step" ? bar.scrollStep ?? 1 : 1;
14175
+ }
14176
+ // src/renderables/ScrollBoxParts.ts
14177
+ import { EventEmitter as EventEmitter2 } from "events";
14178
+ class ScrollBoxPart extends EventEmitter2 {
14179
+ box;
14180
+ constructor(box, event) {
14181
+ super();
14182
+ this.box = box;
14183
+ this.on("newListener", (name) => name === event && box._refreshScrollHook(true));
14184
+ this.on("removeListener", (name) => name === event && box._refreshScrollHook());
14185
+ }
14186
+ get isDestroyed() {
14187
+ return this.box.isDestroyed;
14188
+ }
14189
+ get x() {
14190
+ return this.rect().x;
14191
+ }
14192
+ get y() {
14193
+ return this.rect().y;
14194
+ }
14195
+ get screenX() {
14196
+ return this.rect().x;
14197
+ }
14198
+ get screenY() {
14199
+ return this.rect().y;
14200
+ }
14201
+ get width() {
14202
+ return this.rect().width;
14203
+ }
14204
+ get height() {
14205
+ return this.rect().height;
14206
+ }
14207
+ removeAllListeners(event) {
14208
+ for (const name of event === undefined ? this.eventNames() : [event]) {
14209
+ if (name !== "newListener" && name !== "removeListener")
14210
+ super.removeAllListeners(name);
14211
+ }
14212
+ return this;
14213
+ }
14214
+ _assign(options, keys) {
14215
+ if (options == null)
14216
+ return;
14217
+ for (const key of Reflect.ownKeys(options)) {
14218
+ if (typeof key !== "string" || !keys.includes(key))
14219
+ continue;
14220
+ if (!Object.getOwnPropertyDescriptor(options, key)?.enumerable)
14221
+ continue;
14222
+ this[key] = Reflect.get(options, key);
14223
+ if (this.box.isDestroyed)
14224
+ return;
14225
+ }
14226
+ }
14227
+ }
14228
+
14229
+ class ScrollBoxFilledPart extends ScrollBoxPart {
14230
+ _backgroundColor;
14231
+ get backgroundColor() {
14232
+ return RGBA2.clone(this._backgroundColor ?? RGBA2.fromValues(0, 0, 0, 0));
14233
+ }
14234
+ set backgroundColor(value) {
14235
+ this._backgroundColor = value == null ? undefined : RGBA2.clone(parseColor2(value));
14236
+ this.box._applyScrollOptions();
14237
+ }
14238
+ _fill() {
14239
+ return this._backgroundColor;
14240
+ }
14241
+ }
14242
+
14243
+ class ScrollBoxSizedPart extends ScrollBoxFilledPart {
14244
+ _onSizeChange;
14245
+ constructor(box) {
14246
+ super(box, "resize");
14247
+ }
14248
+ get onSizeChange() {
14249
+ return this._onSizeChange;
14250
+ }
14251
+ set onSizeChange(handler) {
14252
+ this._onSizeChange = handler ?? undefined;
14253
+ this.box._refreshScrollHook();
14254
+ }
14255
+ _listening() {
14256
+ return this._onSizeChange !== undefined || this.listenerCount("resize") > 0;
14257
+ }
14258
+ _emitResize() {
14259
+ this._onSizeChange?.();
14260
+ if (!this.box.isDestroyed)
14261
+ this.emit("resize");
14262
+ }
14263
+ }
14264
+
14265
+ class ScrollBoxWrapper extends ScrollBoxFilledPart {
14266
+ static keys = ["backgroundColor"];
14267
+ _listening() {
14268
+ return false;
14269
+ }
14270
+ rect() {
14271
+ return this.box._wrapperRect();
14272
+ }
14273
+ }
14274
+ var paddingKeys = ["padding", "paddingX", "paddingY", "paddingLeft", "paddingTop", "paddingRight", "paddingBottom"];
14275
+
14276
+ class ScrollBoxViewport extends ScrollBoxSizedPart {
14277
+ static keys = ["backgroundColor", "onSizeChange", ...paddingKeys];
14278
+ paddings = {};
14279
+ constructor(box) {
14280
+ super(box);
14281
+ paddingKeys.forEach((key, index) => Object.defineProperty(this, key, {
14282
+ configurable: true,
14283
+ get: index < 3 ? undefined : () => this._edges()[index - 3],
14284
+ set: (value) => this.setPadding(key, value)
14285
+ }));
14286
+ }
14287
+ rect() {
14288
+ return this.box._scrollState().viewport;
14289
+ }
14290
+ setPadding(key, value) {
14291
+ if (value != null && (typeof value !== "number" || !Number.isInteger(value) || value < 0 || value > 65535)) {
14292
+ throw new RangeError("ScrollBox viewport padding must be a whole number of cells");
14293
+ }
14294
+ if (value == null)
14295
+ delete this.paddings[key];
14296
+ else
14297
+ this.paddings[key] = value;
14298
+ this.box._applyScrollOptions();
14299
+ }
14300
+ _edges() {
14301
+ const p = this.paddings;
14302
+ const all = p.padding ?? 0;
14303
+ const x = p.paddingX ?? all;
14304
+ const y = p.paddingY ?? all;
14305
+ return [p.paddingLeft ?? x, p.paddingTop ?? y, p.paddingRight ?? x, p.paddingBottom ?? y];
14306
+ }
14307
+ }
14308
+ var content = NativeStyleFlags.Content;
14309
+ var contentStyles = {};
14310
+ {
14311
+ const value = (kind, edge = NATIVE_EDGE_NONE2) => (scene, node, input) => sceneSetValue(scene, node, kind, edge, input ?? undefined, content);
14312
+ const enums = [
14313
+ ["flexDirection", YogaEnumKind.FlexDirection, parseFlexDirection2],
14314
+ ["flexWrap", YogaEnumKind.FlexWrap, parseWrap2],
14315
+ ["alignItems", YogaEnumKind.AlignItems, parseAlignItems2],
14316
+ ["justifyContent", YogaEnumKind.JustifyContent, parseJustify2],
14317
+ ["alignSelf", YogaEnumKind.AlignSelf, parseAlign2]
14318
+ ];
14319
+ for (const [key, kind, parse] of enums) {
14320
+ contentStyles[key] = (scene, node, input) => sceneSetEnum(scene, node, kind, parse(input ?? undefined), content);
14321
+ }
14322
+ contentStyles.flexGrow = (scene, node, input) => sceneSetFloat(scene, node, YogaFloatKind.FlexGrow, input ?? 0, content);
14323
+ contentStyles.flexShrink = (scene, node, input) => sceneSetFloat(scene, node, YogaFloatKind.FlexShrink, input ?? 0, content);
14324
+ for (const [key, kind] of [
14325
+ ["width", YogaValueKind.Width],
14326
+ ["height", YogaValueKind.Height],
14327
+ ["flexBasis", YogaValueKind.FlexBasis],
14328
+ ["minWidth", YogaValueKind.MinWidth],
14329
+ ["minHeight", YogaValueKind.MinHeight],
14330
+ ["maxWidth", YogaValueKind.MaxWidth],
14331
+ ["maxHeight", YogaValueKind.MaxHeight]
14332
+ ]) {
14333
+ contentStyles[key] = value(kind);
14334
+ }
14335
+ for (const [suffix, edge] of [
14336
+ ["", Edge2.All],
14337
+ ["X", Edge2.Horizontal],
14338
+ ["Y", Edge2.Vertical],
14339
+ ["Top", Edge2.Top],
14340
+ ["Right", Edge2.Right],
14341
+ ["Bottom", Edge2.Bottom],
14342
+ ["Left", Edge2.Left]
14343
+ ]) {
14344
+ contentStyles[`padding${suffix}`] = value(YogaValueKind.Padding, edge);
14345
+ contentStyles[`margin${suffix}`] = value(YogaValueKind.Margin, edge);
14346
+ }
14347
+ contentStyles.gap = value(YogaValueKind.Gap, Gutter2.All);
14348
+ contentStyles.rowGap = value(YogaValueKind.Gap, Gutter2.Row);
14349
+ contentStyles.columnGap = value(YogaValueKind.Gap, Gutter2.Column);
14350
+ }
14351
+
14352
+ class ScrollBoxContent extends ScrollBoxSizedPart {
14353
+ static keys = ["backgroundColor", "onSizeChange", "viewportCulling", ...Object.keys(contentStyles)];
14354
+ styles = new Map;
14355
+ constructor(box) {
14356
+ super(box);
14357
+ for (const key of Object.keys(contentStyles)) {
14358
+ const size = key === "width" || key === "height";
14359
+ Object.defineProperty(this, key, {
14360
+ configurable: true,
14361
+ enumerable: false,
14362
+ get: () => size ? this.rect()[key] : this.styles.get(key),
14363
+ set: (input) => this.setStyle(key, input)
14364
+ });
13901
14365
  }
13902
14366
  }
14367
+ rect() {
14368
+ const { content, offset } = this.box._scrollState();
14369
+ return {
14370
+ x: this.box.screenX + content.x - offset[0],
14371
+ y: this.box.screenY + content.y - offset[1],
14372
+ width: content.width,
14373
+ height: content.height
14374
+ };
14375
+ }
14376
+ setStyle(key, input) {
14377
+ this.box._setContentStyle((scene, node) => contentStyles[key](scene, node, input));
14378
+ if (input == null)
14379
+ this.styles.delete(key);
14380
+ else
14381
+ this.styles.set(key, input);
14382
+ }
14383
+ get _row() {
14384
+ const direction = parseFlexDirection2(this.styles.get("flexDirection"));
14385
+ return direction === FlexDirection2.Row || direction === FlexDirection2.RowReverse;
14386
+ }
13903
14387
  get viewportCulling() {
13904
- return this._viewportCulling;
14388
+ return this.box.viewportCulling;
13905
14389
  }
13906
14390
  set viewportCulling(value) {
13907
- if (this.isFreed())
14391
+ this.box.viewportCulling = value;
14392
+ }
14393
+ add(obj, index) {
14394
+ return this.box.add(obj, index);
14395
+ }
14396
+ insertBefore(obj, anchor) {
14397
+ return this.box.insertBefore(obj, anchor);
14398
+ }
14399
+ remove(child) {
14400
+ this.box.remove(child);
14401
+ }
14402
+ getChildren() {
14403
+ return this.box.getChildren();
14404
+ }
14405
+ getChildrenCount() {
14406
+ return this.box.getChildrenCount();
14407
+ }
14408
+ getRenderable(id) {
14409
+ return this.box.getRenderable(id);
14410
+ }
14411
+ findDescendantById(id) {
14412
+ return this.box.findDescendantById(id);
14413
+ }
14414
+ }
14415
+ var defaultTrack = RGBA2.fromHex("#252527");
14416
+ var defaultThumb = RGBA2.fromHex("#9a9ea3");
14417
+ var defaultArrowForeground2 = RGBA2.fromValues(1, 1, 1, 1);
14418
+ var defaultArrowBackground2 = RGBA2.fromValues(0, 0, 0, 0);
14419
+
14420
+ class ScrollBoxBar extends ScrollBoxPart {
14421
+ static keys = [
14422
+ "visible",
14423
+ "showArrows",
14424
+ "arrowOptions",
14425
+ "trackOptions",
14426
+ "onChange",
14427
+ "width",
14428
+ "height",
14429
+ "paddingLeft",
14430
+ "paddingTop",
14431
+ "position",
14432
+ "scrollStep"
14433
+ ];
14434
+ orientation;
14435
+ scrollStep = null;
14436
+ axis;
14437
+ policy = "auto";
14438
+ _showArrows = false;
14439
+ _arrowOptions = {};
14440
+ trackForeground = defaultThumb;
14441
+ trackBackground = defaultTrack;
14442
+ thickness = 1;
14443
+ gap = 0;
14444
+ overlay = false;
14445
+ _onChange;
14446
+ constructor(box, orientation) {
14447
+ super(box, "change");
14448
+ this.orientation = orientation;
14449
+ this.axis = orientation === "vertical" ? 1 : 0;
14450
+ }
14451
+ rect() {
14452
+ const bar = this.box._scrollState().bars[this.axis];
14453
+ const arrows = this._showArrows ? 1 : 0;
14454
+ return this.axis === 1 ? {
14455
+ x: bar.track.x - this.gap,
14456
+ y: bar.track.y - arrows,
14457
+ width: bar.track.width + this.gap,
14458
+ height: bar.track.height + 2 * arrows
14459
+ } : {
14460
+ x: bar.track.x - arrows,
14461
+ y: bar.track.y - this.gap,
14462
+ width: bar.track.width + 2 * arrows,
14463
+ height: bar.track.height + this.gap
14464
+ };
14465
+ }
14466
+ _listening() {
14467
+ return this._onChange !== undefined || this.listenerCount("change") > 0;
14468
+ }
14469
+ _native() {
14470
+ return {
14471
+ policy: this.policy,
14472
+ overlay: this.overlay,
14473
+ thickness: this.thickness,
14474
+ gap: this.gap,
14475
+ arrows: this._showArrows,
14476
+ foregroundColor: this.trackForeground,
14477
+ backgroundColor: this.trackBackground
14478
+ };
14479
+ }
14480
+ _arrows() {
14481
+ const options = this._arrowOptions;
14482
+ const background = options.backgroundColor ?? undefined;
14483
+ const foreground = options.foregroundColor ?? background;
14484
+ const chars = options.arrowChars ?? {};
14485
+ return (this.axis === 1 ? ["up", "down"] : ["left", "right"]).map((direction) => ({
14486
+ attributes: options.attributes ?? 0,
14487
+ foregroundColor: RGBA2.clone(parseColor2(foreground || defaultArrowForeground2)),
14488
+ backgroundColor: RGBA2.clone(parseColor2(background || defaultArrowBackground2)),
14489
+ text: chars[direction]
14490
+ }));
14491
+ }
14492
+ _emitChange(position) {
14493
+ this._onChange?.(position);
14494
+ if (!this.box.isDestroyed)
14495
+ this.emit("change", { position });
14496
+ }
14497
+ get visible() {
14498
+ return this.box._scrollState().bars[this.axis].visible;
14499
+ }
14500
+ set visible(value) {
14501
+ this.setOption(() => this.policy = value == null ? "auto" : value ? "always" : "never");
14502
+ }
14503
+ resetVisibilityControl() {
14504
+ this.visible = null;
14505
+ }
14506
+ get onChange() {
14507
+ return this._onChange;
14508
+ }
14509
+ set onChange(handler) {
14510
+ this._onChange = handler ?? undefined;
14511
+ this.box._refreshScrollHook();
14512
+ }
14513
+ get showArrows() {
14514
+ return this._showArrows;
14515
+ }
14516
+ set showArrows(value) {
14517
+ this.setOption(() => this._showArrows = value ?? false);
14518
+ }
14519
+ set arrowOptions(options) {
14520
+ this._arrowOptions = { ...this._arrowOptions, ...options };
14521
+ if (!this.box.isDestroyed)
14522
+ this.box._applyScrollArrows(this.axis);
14523
+ }
14524
+ set trackOptions(options) {
14525
+ this.setOption(() => {
14526
+ if (options && "foregroundColor" in options) {
14527
+ this.trackForeground = RGBA2.clone(parseColor2(options.foregroundColor ?? defaultThumb));
14528
+ }
14529
+ if (options && "backgroundColor" in options) {
14530
+ this.trackBackground = RGBA2.clone(parseColor2(options.backgroundColor ?? defaultTrack));
14531
+ }
14532
+ });
14533
+ }
14534
+ get width() {
14535
+ return super.width;
14536
+ }
14537
+ set width(value) {
14538
+ if (this.axis === 1)
14539
+ this.setOption(() => this.thickness = Math.max(1, cells(value, 1)));
14540
+ }
14541
+ get height() {
14542
+ return super.height;
14543
+ }
14544
+ set height(value) {
14545
+ if (this.axis === 0)
14546
+ this.setOption(() => this.thickness = Math.max(1, cells(value, 1)));
14547
+ }
14548
+ set paddingLeft(value) {
14549
+ if (this.axis === 1)
14550
+ this.setOption(() => this.gap = cells(value, 0));
14551
+ }
14552
+ set paddingTop(value) {
14553
+ if (this.axis === 0)
14554
+ this.setOption(() => this.gap = cells(value, 0));
14555
+ }
14556
+ set position(value) {
14557
+ this.setOption(() => this.overlay = value === "absolute");
14558
+ }
14559
+ setOption(change) {
14560
+ if (this.box.isDestroyed)
13908
14561
  return;
13909
- this._ctx.nativeScene.setViewport(this, value ? this.viewport : null);
13910
- this._viewportCulling = value;
14562
+ change();
14563
+ this.box._applyScrollOptions();
14564
+ }
14565
+ get scrollSize() {
14566
+ const { content } = this.box._scrollState();
14567
+ return this.axis === 1 ? content.height : content.width;
14568
+ }
14569
+ get viewportSize() {
14570
+ const { viewport } = this.box._scrollState();
14571
+ return this.axis === 1 ? viewport.height : viewport.width;
14572
+ }
14573
+ get scrollPosition() {
14574
+ return this.box._scrollState().offset[this.axis];
14575
+ }
14576
+ set scrollPosition(value) {
14577
+ this.box._scrollAxis(this.axis, value, false);
14578
+ }
14579
+ scrollBy(delta, unit = "absolute") {
14580
+ this.box._scrollAxis(this.axis, scrollUnitSize(this, unit) * delta, true, true);
14581
+ }
14582
+ handleKeyPress(key) {
14583
+ return ScrollBarRenderable.prototype.handleKeyPress.call(this, key);
13911
14584
  }
13912
14585
  }
14586
+ function cells(value, fallback) {
14587
+ return typeof value === "number" && Number.isFinite(value) ? Math.max(0, Math.min(255, Math.trunc(value))) : fallback;
14588
+ }
14589
+
14590
+ // src/renderables/ScrollBox.ts
13913
14591
  var SCROLLBOX_PADDING_KEYS = [
13914
14592
  "padding",
13915
14593
  "paddingX",
@@ -13946,18 +14624,20 @@ class ScrollBoxRenderable extends BoxRenderable2 {
13946
14624
  update: {
13947
14625
  idle: this.prototype.onUpdate,
13948
14626
  active: (renderable) => renderable["isAutoScrolling"]
14627
+ },
14628
+ scroll: {
14629
+ active: (renderable) => renderable.scrollHook,
14630
+ notify: (renderable) => renderable.notifyScroll()
13949
14631
  }
13950
14632
  }
13951
14633
  };
13952
- static idCounter = 0;
13953
- internalId = 0;
13954
14634
  wrapper;
13955
14635
  viewport;
13956
14636
  content;
13957
14637
  horizontalScrollBar;
13958
14638
  verticalScrollBar;
13959
14639
  static defaultFocusable = true;
13960
- selectionListener;
14640
+ selectionListener = () => this.stopAutoScroll();
13961
14641
  autoScrollMouseX = 0;
13962
14642
  autoScrollMouseY = 0;
13963
14643
  autoScrollThresholdVertical = 3;
@@ -13972,126 +14652,70 @@ class ScrollBoxRenderable extends BoxRenderable2 {
13972
14652
  scrollAccumulatorX = 0;
13973
14653
  scrollAccumulatorY = 0;
13974
14654
  _stickyScroll;
13975
- _stickyScrollTop = false;
13976
- _stickyScrollBottom = false;
13977
- _stickyScrollLeft = false;
13978
- _stickyScrollRight = false;
13979
14655
  _stickyStart;
13980
- _hasManualScroll = false;
13981
- _isApplyingStickyScroll = false;
13982
14656
  scrollAccel;
14657
+ axes;
14658
+ _viewportCulling;
14659
+ state = emptySceneScrollState();
14660
+ stateRevision;
14661
+ scrollHook = false;
14662
+ configured = false;
14663
+ barPress;
14664
+ layoutCallbacks = [];
14665
+ anchorToken;
13983
14666
  get stickyScroll() {
13984
14667
  return this._stickyScroll;
13985
14668
  }
13986
14669
  set stickyScroll(value) {
13987
- this._stickyScroll = value;
13988
- this.updateStickyState();
14670
+ this.setScrollOption(() => this._stickyScroll = value);
13989
14671
  }
13990
14672
  get stickyStart() {
13991
14673
  return this._stickyStart;
13992
14674
  }
13993
14675
  set stickyStart(value) {
13994
- this._stickyStart = value;
13995
- this.updateStickyState();
14676
+ this.setScrollOption(() => this._stickyStart = value);
14677
+ }
14678
+ setScrollOption(change) {
14679
+ const previous = [this._stickyScroll, this._stickyStart, this._viewportCulling];
14680
+ change();
14681
+ try {
14682
+ this._applyScrollOptions();
14683
+ } catch (error) {
14684
+ [this._stickyScroll, this._stickyStart, this._viewportCulling] = previous;
14685
+ throw error;
14686
+ }
14687
+ }
14688
+ get scrollX() {
14689
+ return this.axes.x;
14690
+ }
14691
+ set scrollX(value) {
14692
+ this.axes.x = value ?? false;
14693
+ this._applyScrollOptions();
14694
+ }
14695
+ get scrollY() {
14696
+ return this.axes.y;
14697
+ }
14698
+ set scrollY(value) {
14699
+ this.axes.y = value ?? true;
14700
+ this._applyScrollOptions();
13996
14701
  }
13997
14702
  get scrollTop() {
13998
- return this.verticalScrollBar.scrollPosition;
14703
+ return this._scrollState().offset[1];
13999
14704
  }
14000
14705
  set scrollTop(value) {
14001
- this.verticalScrollBar.scrollPosition = value;
14002
- this.updateStickyState();
14706
+ this._scrollAxis(1, value, false);
14003
14707
  }
14004
14708
  get scrollLeft() {
14005
- return this.horizontalScrollBar.scrollPosition;
14709
+ return this._scrollState().offset[0];
14006
14710
  }
14007
14711
  set scrollLeft(value) {
14008
- this.horizontalScrollBar.scrollPosition = value;
14009
- this.updateStickyState();
14712
+ this._scrollAxis(0, value, false);
14010
14713
  }
14011
14714
  get scrollWidth() {
14012
- return this.horizontalScrollBar.scrollSize;
14715
+ return this._scrollState().content.width;
14013
14716
  }
14014
14717
  get scrollHeight() {
14015
- return this.verticalScrollBar.scrollSize;
14016
- }
14017
- updateStickyState() {
14018
- if (this.isDestroyed)
14019
- return;
14020
- if (!this._stickyScroll) {
14021
- this.syncManualScrollState();
14022
- return;
14023
- }
14024
- const maxScrollTop = Math.max(0, this.scrollHeight - this.viewport.height);
14025
- const maxScrollLeft = Math.max(0, this.scrollWidth - this.viewport.width);
14026
- if (this.scrollTop <= 0) {
14027
- this._stickyScrollTop = true;
14028
- this._stickyScrollBottom = false;
14029
- } else if (this.scrollTop >= maxScrollTop) {
14030
- this._stickyScrollTop = false;
14031
- this._stickyScrollBottom = true;
14032
- } else {
14033
- this._stickyScrollTop = false;
14034
- this._stickyScrollBottom = false;
14035
- }
14036
- if (this.scrollLeft <= 0) {
14037
- this._stickyScrollLeft = true;
14038
- this._stickyScrollRight = false;
14039
- } else if (this.scrollLeft >= maxScrollLeft) {
14040
- this._stickyScrollLeft = false;
14041
- this._stickyScrollRight = true;
14042
- } else {
14043
- this._stickyScrollLeft = false;
14044
- this._stickyScrollRight = false;
14045
- }
14046
- this.syncManualScrollState();
14047
- }
14048
- syncManualScrollState() {
14049
- if (this.isDestroyed)
14050
- return;
14051
- if (!this._stickyScroll) {
14052
- this._hasManualScroll = false;
14053
- return;
14054
- }
14055
- const maxScrollTop = Math.max(0, this.scrollHeight - this.viewport.height);
14056
- const maxScrollLeft = Math.max(0, this.scrollWidth - this.viewport.width);
14057
- const hasScrollableContent = maxScrollTop > 1 || maxScrollLeft > 1;
14058
- if (this._isApplyingStickyScroll) {
14059
- if (this._hasManualScroll && hasScrollableContent && this.isAtStickyPosition()) {
14060
- this._hasManualScroll = false;
14061
- }
14062
- return;
14063
- }
14064
- this._hasManualScroll = hasScrollableContent && !this.isAtStickyPosition();
14065
- }
14066
- applyStickyStart(stickyStart) {
14067
- const wasApplyingStickyScroll = this._isApplyingStickyScroll;
14068
- this._isApplyingStickyScroll = true;
14069
- try {
14070
- switch (stickyStart) {
14071
- case "top":
14072
- this._stickyScrollTop = true;
14073
- this._stickyScrollBottom = false;
14074
- this.verticalScrollBar.scrollPosition = 0;
14075
- break;
14076
- case "bottom":
14077
- this._stickyScrollTop = false;
14078
- this._stickyScrollBottom = true;
14079
- this.verticalScrollBar.scrollPosition = Math.max(0, this.scrollHeight - this.viewport.height);
14080
- break;
14081
- case "left":
14082
- this._stickyScrollLeft = true;
14083
- this._stickyScrollRight = false;
14084
- this.horizontalScrollBar.scrollPosition = 0;
14085
- break;
14086
- case "right":
14087
- this._stickyScrollLeft = false;
14088
- this._stickyScrollRight = true;
14089
- this.horizontalScrollBar.scrollPosition = Math.max(0, this.scrollWidth - this.viewport.width);
14090
- break;
14091
- }
14092
- } finally {
14093
- this._isApplyingStickyScroll = wasApplyingStickyScroll;
14094
- }
14718
+ return this._scrollState().content.height;
14095
14719
  }
14096
14720
  constructor(ctx, options) {
14097
14721
  const {
@@ -14116,114 +14740,183 @@ class ScrollBoxRenderable extends BoxRenderable2 {
14116
14740
  };
14117
14741
  const sanitizedRootBoxOptions = stripScrollBoxPadding(rootBoxOptions);
14118
14742
  const sanitizedRootOptions = rootOptions ? stripScrollBoxPadding(rootOptions) : undefined;
14119
- const mergedContentOptions = {
14120
- ...forwardedContentPadding,
14121
- ...contentOptions
14122
- };
14123
14743
  super(ctx, {
14124
14744
  flexDirection: "row",
14125
14745
  alignItems: "stretch",
14126
14746
  ...sanitizedRootBoxOptions,
14127
- ...sanitizedRootOptions
14747
+ ...sanitizedRootOptions,
14748
+ overflow: "hidden"
14128
14749
  });
14129
- const children = [];
14130
14750
  try {
14131
- this.internalId = ScrollBoxRenderable.idCounter++;
14132
14751
  this._stickyScroll = stickyScroll;
14133
14752
  this._stickyStart = stickyStart;
14134
14753
  this.scrollAccel = scrollAcceleration ?? new LinearScrollAccel2;
14135
- this.wrapper = new BoxRenderable2(ctx, {
14136
- flexDirection: "column",
14137
- flexGrow: 1,
14138
- ...wrapperOptions,
14139
- id: `scroll-box-wrapper-${this.internalId}`
14140
- });
14141
- children.push(this.wrapper);
14142
- super.add(this.wrapper);
14143
- this.viewport = new BoxRenderable2(ctx, {
14144
- flexDirection: "column",
14145
- flexGrow: 1,
14146
- overflow: "hidden",
14147
- onSizeChange: () => {
14148
- this.recalculateBarProps();
14149
- },
14150
- ...viewportOptions,
14151
- id: `scroll-box-viewport-${this.internalId}`
14152
- });
14153
- children.push(this.viewport);
14154
- this.wrapper.add(this.viewport);
14155
- this.content = new ContentRenderable(ctx, this.viewport, viewportCulling, {
14156
- alignSelf: "flex-start",
14157
- flexShrink: 0,
14158
- ...scrollX ? { minWidth: "100%" } : { minWidth: "100%", maxWidth: "100%" },
14159
- ...scrollY ? { minHeight: "100%" } : { minHeight: "100%", maxHeight: "100%" },
14160
- onSizeChange: () => {
14161
- this.recalculateBarProps();
14162
- },
14163
- ...mergedContentOptions,
14164
- id: `scroll-box-content-${this.internalId}`
14165
- });
14166
- children.push(this.content);
14167
- this.viewport.add(this.content);
14168
- this.verticalScrollBar = new ScrollBarRenderable(ctx, {
14169
- ...scrollbarOptions,
14170
- ...verticalScrollbarOptions,
14171
- arrowOptions: {
14172
- ...scrollbarOptions?.arrowOptions,
14173
- ...verticalScrollbarOptions?.arrowOptions
14174
- },
14175
- id: `scroll-box-vertical-scrollbar-${this.internalId}`,
14176
- orientation: "vertical",
14177
- onChange: (position) => {
14178
- if (this.isDestroyed)
14179
- return;
14180
- this.content.translateY = -position;
14181
- this.updateStickyState();
14182
- }
14183
- });
14184
- children.push(this.verticalScrollBar);
14185
- super.add(this.verticalScrollBar);
14186
- this.horizontalScrollBar = new ScrollBarRenderable(ctx, {
14187
- ...scrollbarOptions,
14188
- ...horizontalScrollbarOptions,
14189
- arrowOptions: {
14190
- ...scrollbarOptions?.arrowOptions,
14191
- ...horizontalScrollbarOptions?.arrowOptions
14192
- },
14193
- id: `scroll-box-horizontal-scrollbar-${this.internalId}`,
14194
- orientation: "horizontal",
14195
- onChange: (position) => {
14196
- if (this.isDestroyed)
14197
- return;
14198
- this.content.translateX = -position;
14199
- this.updateStickyState();
14200
- }
14201
- });
14202
- children.push(this.horizontalScrollBar);
14203
- this.wrapper.add(this.horizontalScrollBar);
14204
- this.recalculateBarProps();
14205
- if (stickyStart && stickyScroll) {
14206
- this.applyStickyStart(stickyStart);
14207
- }
14208
- this.selectionListener = () => {
14209
- if (this.isDestroyed)
14210
- return;
14211
- const selection = this._ctx.getSelection();
14212
- if (!selection || !selection.isDragging) {
14213
- this.stopAutoScroll();
14214
- }
14215
- };
14216
- this._ctx.on("selection", this.selectionListener);
14754
+ this.axes = { x: scrollX, y: scrollY };
14755
+ this._viewportCulling = viewportCulling;
14756
+ this.wrapper = new ScrollBoxWrapper(this);
14757
+ this.viewport = new ScrollBoxViewport(this);
14758
+ this.content = new ScrollBoxContent(this);
14759
+ this.verticalScrollBar = new ScrollBoxBar(this, "vertical");
14760
+ this.horizontalScrollBar = new ScrollBoxBar(this, "horizontal");
14761
+ this.wrapper._assign(wrapperOptions, ScrollBoxWrapper.keys);
14762
+ this.viewport._assign(viewportOptions, ScrollBoxViewport.keys);
14763
+ for (const [bar, own] of [
14764
+ [this.verticalScrollBar, verticalScrollbarOptions],
14765
+ [this.horizontalScrollBar, horizontalScrollbarOptions]
14766
+ ]) {
14767
+ bar._assign({ ...scrollbarOptions, ...own, arrowOptions: { ...scrollbarOptions?.arrowOptions, ...own?.arrowOptions } }, ScrollBoxBar.keys);
14768
+ }
14769
+ this.configured = true;
14770
+ this._applyScrollOptions();
14771
+ this._applyScrollArrows(0);
14772
+ this._applyScrollArrows(1);
14773
+ this.content._assign({ ...forwardedContentPadding, ...contentOptions }, ScrollBoxContent.keys);
14774
+ this._refreshScrollHook();
14217
14775
  this.setNativeScenePaint();
14218
14776
  } catch (error) {
14219
- this.abortConstruction(error, (run) => {
14220
- run(() => this.destroySelf());
14221
- for (let index = children.length - 1;index >= 0; index--) {
14222
- run(() => children[index].destroyRecursively());
14223
- }
14224
- });
14777
+ this.abortConstruction(error, (run) => run(() => this.destroySelf()));
14225
14778
  }
14226
14779
  }
14780
+ _applyScrollOptions() {
14781
+ if (!this.configured || this.isFreed())
14782
+ return;
14783
+ const sticky = this._stickyScroll && this._stickyStart;
14784
+ this._ctx.nativeScene.setScroll(this, {
14785
+ scrollX: this.axes.x,
14786
+ scrollY: this.axes.y,
14787
+ follow: sticky ? this._stickyStart : "none",
14788
+ culling: this._viewportCulling,
14789
+ padding: this.viewport._edges(),
14790
+ fills: [this.wrapper._fill(), this.viewport._fill(), this.content._fill()],
14791
+ bars: [this.horizontalScrollBar._native(), this.verticalScrollBar._native()]
14792
+ });
14793
+ this.requestRender();
14794
+ }
14795
+ _applyScrollArrows(axis) {
14796
+ if (!this.configured || this.isFreed())
14797
+ return;
14798
+ const bar = axis === 1 ? this.verticalScrollBar : this.horizontalScrollBar;
14799
+ bar._arrows().forEach((arrow, end) => this._ctx.nativeScene.setScrollArrow(this, axis, end, arrow));
14800
+ this.requestRender();
14801
+ }
14802
+ _setContentStyle(apply) {
14803
+ if (this.isFreed())
14804
+ return;
14805
+ apply(this._ctx.nativeScene, this);
14806
+ this.requestRender();
14807
+ }
14808
+ _scrollState() {
14809
+ if (this.isFreed())
14810
+ return this.state;
14811
+ const revision = this._ctx.nativeScene.observedLayoutRevision;
14812
+ if (revision !== undefined && revision === this.stateRevision)
14813
+ return this.state;
14814
+ this.state = this._ctx.nativeScene.getScroll(this);
14815
+ this.stateRevision = revision;
14816
+ return this.state;
14817
+ }
14818
+ _wrapperRect() {
14819
+ const { viewport, bars } = this._scrollState();
14820
+ const horizontal = bars[0];
14821
+ const gutter = horizontal.visible ? horizontal.track.y + horizontal.track.height - viewport.y - viewport.height : 0;
14822
+ return { ...viewport, height: viewport.height + Math.max(0, gutter) };
14823
+ }
14824
+ _scrollAxis(axis, value, relative, reapply = false) {
14825
+ if (this.isFreed())
14826
+ return;
14827
+ this.assertMutable();
14828
+ value ??= 0;
14829
+ if (Number.isNaN(value))
14830
+ throw new RangeError("Scene scroll positions must be finite numbers");
14831
+ const x = axis === 0 ? value : 0;
14832
+ const y = axis === 1 ? value : 0;
14833
+ this.commitScroll(() => this._ctx.nativeScene.scrollTo(this, x, y, axis !== 0 || relative, axis !== 1 || relative, reapply));
14834
+ }
14835
+ commitScroll(scroll) {
14836
+ const before = this._scrollState().offset;
14837
+ const state = scroll();
14838
+ this.state = state;
14839
+ this.stateRevision = this._ctx.nativeScene.observedLayoutRevision;
14840
+ const moved = (state.offset[0] !== before[0] ? 1 : 0) | (state.offset[1] !== before[1] ? 2 : 0);
14841
+ if (moved)
14842
+ this.requestRender();
14843
+ this.notifyOffsets(state, moved);
14844
+ }
14845
+ notifyOffsets(state, moved) {
14846
+ for (const axis of [1, 0]) {
14847
+ if ((moved & axis + 1) === 0)
14848
+ continue;
14849
+ (axis === 1 ? this.verticalScrollBar : this.horizontalScrollBar)._emitChange(state.offset[axis]);
14850
+ if (this.isDestroyed)
14851
+ return;
14852
+ }
14853
+ }
14854
+ listening() {
14855
+ return this.verticalScrollBar?._listening() || this.horizontalScrollBar?._listening() || this.content?._listening() || this.viewport?._listening() || this.layoutCallbacks.length > 0;
14856
+ }
14857
+ _refreshScrollHook(adding = false) {
14858
+ if (!this.configured || this.isFreed())
14859
+ return;
14860
+ const listening = adding || this.listening();
14861
+ if (listening === this.scrollHook)
14862
+ return;
14863
+ this.scrollHook = listening;
14864
+ this.refreshNativeSceneHooks();
14865
+ }
14866
+ notifyScroll() {
14867
+ const state = this._scrollState();
14868
+ this.notifyOffsets(state, state.changes);
14869
+ if (!this.isDestroyed && state.changes & 8)
14870
+ this.viewport._emitResize();
14871
+ if (!this.isDestroyed && state.changes & 4)
14872
+ this.content._emitResize();
14873
+ if (this.isDestroyed || !(state.changes & 16))
14874
+ return;
14875
+ const frame = this._ctx.frameId;
14876
+ const due = this.layoutCallbacks.filter((entry) => entry.frame < frame);
14877
+ this.layoutCallbacks = this.layoutCallbacks.filter((entry) => entry.frame >= frame);
14878
+ if (this.layoutCallbacks.length > 0)
14879
+ this._ctx.nativeScene.scrollRequest(this, "layout", null);
14880
+ let failure;
14881
+ for (const { callback } of due) {
14882
+ if (this.isDestroyed)
14883
+ break;
14884
+ try {
14885
+ callback();
14886
+ } catch (error) {
14887
+ failure ??= { error };
14888
+ }
14889
+ }
14890
+ this._refreshScrollHook();
14891
+ if (failure)
14892
+ throw failure.error;
14893
+ }
14894
+ afterLayout(callback) {
14895
+ if (this.isFreed())
14896
+ return;
14897
+ this.assertMutable();
14898
+ this.layoutCallbacks.push({ frame: this._ctx.frameId, callback });
14899
+ this._refreshScrollHook();
14900
+ this._ctx.nativeScene.scrollRequest(this, "layout", null);
14901
+ this.requestRender();
14902
+ }
14903
+ anchor(node) {
14904
+ if (this.isFreed())
14905
+ return () => {};
14906
+ this.assertMutable();
14907
+ this._ctx.nativeScene.scrollRequest(this, "anchor", node);
14908
+ const token = {};
14909
+ this.anchorToken = token;
14910
+ return () => {
14911
+ if (this.anchorToken !== token || this.isFreed())
14912
+ return;
14913
+ this._ctx.nativeScene.scrollRequest(this, "anchor", null);
14914
+ this.anchorToken = undefined;
14915
+ };
14916
+ }
14917
+ get primaryAxis() {
14918
+ return this.content._row ? "row" : "column";
14919
+ }
14227
14920
  onUpdate(deltaTime) {
14228
14921
  this.handleAutoScroll(deltaTime);
14229
14922
  }
@@ -14237,120 +14930,42 @@ class ScrollBoxRenderable extends BoxRenderable2 {
14237
14930
  this.horizontalScrollBar.scrollBy(delta.x, unit);
14238
14931
  }
14239
14932
  }
14240
- scrollChildIntoView(childId) {
14241
- const child = this.content.findDescendantById(childId);
14242
- if (!child)
14933
+ scrollChildIntoView(child, options = {}) {
14934
+ const node = typeof child === "string" ? this.findDescendantById(child) : child;
14935
+ if (!node || this.isFreed())
14243
14936
  return;
14244
- const getNearestDelta = (elementStart, elementEnd, viewportStart, viewportEnd) => {
14245
- const elementSize = elementEnd - elementStart;
14246
- const viewportSize = viewportEnd - viewportStart;
14247
- const elementStartOutside = elementStart < viewportStart;
14248
- const elementEndOutside = elementEnd > viewportEnd;
14249
- if (elementStartOutside && elementEndOutside) {
14250
- return 0;
14251
- }
14252
- if (elementStartOutside && elementSize < viewportSize || elementEndOutside && elementSize > viewportSize) {
14253
- return elementStart - viewportStart;
14254
- }
14255
- if (elementStartOutside && elementSize > viewportSize || elementEndOutside && elementSize < viewportSize) {
14256
- return elementEnd - viewportEnd;
14257
- }
14258
- return 0;
14259
- };
14260
- const childTop = child.y;
14261
- const childBottom = child.y + child.height;
14262
- const viewportTop = this.viewport.y;
14263
- const viewportBottom = this.viewport.y + this.viewport.height;
14264
- const dy = getNearestDelta(childTop, childBottom, viewportTop, viewportBottom);
14265
- const childLeft = child.x;
14266
- const childRight = child.x + child.width;
14267
- const viewportLeft = this.viewport.x;
14268
- const viewportRight = this.viewport.x + this.viewport.width;
14269
- const dx = getNearestDelta(childLeft, childRight, viewportLeft, viewportRight);
14270
- if (dx !== 0 || dy !== 0) {
14271
- this.scrollBy({ x: dx, y: dy });
14272
- }
14937
+ this.assertMutable();
14938
+ this.commitScroll(() => this._ctx.nativeScene.scrollRequest(this, "into-view", node, options.align, options.inset));
14273
14939
  }
14274
14940
  scrollTo(position) {
14275
14941
  if (typeof position === "number") {
14276
- this.scrollTop = position;
14942
+ this._scrollAxis(1, position, false, true);
14277
14943
  } else {
14278
- this.scrollTop = position.y;
14944
+ this._scrollAxis(1, position.y, false, true);
14279
14945
  if (this.isDestroyed)
14280
14946
  return;
14281
- this.scrollLeft = position.x;
14282
- }
14283
- }
14284
- isAtStickyPosition() {
14285
- if (!this._stickyScroll || !this._stickyStart) {
14286
- return false;
14947
+ this._scrollAxis(0, position.x, false, true);
14287
14948
  }
14288
- const maxScrollTop = Math.max(0, this.scrollHeight - this.viewport.height);
14289
- const maxScrollLeft = Math.max(0, this.scrollWidth - this.viewport.width);
14290
- switch (this._stickyStart) {
14291
- case "top":
14292
- return this.scrollTop === 0;
14293
- case "bottom":
14294
- return this.scrollTop >= maxScrollTop;
14295
- case "left":
14296
- return this.scrollLeft === 0;
14297
- case "right":
14298
- return this.scrollLeft >= maxScrollLeft;
14299
- default:
14300
- return false;
14301
- }
14302
- }
14303
- isAtStickyReengagePoint(stickyStart, maxScrollTop, maxScrollLeft) {
14304
- switch (stickyStart) {
14305
- case "top":
14306
- return maxScrollTop > 0 && this.scrollTop <= 0;
14307
- case "bottom":
14308
- return maxScrollTop > 0 && this.scrollTop >= maxScrollTop - 1;
14309
- case "left":
14310
- return maxScrollLeft > 0 && this.scrollLeft <= 0;
14311
- case "right":
14312
- return maxScrollLeft > 0 && this.scrollLeft >= maxScrollLeft - 1;
14313
- }
14314
- }
14315
- add(obj, index) {
14316
- return this.content.add(obj, index);
14317
- }
14318
- insertBefore(obj, anchor) {
14319
- return this.content.insertBefore(obj, anchor);
14320
- }
14321
- remove(child) {
14322
- if (child.parent === this) {
14323
- super.remove(child);
14324
- return;
14325
- }
14326
- this.content.remove(child);
14327
- }
14328
- getChildren() {
14329
- return this.content.getChildren();
14330
- }
14331
- getRenderable(id) {
14332
- return this.content.getRenderable(id);
14333
14949
  }
14334
14950
  scrollByWheel(event) {
14335
14951
  const dir = wheelDirection(event);
14336
14952
  const vertical = dir === "up" || dir === "down";
14337
14953
  if (!vertical && dir !== "left" && dir !== "right")
14338
14954
  return false;
14339
- const bar = vertical ? this.verticalScrollBar : this.horizontalScrollBar;
14955
+ const axis = vertical ? 1 : 0;
14340
14956
  const sign = dir === "up" || dir === "left" ? -1 : 1;
14341
- const position = bar.scrollPosition;
14342
- if (sign < 0 ? position <= 0 : position >= bar.scrollSize - bar.viewportSize)
14957
+ const { offset, max } = this._scrollState();
14958
+ const position = offset[axis];
14959
+ if (sign < 0 ? position <= 0 : position >= max[axis])
14343
14960
  return false;
14344
14961
  let remainder = vertical ? this.scrollAccumulatorY : this.scrollAccumulatorX;
14345
14962
  if (remainder * sign < 0)
14346
14963
  remainder = 0;
14347
14964
  remainder += sign * (event.scroll?.delta ?? 0) * this.scrollAccel.tick(Date.now());
14348
14965
  const step = Math.trunc(remainder);
14349
- if (step !== 0 && vertical)
14350
- this.scrollTop = position + step;
14351
- else if (step !== 0)
14352
- this.scrollLeft = position + step;
14353
- remainder = bar.scrollPosition - position === step ? remainder - step : 0;
14966
+ if (step !== 0)
14967
+ this._scrollAxis(axis, position + step, false);
14968
+ remainder = this._scrollState().offset[axis] - position === step ? remainder - step : 0;
14354
14969
  if (vertical)
14355
14970
  this.scrollAccumulatorY = remainder;
14356
14971
  else
@@ -14360,23 +14975,97 @@ class ScrollBoxRenderable extends BoxRenderable2 {
14360
14975
  onMouseEvent(event) {
14361
14976
  if (event.type === "scroll")
14362
14977
  scrollOnce(event, this, () => this.scrollByWheel(event));
14978
+ if (this.handleBarMouse(event))
14979
+ return;
14363
14980
  if (event.type === "drag" && event.isDragging) {
14364
14981
  this.updateAutoScroll(event.x, event.y);
14365
14982
  } else if (event.type === "up") {
14366
14983
  this.stopAutoScroll();
14367
14984
  }
14368
14985
  }
14369
- handleKeyPress(key) {
14370
- if (this.verticalScrollBar.handleKeyPress(key)) {
14371
- this.scrollAccel.reset();
14372
- this.resetScrollAccumulators();
14373
- this.syncManualScrollState();
14986
+ handleBarMouse(event) {
14987
+ const press = this.barPress;
14988
+ if (press && (event.type === "drag" || event.type === "up" || event.type === "drag-end")) {
14989
+ if ("offset" in press && event.type !== "drag-end")
14990
+ this.dragThumb(press, event);
14991
+ if (event.type === "up")
14992
+ this.endBarPress();
14993
+ event.stopPropagation();
14994
+ return true;
14995
+ }
14996
+ if (event.type !== "down" || event.button !== 0 || event.target !== this)
14997
+ return false;
14998
+ const { bars } = this._scrollState();
14999
+ for (const axis of [1, 0]) {
15000
+ const bar = bars[axis];
15001
+ if (!bar.visible)
15002
+ continue;
15003
+ const part = axis === 1 ? this.verticalScrollBar : this.horizontalScrollBar;
15004
+ const inside = (rect) => event.x >= rect.x && event.x < rect.x + rect.width && event.y >= rect.y && event.y < rect.y + rect.height;
15005
+ const arrow = part.showArrows ? inside(bar.startArrow) ? -1 : inside(bar.endArrow) ? 1 : 0 : 0;
15006
+ if (arrow === 0 && !inside(bar.track))
15007
+ continue;
15008
+ event.stopPropagation();
15009
+ event.preventDefault();
15010
+ this.endBarPress();
15011
+ if (arrow !== 0)
15012
+ this.pressArrow(axis, arrow, part);
15013
+ else
15014
+ this.pressTrack(axis, event);
14374
15015
  return true;
14375
15016
  }
14376
- if (this.horizontalScrollBar.handleKeyPress(key)) {
15017
+ return false;
15018
+ }
15019
+ pressArrow(axis, arrow, part) {
15020
+ const press = { axis, arrow, timer: undefined };
15021
+ this.barPress = press;
15022
+ const step = (amount, delay) => {
15023
+ part.scrollBy(arrow * amount, "viewport");
15024
+ if (this.barPress !== press)
15025
+ return;
15026
+ press.timer = this._ctx.clock.setTimeout(() => step(delay === 500 ? 0.5 : 0.2, 200), delay);
15027
+ };
15028
+ step(0.5, 500);
15029
+ }
15030
+ thumbPointer(axis, event) {
15031
+ const bar = this._scrollState().bars[axis];
15032
+ const along = axis === 1 ? event.y - bar.track.y : event.x - bar.track.x;
15033
+ const length = axis === 1 ? bar.track.height : bar.track.width;
15034
+ return {
15035
+ at: Math.max(0, Math.min(length, along)) * 2,
15036
+ length: length * 2,
15037
+ start: bar.thumbStart,
15038
+ size: bar.thumbSize
15039
+ };
15040
+ }
15041
+ pressTrack(axis, event) {
15042
+ let thumb = this.thumbPointer(axis, event);
15043
+ const inThumb = thumb.at >= Math.floor(thumb.start / 2) * 2 && thumb.at < Math.ceil((thumb.start + thumb.size) / 2) * 2;
15044
+ if (!inThumb) {
15045
+ const max = this._scrollState().max[axis];
15046
+ this._scrollAxis(axis, thumb.length === 0 ? 0 : thumb.at / thumb.length * max, false);
15047
+ if (this.isDestroyed)
15048
+ return;
15049
+ thumb = this.thumbPointer(axis, event);
15050
+ }
15051
+ this.barPress = { axis, offset: Math.max(0, Math.min(thumb.size, thumb.at - thumb.start)) };
15052
+ }
15053
+ dragThumb(press, event) {
15054
+ const thumb = this.thumbPointer(press.axis, event);
15055
+ const span = Math.max(0, thumb.length - thumb.size);
15056
+ const start = Math.max(0, Math.min(span, thumb.at - press.offset));
15057
+ this._scrollAxis(press.axis, span === 0 ? 0 : start / span * this._scrollState().max[press.axis], false);
15058
+ }
15059
+ endBarPress() {
15060
+ const press = this.barPress;
15061
+ this.barPress = undefined;
15062
+ if (press && "timer" in press && press.timer !== undefined)
15063
+ this._ctx.clock.clearTimeout(press.timer);
15064
+ }
15065
+ handleKeyPress(key) {
15066
+ if (this.verticalScrollBar.handleKeyPress(key) || this.horizontalScrollBar.handleKeyPress(key)) {
14377
15067
  this.scrollAccel.reset();
14378
15068
  this.resetScrollAccumulators();
14379
- this.syncManualScrollState();
14380
15069
  return true;
14381
15070
  }
14382
15071
  return false;
@@ -14386,12 +15075,15 @@ class ScrollBoxRenderable extends BoxRenderable2 {
14386
15075
  this.scrollAccumulatorY = 0;
14387
15076
  }
14388
15077
  startAutoScroll(mouseX, mouseY) {
15078
+ if (this.isDestroyed)
15079
+ return;
14389
15080
  this.stopAutoScroll();
14390
15081
  this.autoScrollMouseX = mouseX;
14391
15082
  this.autoScrollMouseY = mouseY;
14392
15083
  this.cachedAutoScrollSpeed = this.getAutoScrollSpeed(mouseX, mouseY);
14393
15084
  this.isAutoScrolling = true;
14394
15085
  this.live = true;
15086
+ this._ctx.on("selection", this.selectionListener);
14395
15087
  this.refreshNativeSceneHooks();
14396
15088
  }
14397
15089
  updateAutoScroll(mouseX, mouseY) {
@@ -14412,6 +15104,7 @@ class ScrollBoxRenderable extends BoxRenderable2 {
14412
15104
  this.autoScrollAccumulatorX = 0;
14413
15105
  this.autoScrollAccumulatorY = 0;
14414
15106
  if (wasAutoScrolling) {
15107
+ this._ctx.off("selection", this.selectionListener);
14415
15108
  this.live = false;
14416
15109
  this.refreshNativeSceneHooks();
14417
15110
  }
@@ -14459,8 +15152,7 @@ class ScrollBoxRenderable extends BoxRenderable2 {
14459
15152
  if (distToLeft <= this.autoScrollThresholdHorizontal) {
14460
15153
  return this.scrollLeft > 0 ? -1 : 0;
14461
15154
  } else if (distToRight <= this.autoScrollThresholdHorizontal) {
14462
- const maxScrollLeft = this.scrollWidth - this.viewport.width;
14463
- return this.scrollLeft < maxScrollLeft ? 1 : 0;
15155
+ return this.scrollLeft < this._scrollState().max[0] ? 1 : 0;
14464
15156
  }
14465
15157
  return 0;
14466
15158
  }
@@ -14471,8 +15163,7 @@ class ScrollBoxRenderable extends BoxRenderable2 {
14471
15163
  if (distToTop <= this.autoScrollThresholdVertical) {
14472
15164
  return this.scrollTop > 0 ? -1 : 0;
14473
15165
  } else if (distToBottom <= this.autoScrollThresholdVertical) {
14474
- const maxScrollTop = this.scrollHeight - this.viewport.height;
14475
- return this.scrollTop < maxScrollTop ? 1 : 0;
15166
+ return this.scrollTop < this._scrollState().max[1] ? 1 : 0;
14476
15167
  }
14477
15168
  return 0;
14478
15169
  }
@@ -14492,115 +15183,31 @@ class ScrollBoxRenderable extends BoxRenderable2 {
14492
15183
  return this.autoScrollSpeedSlow;
14493
15184
  }
14494
15185
  }
14495
- recalculateBarProps() {
14496
- if (this.isDestroyed)
14497
- return;
14498
- const wasApplyingStickyScroll = this._isApplyingStickyScroll;
14499
- this._isApplyingStickyScroll = true;
14500
- try {
14501
- this.verticalScrollBar.scrollSize = this.content.height;
14502
- if (this.isDestroyed)
14503
- return;
14504
- this.verticalScrollBar.viewportSize = this.viewport.height;
14505
- if (this.isDestroyed)
14506
- return;
14507
- this.horizontalScrollBar.scrollSize = this.content.width;
14508
- if (this.isDestroyed)
14509
- return;
14510
- this.horizontalScrollBar.viewportSize = this.viewport.width;
14511
- if (this.isDestroyed)
14512
- return;
14513
- if (this._stickyScroll) {
14514
- const newMaxScrollTop = Math.max(0, this.scrollHeight - this.viewport.height);
14515
- const newMaxScrollLeft = Math.max(0, this.scrollWidth - this.viewport.width);
14516
- const stickyStart = this._stickyStart;
14517
- if (stickyStart && !this._hasManualScroll) {
14518
- this.applyStickyStart(stickyStart);
14519
- } else if (stickyStart && this._hasManualScroll && this.isAtStickyReengagePoint(stickyStart, newMaxScrollTop, newMaxScrollLeft)) {
14520
- this._hasManualScroll = false;
14521
- this.applyStickyStart(stickyStart);
14522
- } else if (!this._hasManualScroll) {
14523
- if (this._stickyScrollTop) {
14524
- this.scrollTop = 0;
14525
- } else if (this._stickyScrollBottom && newMaxScrollTop > 0) {
14526
- this.scrollTop = newMaxScrollTop;
14527
- }
14528
- if (this.isDestroyed)
14529
- return;
14530
- if (this._stickyScrollLeft) {
14531
- this.scrollLeft = 0;
14532
- } else if (this._stickyScrollRight && newMaxScrollLeft > 0) {
14533
- this.scrollLeft = newMaxScrollLeft;
14534
- }
14535
- }
14536
- }
14537
- } finally {
14538
- this._isApplyingStickyScroll = wasApplyingStickyScroll;
14539
- }
14540
- }
14541
- set padding(value) {
14542
- this.content.padding = value;
14543
- this.requestRender();
14544
- }
14545
- set paddingX(value) {
14546
- this.content.paddingX = value;
14547
- this.requestRender();
14548
- }
14549
- set paddingY(value) {
14550
- this.content.paddingY = value;
14551
- this.requestRender();
14552
- }
14553
- set paddingTop(value) {
14554
- this.content.paddingTop = value;
14555
- this.requestRender();
14556
- }
14557
- set paddingRight(value) {
14558
- this.content.paddingRight = value;
14559
- this.requestRender();
14560
- }
14561
- set paddingBottom(value) {
14562
- this.content.paddingBottom = value;
14563
- this.requestRender();
14564
- }
14565
- set paddingLeft(value) {
14566
- this.content.paddingLeft = value;
14567
- this.requestRender();
14568
- }
14569
15186
  set rootOptions(options) {
14570
- this.assignOptions(this, options);
15187
+ this.assignOptions(this, options && stripScrollBoxPadding(options));
15188
+ if (options)
15189
+ this.content._assign(pickScrollBoxPadding(options), ScrollBoxContent.keys);
14571
15190
  if (!this.isDestroyed)
14572
15191
  this.requestRender();
14573
15192
  }
14574
15193
  set wrapperOptions(options) {
14575
- this.assignOptions(this.wrapper, options);
14576
- if (!this.isDestroyed)
14577
- this.requestRender();
15194
+ this.wrapper._assign(options, ScrollBoxWrapper.keys);
14578
15195
  }
14579
15196
  set viewportOptions(options) {
14580
- this.assignOptions(this.viewport, options);
14581
- if (!this.isDestroyed)
14582
- this.requestRender();
15197
+ this.viewport._assign(options, ScrollBoxViewport.keys);
14583
15198
  }
14584
15199
  set contentOptions(options) {
14585
- this.assignOptions(this.content, options);
14586
- if (!this.isDestroyed)
14587
- this.requestRender();
15200
+ this.content._assign(options, ScrollBoxContent.keys);
14588
15201
  }
14589
15202
  set scrollbarOptions(options) {
14590
- this.assignOptions(this.verticalScrollBar, options);
14591
- this.assignOptions(this.horizontalScrollBar, options);
14592
- if (!this.isDestroyed)
14593
- this.requestRender();
15203
+ this.verticalScrollBar._assign(options ?? { onChange: undefined }, ScrollBoxBar.keys);
15204
+ this.horizontalScrollBar._assign(options ?? { onChange: undefined }, ScrollBoxBar.keys);
14594
15205
  }
14595
15206
  set verticalScrollbarOptions(options) {
14596
- this.assignOptions(this.verticalScrollBar, options);
14597
- if (!this.isDestroyed)
14598
- this.requestRender();
15207
+ this.verticalScrollBar._assign(options ?? { onChange: undefined }, ScrollBoxBar.keys);
14599
15208
  }
14600
15209
  set horizontalScrollbarOptions(options) {
14601
- this.assignOptions(this.horizontalScrollBar, options);
14602
- if (!this.isDestroyed)
14603
- this.requestRender();
15210
+ this.horizontalScrollBar._assign(options ?? { onChange: undefined }, ScrollBoxBar.keys);
14604
15211
  }
14605
15212
  get scrollAcceleration() {
14606
15213
  return this.scrollAccel;
@@ -14609,23 +15216,37 @@ class ScrollBoxRenderable extends BoxRenderable2 {
14609
15216
  this.scrollAccel = value;
14610
15217
  }
14611
15218
  get viewportCulling() {
14612
- return this.content.viewportCulling;
15219
+ return this._viewportCulling;
14613
15220
  }
14614
15221
  set viewportCulling(value) {
14615
- this.content.viewportCulling = value;
14616
- this.requestRender();
15222
+ this.setScrollOption(() => this._viewportCulling = value ?? true);
14617
15223
  }
15224
+ get overflow() {
15225
+ return "hidden";
15226
+ }
15227
+ set overflow(_value) {}
14618
15228
  destroySelf() {
14619
- const selectionListener = this.selectionListener;
14620
- this.selectionListener = undefined;
15229
+ if (!this.isFreed())
15230
+ this._scrollState();
15231
+ this.layoutCallbacks = [];
15232
+ this.endBarPress();
14621
15233
  this.runCleanup((run) => {
14622
- if (selectionListener)
14623
- run(() => this._ctx.off("selection", selectionListener));
15234
+ run(() => this._ctx.off("selection", this.selectionListener));
14624
15235
  run(() => super.destroySelf());
14625
15236
  });
14626
15237
  }
14627
15238
  }
15239
+ for (const key of SCROLLBOX_PADDING_KEYS) {
15240
+ Object.defineProperty(ScrollBoxRenderable.prototype, key, {
15241
+ configurable: true,
15242
+ set(value) {
15243
+ this.content[key] = value;
15244
+ }
15245
+ });
15246
+ }
14628
15247
  // src/renderables/Select.ts
15248
+ var transparent2 = RGBA2.fromValues(0, 0, 0, 0);
15249
+ var indicatorColor = parseColor2("#666666");
14629
15250
  var defaultSelectKeybindings = [
14630
15251
  { name: "up", action: "move-up" },
14631
15252
  { name: "k", action: "move-up" },
@@ -14686,7 +15307,7 @@ class SelectRenderable extends Renderable2 {
14686
15307
  fastScrollStep: 5
14687
15308
  };
14688
15309
  constructor(ctx, options) {
14689
- super(ctx, { ...options, buffered: true });
15310
+ super(ctx, options);
14690
15311
  try {
14691
15312
  this._options = options.options || [];
14692
15313
  const requestedIndex = options.selectedIndex ?? this._defaultOptions.selectedIndex;
@@ -14719,74 +15340,65 @@ class SelectRenderable extends Renderable2 {
14719
15340
  }
14720
15341
  }
14721
15342
  renderSelf(buffer, deltaTime) {
14722
- if (!this.visible || !this.frameBuffer)
14723
- return;
14724
- if (this.isDirty) {
14725
- this.refreshFrameBuffer();
14726
- }
14727
- }
14728
- refreshFrameBuffer() {
14729
- if (!this.frameBuffer)
14730
- return;
15343
+ const [x, y] = this._paintOrigin(buffer);
15344
+ const width = this._paintWidth;
15345
+ const height = this._paintHeight;
14731
15346
  const bgColor = this._focused ? this._focusedBackgroundColor : this._backgroundColor;
14732
- this.frameBuffer.clear(bgColor);
14733
- if (this._options.length === 0)
14734
- return;
14735
- const contentX = 0;
14736
- const contentY = 0;
14737
- const contentWidth = this.width;
14738
- const contentHeight = this.height;
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
+ }
14739
15366
  const visibleOptions = this._options.slice(this.scrollOffset, this.scrollOffset + this.maxVisibleItems);
14740
15367
  for (let i = 0;i < visibleOptions.length; i++) {
14741
- const actualIndex = this.scrollOffset + i;
14742
15368
  const option = visibleOptions[i];
14743
- const isSelected = actualIndex === this._selectedIndex;
14744
- const itemY = contentY + i * this.linesPerItem;
14745
- if (itemY + this.linesPerItem - 1 >= contentY + contentHeight)
15369
+ const isSelected = this.scrollOffset + i === this._selectedIndex;
15370
+ const itemY = y + i * this.linesPerItem;
15371
+ if (itemY + this.linesPerItem - 1 >= y + height)
14746
15372
  break;
14747
15373
  if (isSelected) {
14748
- const contentHeight = this.linesPerItem - this._itemSpacing;
14749
- this.frameBuffer.fillRect(contentX, itemY, contentWidth, contentHeight, this._selectedBackgroundColor);
15374
+ buffer.fillRect(x, itemY, width, selectedHeight, this._selectedBackgroundColor);
14750
15375
  }
14751
15376
  const indicator = this._showSelectionIndicator ? isSelected ? "▶ " : " " : "";
14752
- const indicatorWidth = this._showSelectionIndicator ? 2 : 0;
14753
- const nameContent = `${indicator}${option.name}`;
14754
15377
  const baseTextColor = this._focused ? this._focusedTextColor : this._textColor;
14755
15378
  const nameColor = isSelected ? this._selectedTextColor : baseTextColor;
14756
- const textX = contentX + 1 + indicatorWidth;
15379
+ const textX = x + 1 + (this._showSelectionIndicator ? 2 : 0);
14757
15380
  if (this._font) {
14758
- if (indicator) {
14759
- this.frameBuffer.drawText(indicator, contentX + 1, itemY, nameColor);
14760
- }
14761
- renderFontToFrameBuffer2(this.frameBuffer, {
15381
+ if (indicator)
15382
+ draw(indicator, x + 1, itemY, nameColor);
15383
+ renderFontToFrameBuffer2(buffer, {
14762
15384
  text: option.name,
14763
15385
  x: textX,
14764
15386
  y: itemY,
14765
15387
  color: nameColor,
14766
- backgroundColor: isSelected ? this._selectedBackgroundColor : bgColor,
15388
+ backgroundColor: transparent2,
14767
15389
  font: this._font
14768
15390
  });
14769
15391
  } else {
14770
- this.frameBuffer.drawText(nameContent, contentX + 1, itemY, nameColor);
15392
+ draw(`${indicator}${option.name}`, x + 1, itemY, nameColor);
14771
15393
  }
14772
- if (this._showDescription && itemY + this.fontHeight < contentY + contentHeight) {
15394
+ if (this._showDescription && itemY + this.fontHeight < y + height) {
14773
15395
  const descColor = isSelected ? this._selectedDescriptionColor : this._descriptionColor;
14774
- this.frameBuffer.drawText(option.description, textX, itemY + this.fontHeight, descColor);
15396
+ draw(option.description, textX, itemY + this.fontHeight, descColor);
14775
15397
  }
14776
15398
  }
14777
- if (this._showScrollIndicator && this._options.length > this.maxVisibleItems) {
14778
- this.renderScrollIndicatorToFrameBuffer(contentX, contentY, contentWidth, contentHeight);
14779
- }
14780
- }
14781
- renderScrollIndicatorToFrameBuffer(contentX, contentY, contentWidth, contentHeight) {
14782
- if (!this.frameBuffer)
14783
- return;
14784
- const maxScrollOffset = this._options.length - this.maxVisibleItems;
14785
- const scrollPercent = this.scrollOffset / maxScrollOffset;
14786
- const indicatorHeight = Math.max(1, contentHeight - 2);
14787
- const indicatorY = contentY + 1 + Math.floor(scrollPercent * indicatorHeight);
14788
- const indicatorX = contentX + contentWidth - 1;
14789
- this.frameBuffer.drawText("█", indicatorX, indicatorY, parseColor2("#666666"));
15399
+ if (scrolls)
15400
+ buffer.drawText("█", x + width - 1, indicatorY, indicatorColor, transparent2);
15401
+ buffer.popScissorRect();
14790
15402
  }
14791
15403
  get options() {
14792
15404
  return this._options;
@@ -14987,6 +15599,8 @@ class SelectRenderable extends Renderable2 {
14987
15599
  }
14988
15600
  }
14989
15601
  // src/renderables/TabSelect.ts
15602
+ var transparent3 = RGBA2.fromValues(0, 0, 0, 0);
15603
+ var arrowColor = parseColor2("#AAAAAA");
14990
15604
  var defaultTabSelectKeybindings = [
14991
15605
  { name: "left", action: "move-left" },
14992
15606
  { name: "[", action: "move-left" },
@@ -15043,7 +15657,7 @@ class TabSelectRenderable extends Renderable2 {
15043
15657
  _keyBindings;
15044
15658
  constructor(ctx, options) {
15045
15659
  const calculatedHeight = calculateDynamicHeight(options.showUnderline ?? true, options.showDescription ?? true);
15046
- super(ctx, { ...options, height: calculatedHeight, buffered: true });
15660
+ super(ctx, { ...options, height: calculatedHeight });
15047
15661
  try {
15048
15662
  this._backgroundColor = RGBA2.clone(parseColor2(options.backgroundColor || defaultColors2.backgroundColor));
15049
15663
  this._hasBackgroundColor = !!options.backgroundColor;
@@ -15075,71 +15689,52 @@ class TabSelectRenderable extends Renderable2 {
15075
15689
  return kind === "height" ? this.calculateDynamicHeight() : super.defaultDimension(kind);
15076
15690
  }
15077
15691
  renderSelf(buffer, deltaTime) {
15078
- if (!this.visible || !this.frameBuffer)
15079
- return;
15080
- if (this.isDirty) {
15081
- this.refreshFrameBuffer();
15082
- }
15083
- }
15084
- refreshFrameBuffer() {
15085
- if (!this.frameBuffer)
15086
- return;
15692
+ const [x, y] = this._paintOrigin(buffer);
15693
+ const width = this._paintWidth;
15694
+ const height = this._paintHeight;
15087
15695
  const bgColor = this._focused ? this._focusedBackgroundColor : this._backgroundColor;
15088
- this.frameBuffer.clear(bgColor);
15089
- if (this._options.length === 0)
15090
- return;
15091
- const contentX = 0;
15092
- const contentY = 0;
15093
- const contentWidth = this.width;
15094
- const contentHeight = this.height;
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
+ }
15095
15708
  const visibleOptions = this._options.slice(this.scrollOffset, this.scrollOffset + this.maxVisibleTabs);
15096
15709
  for (let i = 0;i < visibleOptions.length; i++) {
15097
- const actualIndex = this.scrollOffset + i;
15098
15710
  const option = visibleOptions[i];
15099
- const isSelected = actualIndex === this.selectedIndex;
15100
- const tabX = contentX + i * this._tabWidth;
15101
- if (tabX >= contentX + contentWidth)
15711
+ const isSelected = this.scrollOffset + i === this.selectedIndex;
15712
+ const tabX = x + i * this._tabWidth;
15713
+ if (tabX >= x + width)
15102
15714
  break;
15103
- const actualTabWidth = Math.min(this._tabWidth, contentWidth - i * this._tabWidth);
15104
- if (isSelected) {
15105
- this.frameBuffer.fillRect(tabX, contentY, actualTabWidth, 1, this._selectedBackgroundColor);
15106
- }
15715
+ const actualTabWidth = Math.min(this._tabWidth, width - i * this._tabWidth);
15107
15716
  const baseTextColor = this._focused ? this._focusedTextColor : this._textColor;
15108
15717
  const nameColor = isSelected ? this._selectedTextColor : baseTextColor;
15109
- const nameContent = this.truncateText(option.name, actualTabWidth - 2);
15110
- this.frameBuffer.drawText(nameContent, tabX + 1, contentY, nameColor);
15111
- if (isSelected && this._showUnderline && contentHeight >= 2) {
15112
- this.frameBuffer.drawText("▬".repeat(actualTabWidth), tabX, contentY + 1, nameColor, this._selectedBackgroundColor);
15718
+ if (isSelected) {
15719
+ buffer.fillRect(tabX, y, actualTabWidth, selectedRows, this._selectedBackgroundColor);
15113
15720
  }
15114
- }
15115
- if (this._showDescription && contentHeight >= (this._showUnderline ? 3 : 2)) {
15116
- const selectedOption = this.getSelectedOption();
15117
- if (selectedOption) {
15118
- const descriptionY = contentY + (this._showUnderline ? 2 : 1);
15119
- const descColor = this._selectedDescriptionColor;
15120
- const descContent = this.truncateText(selectedOption.description, contentWidth - 2);
15121
- 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);
15122
15724
  }
15123
15725
  }
15124
- if (this._showScrollArrows && this._options.length > this.maxVisibleTabs) {
15125
- this.renderScrollArrowsToFrameBuffer(contentX, contentY, contentWidth, contentHeight);
15126
- }
15127
- }
15128
- truncateText(text, maxWidth) {
15129
- if (text.length <= maxWidth)
15130
- return text;
15131
- return text.substring(0, Math.max(0, maxWidth - 1)) + "…";
15132
- }
15133
- renderScrollArrowsToFrameBuffer(contentX, contentY, contentWidth, contentHeight) {
15134
- if (!this.frameBuffer)
15135
- return;
15136
- const hasMoreLeft = this.scrollOffset > 0;
15137
- const hasMoreRight = this.scrollOffset + this.maxVisibleTabs < this._options.length;
15138
- if (hasMoreLeft) {
15139
- this.frameBuffer.drawText("‹", contentX, contentY, parseColor2("#AAAAAA"));
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);
15140
15731
  }
15141
- if (hasMoreRight) {
15142
- 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
+ }
15143
15738
  }
15144
15739
  }
15145
15740
  setOptions(options) {
@@ -15324,28 +15919,19 @@ class TabSelectRenderable extends Renderable2 {
15324
15919
  }
15325
15920
  }
15326
15921
  // src/renderables/TimeToFirstDraw.ts
15327
- var graphemeSegmenter = new Intl.Segmenter(undefined, { granularity: "grapheme" });
15328
- function measureCellWidth(buffer, text) {
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);
15329
15926
  const encoded = buffer.encodeUnicode(text);
15330
- if (!encoded)
15331
- return 0;
15332
- try {
15333
- return encoded.data.reduce((width, glyph) => width + glyph.width, 0);
15334
- } finally {
15335
- buffer.freeUnicode(encoded);
15336
- }
15337
- }
15338
- function truncateToCellWidth(buffer, text, maxWidth) {
15339
- let visibleText = "";
15340
- let visibleWidth = 0;
15341
- for (const { segment } of graphemeSegmenter.segment(text)) {
15342
- const segmentWidth = measureCellWidth(buffer, segment);
15343
- if (visibleWidth + segmentWidth > maxWidth)
15927
+ let width = 0;
15928
+ for (const glyph of encoded.data) {
15929
+ if (width + glyph.width > maxWidth)
15344
15930
  break;
15345
- visibleText += segment;
15346
- visibleWidth += segmentWidth;
15931
+ width += glyph.width;
15347
15932
  }
15348
- return { text: visibleText, width: visibleWidth };
15933
+ buffer.freeUnicode(encoded);
15934
+ return width;
15349
15935
  }
15350
15936
 
15351
15937
  class TimeToFirstDrawRenderable extends Renderable2 {
@@ -15403,9 +15989,9 @@ class TimeToFirstDrawRenderable extends Renderable2 {
15403
15989
  }
15404
15990
  const content = `${this.label}: ${this._runtimeMs.toFixed(this.precision)}ms`;
15405
15991
  const maxWidth = Math.max(this.width, 1);
15406
- const visibleContent = truncateToCellWidth(buffer, content, maxWidth);
15407
- const centeredX = this.x + Math.max(0, Math.floor((maxWidth - visibleContent.width) / 2));
15408
- buffer.drawText(visibleContent.text, centeredX, this.y, this.textColor);
15992
+ const [x, y] = this._paintOrigin(buffer);
15993
+ const width = fittedWidth(buffer, content, maxWidth);
15994
+ buffer.drawTextFit(content, x + Math.floor((maxWidth - width) / 2), y, width, this.textColor, transparent4);
15409
15995
  }
15410
15996
  normalizePrecision(value) {
15411
15997
  if (!Number.isFinite(value)) {
@@ -15537,7 +16123,11 @@ export {
15537
16123
  SYNTHWAVE_MATRIX,
15538
16124
  ScrollBarRenderable,
15539
16125
  ScrollBox,
16126
+ ScrollBoxBar,
16127
+ ScrollBoxContent,
15540
16128
  ScrollBoxRenderable,
16129
+ ScrollBoxViewport,
16130
+ ScrollBoxWrapper,
15541
16131
  Select,
15542
16132
  SelectRenderable,
15543
16133
  SelectRenderableEvents,
@@ -15571,6 +16161,7 @@ export {
15571
16161
  Timeline2 as Timeline,
15572
16162
  TreeSitterClient2 as TreeSitterClient,
15573
16163
  VRenderable,
16164
+ VideoRenderable,
15574
16165
  VignetteEffect,
15575
16166
  exports_yoga as Yoga,
15576
16167
  acquireSessionBufferLease2 as acquireSessionBufferLease,
@@ -15611,6 +16202,7 @@ export {
15611
16202
  buildKittyKeyboardFlags2 as buildKittyKeyboardFlags,
15612
16203
  buildTerminalPaletteSignature2 as buildTerminalPaletteSignature,
15613
16204
  capture2 as capture,
16205
+ checkCrop2 as checkCrop,
15614
16206
  clearEnvCache2 as clearEnvCache,
15615
16207
  convertGlobalToLocalSelection2 as convertGlobalToLocalSelection,
15616
16208
  convertThemeToStyles,
@@ -15705,6 +16297,8 @@ export {
15705
16297
  resolveRenderLib2 as resolveRenderLib,
15706
16298
  reverse2 as reverse,
15707
16299
  rgbToHex2 as rgbToHex,
16300
+ sameCrop2 as sameCrop,
16301
+ scrollUnitSize,
15708
16302
  setRenderLibPath2 as setRenderLibPath,
15709
16303
  setupAudio,
15710
16304
  strikethrough2 as strikethrough,
@@ -15722,5 +16316,5 @@ export {
15722
16316
  yellow2 as yellow
15723
16317
  };
15724
16318
 
15725
- //# debugId=B22B34CB6114361B64756E2164756E21
16319
+ //# debugId=3176549723C7AF9764756E2164756E21
15726
16320
  //# sourceMappingURL=index.node.js.map