@opentui/core 0.7.0 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/NativeScene.d.ts +9 -3
  2. package/Renderable.d.ts +20 -2
  3. package/animation/Timeline.d.ts +9 -0
  4. package/buffer.d.ts +6 -2
  5. package/{chunk-bun-zevtbcf6.js → chunk-bun-6kxdhkdc.js} +407 -259
  6. package/chunk-bun-6kxdhkdc.js.map +70 -0
  7. package/{chunk-bun-qkpm62w1.js → chunk-bun-x6cz4jyg.js} +263 -21
  8. package/chunk-bun-x6cz4jyg.js.map +35 -0
  9. package/{chunk-node-7bcmqh18.js → chunk-node-q5ccgbk5.js} +407 -259
  10. package/{chunk-bun-zevtbcf6.js.map → chunk-node-q5ccgbk5.js.map} +15 -15
  11. package/{chunk-node-mzgnr3sw.js → chunk-node-y0w0hq5m.js} +263 -21
  12. package/chunk-node-y0w0hq5m.js.map +34 -0
  13. package/edit-buffer.d.ts +4 -0
  14. package/index.bun.js +788 -473
  15. package/index.bun.js.map +11 -10
  16. package/index.d.ts +1 -1
  17. package/index.node.js +788 -473
  18. package/index.node.js.map +11 -9
  19. package/lib/extmarks.d.ts +3 -1
  20. package/lib/stdin-parser-native.d.ts +2 -0
  21. package/lib/stdin-parser.d.ts +2 -0
  22. package/lib/terminal-capability-detection.d.ts +6 -1
  23. package/native-abi.generated.d.ts +307 -3
  24. package/package.json +9 -9
  25. package/renderables/FrameBuffer.d.ts +1 -0
  26. package/renderables/ScrollBar.d.ts +6 -0
  27. package/renderables/ScrollBox.d.ts +83 -43
  28. package/renderables/ScrollBoxParts.d.ts +165 -0
  29. package/renderables/index.d.ts +1 -1
  30. package/renderer-theme-mode.d.ts +1 -6
  31. package/renderer.d.ts +22 -3
  32. package/testing/test-renderer.d.ts +2 -0
  33. package/testing.bun.js +7 -6
  34. package/testing.bun.js.map +3 -3
  35. package/testing.js +7 -6
  36. package/testing.js.map +3 -3
  37. package/types.d.ts +11 -0
  38. package/yoga.bun.js +1 -1
  39. package/yoga.internal.d.ts +3 -3
  40. package/yoga.js +1 -1
  41. package/zig-structs.d.ts +1 -0
  42. package/zig.d.ts +78 -8
  43. package/chunk-bun-qkpm62w1.js.map +0 -35
  44. package/chunk-node-7bcmqh18.js.map +0 -70
  45. package/chunk-node-mzgnr3sw.js.map +0 -34
package/index.node.js CHANGED
@@ -66,6 +66,12 @@ import {
66
66
  bg2,
67
67
  link2,
68
68
  t2,
69
+ YogaEnumKind,
70
+ YogaFloatKind,
71
+ YogaValueKind,
72
+ sceneSetEnum,
73
+ sceneSetFloat,
74
+ sceneSetValue,
69
75
  SpanInfoStruct,
70
76
  NativeAudioStreamFormat2,
71
77
  NativeAudioStreamState2,
@@ -84,11 +90,13 @@ import {
84
90
  NativeEditorSelectionOperation2,
85
91
  NativeEditorPositionQuery2,
86
92
  NativeEditEvent2,
93
+ NativeStyleFlags,
87
94
  NATIVE_EDGE_NONE2,
88
95
  NativeBorder2,
89
96
  NativeSceneHook2,
90
97
  NativeSceneFrame2,
91
98
  NativeScenePaintPhase2,
99
+ emptySceneScrollState,
92
100
  NATIVE_BUFFER_TEXT_BYTES_MAX2,
93
101
  NativeSessionState2,
94
102
  NativeSessionRenderStatus2,
@@ -107,9 +115,12 @@ import {
107
115
  FFIRenderLib2,
108
116
  setRenderLibPath2,
109
117
  resolveRenderLib2,
118
+ Edge2,
119
+ FlexDirection2,
120
+ Gutter2,
110
121
  MeasureMode2,
111
122
  exports_yoga
112
- } from "./chunk-node-mzgnr3sw.js";
123
+ } from "./chunk-node-y0w0hq5m.js";
113
124
  import {
114
125
  isValidBorderStyle2,
115
126
  parseBorderStyle2,
@@ -241,7 +252,7 @@ import {
241
252
  CliRenderEvents2,
242
253
  RendererControlState2,
243
254
  CliRenderer2
244
- } from "./chunk-node-7bcmqh18.js";
255
+ } from "./chunk-node-q5ccgbk5.js";
245
256
  // src/syntax-style.ts
246
257
  function cloneStyle(style) {
247
258
  return {
@@ -6505,10 +6516,10 @@ class LineNumberRenderable extends Renderable2 {
6505
6516
  renderSelf(buffer) {
6506
6517
  if (!this.target || !this.gutter || this._lineColorsContent.size === 0)
6507
6518
  return;
6508
- const y = Math.trunc(this.y);
6519
+ const [x, y] = this._paintOrigin(buffer);
6509
6520
  const start = Math.max(0, -y);
6510
6521
  const end = Math.min(this.height, buffer.height - y);
6511
- if (end <= start || this.x >= buffer.width || this.x + this.width <= 0)
6522
+ if (end <= start || x >= buffer.width || x + this.width <= 0)
6512
6523
  return;
6513
6524
  const sources = getLineSources(this.target, Math.trunc(this.target.scrollY) + start, end - start);
6514
6525
  const gutterWidth = this.gutter.visible ? this.gutter.width : 0;
@@ -6517,7 +6528,7 @@ class LineNumberRenderable extends Renderable2 {
6517
6528
  const logicalLine = sources[i];
6518
6529
  const lineBg = this._lineColorsContent.get(logicalLine);
6519
6530
  if (lineBg) {
6520
- buffer.fillRect(this.x + gutterWidth, y + start + i, contentWidth, 1, lineBg);
6531
+ buffer.fillRect(x + gutterWidth, y + start + i, contentWidth, 1, lineBg);
6521
6532
  }
6522
6533
  }
6523
6534
  }
@@ -12107,7 +12118,7 @@ class MarkdownRenderable extends Renderable2 {
12107
12118
  }
12108
12119
  }
12109
12120
  applyListItemRenderable(row, input, previousItem) {
12110
- this.applyListItemMarker(row, input);
12121
+ this.applyListItemMarker(row, input, previousItem);
12111
12122
  const content = row.getChildren()[1];
12112
12123
  if (!(content instanceof BoxRenderable2))
12113
12124
  return false;
@@ -12174,6 +12185,10 @@ class MarkdownRenderable extends Renderable2 {
12174
12185
  this.applyCodeBlockRenderable(renderable, token, 0);
12175
12186
  return true;
12176
12187
  }
12188
+ if (token.type === "blockquote" && renderable instanceof BoxRenderable2) {
12189
+ this.applyBlockquoteRenderable(renderable, token, 0);
12190
+ return true;
12191
+ }
12177
12192
  return previousToken?.raw === token.raw;
12178
12193
  }
12179
12194
  destroyListItemChildrenAfter(content, index) {
@@ -12182,7 +12197,7 @@ class MarkdownRenderable extends Renderable2 {
12182
12197
  children[i]?.destroyRecursively();
12183
12198
  }
12184
12199
  }
12185
- applyListItemMarker(row, input) {
12200
+ applyListItemMarker(row, input, previousItem) {
12186
12201
  const marker = row.getChildren()[0];
12187
12202
  if (!(marker instanceof TextRenderable2))
12188
12203
  return;
@@ -12193,7 +12208,7 @@ class MarkdownRenderable extends Renderable2 {
12193
12208
  row.marginBottom = marginBottom;
12194
12209
  if (marker.width !== markerWidth)
12195
12210
  marker.width = markerWidth;
12196
- if (marker.chunks[0]?.text !== markerText) {
12211
+ if (!previousItem || marker.chunks[0]?.text !== markerText) {
12197
12212
  marker.content = new StyledText2([this.createChunk(markerText, "markup.list")]);
12198
12213
  }
12199
12214
  }
@@ -12774,7 +12789,7 @@ class MarkdownRenderable extends Renderable2 {
12774
12789
  return;
12775
12790
  renderable.destroyRecursively();
12776
12791
  }
12777
- updateBlockRenderable(state, token, index, nextToken, forceListRefresh = false) {
12792
+ updateBlockRenderable(state, token, index, nextToken, forceRefresh = false) {
12778
12793
  const marginBottom = this.getInterBlockMargin(token, nextToken);
12779
12794
  if (token.type === "code") {
12780
12795
  this.applyCodeBlockRenderable(state.renderable, token, marginBottom);
@@ -12785,7 +12800,7 @@ class MarkdownRenderable extends Renderable2 {
12785
12800
  return;
12786
12801
  }
12787
12802
  if (token.type === "list") {
12788
- if (!this.applyListRenderable(state.renderable, token, forceListRefresh ? undefined : state.token, `${this.id}-block-${index}`, marginBottom)) {
12803
+ if (!this.applyListRenderable(state.renderable, token, forceRefresh ? undefined : state.token, `${this.id}-block-${index}`, marginBottom)) {
12789
12804
  state.renderable.destroyRecursively();
12790
12805
  state.renderable = this.createListRenderable(token, `${this.id}-block-${index}`, marginBottom);
12791
12806
  this.add(state.renderable, index);
@@ -12798,7 +12813,7 @@ class MarkdownRenderable extends Renderable2 {
12798
12813
  }
12799
12814
  if (token.type === "table") {
12800
12815
  const tableToken = token;
12801
- const { cache, changed } = this.buildTableContentCache(tableToken, state.tableContentCache);
12816
+ const { cache, changed } = this.buildTableContentCache(tableToken, state.tableContentCache, forceRefresh);
12802
12817
  if (!cache) {
12803
12818
  if (state.renderable instanceof CodeRenderable2) {
12804
12819
  this.applyMarkdownCodeRenderable(state.renderable, tableToken.raw, marginBottom);
@@ -12883,7 +12898,7 @@ class MarkdownRenderable extends Renderable2 {
12883
12898
  }
12884
12899
  this.destroyUnusedDefaultRenderable(custom.renderable);
12885
12900
  }
12886
- this.updateBlockRenderable(existing, block.token, blockIndex, blocks[i + 1]?.token);
12901
+ this.updateBlockRenderable(existing, block.token, blockIndex, blocks[i + 1]?.token, forceTableRefresh);
12887
12902
  existing.renderable.marginBottom = 0;
12888
12903
  if (existing.marginTop !== block.marginTop) {
12889
12904
  this.applyMargins(existing.renderable, block.marginTop, 0);
@@ -13403,56 +13418,7 @@ class SliderRenderable extends Renderable2 {
13403
13418
  }
13404
13419
  }
13405
13420
  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
- }
13421
+ this._drawNativeBody(buffer);
13456
13422
  }
13457
13423
  }
13458
13424
 
@@ -13718,9 +13684,7 @@ class ScrollBarRenderable extends Renderable2 {
13718
13684
  this.slider.value = Math.min(this._scrollPosition, scrollRange);
13719
13685
  }
13720
13686
  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;
13687
+ this.scrollPosition += scrollUnitSize(this, unit) * delta;
13724
13688
  }
13725
13689
  recalculateVisibility() {
13726
13690
  if (!this._manualVisibility) {
@@ -13866,8 +13830,7 @@ class ArrowRenderable extends Renderable2 {
13866
13830
  });
13867
13831
  }
13868
13832
  renderSelf(buffer) {
13869
- const char = this.getArrowChar();
13870
- buffer.drawText(char, this.x, this.y, this._foregroundColor, this._backgroundColor, this._attributes);
13833
+ this._drawNativeBody(buffer);
13871
13834
  }
13872
13835
  defaultDimension(kind) {
13873
13836
  return kind === "width" ? this.glyphWidth() : super.defaultDimension(kind);
@@ -13885,31 +13848,428 @@ class ArrowRenderable extends Renderable2 {
13885
13848
  return this._arrowChars[this._direction];
13886
13849
  }
13887
13850
  }
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);
13851
+ function scrollUnitSize(bar, unit) {
13852
+ if (unit === "viewport")
13853
+ return bar.viewportSize;
13854
+ if (unit === "content")
13855
+ return bar.scrollSize;
13856
+ return unit === "step" ? bar.scrollStep ?? 1 : 1;
13857
+ }
13858
+ // src/renderables/ScrollBoxParts.ts
13859
+ import { EventEmitter as EventEmitter2 } from "events";
13860
+ class ScrollBoxPart extends EventEmitter2 {
13861
+ box;
13862
+ constructor(box, event) {
13863
+ super();
13864
+ this.box = box;
13865
+ this.on("newListener", (name) => name === event && box._refreshScrollHook(true));
13866
+ this.on("removeListener", (name) => name === event && box._refreshScrollHook());
13867
+ }
13868
+ get isDestroyed() {
13869
+ return this.box.isDestroyed;
13870
+ }
13871
+ get x() {
13872
+ return this.rect().x;
13873
+ }
13874
+ get y() {
13875
+ return this.rect().y;
13876
+ }
13877
+ get screenX() {
13878
+ return this.rect().x;
13879
+ }
13880
+ get screenY() {
13881
+ return this.rect().y;
13882
+ }
13883
+ get width() {
13884
+ return this.rect().width;
13885
+ }
13886
+ get height() {
13887
+ return this.rect().height;
13888
+ }
13889
+ removeAllListeners(event) {
13890
+ for (const name of event === undefined ? this.eventNames() : [event]) {
13891
+ if (name !== "newListener" && name !== "removeListener")
13892
+ super.removeAllListeners(name);
13893
+ }
13894
+ return this;
13895
+ }
13896
+ _assign(options, keys) {
13897
+ if (options == null)
13898
+ return;
13899
+ for (const key of Reflect.ownKeys(options)) {
13900
+ if (typeof key !== "string" || !keys.includes(key))
13901
+ continue;
13902
+ if (!Object.getOwnPropertyDescriptor(options, key)?.enumerable)
13903
+ continue;
13904
+ this[key] = Reflect.get(options, key);
13905
+ if (this.box.isDestroyed)
13906
+ return;
13907
+ }
13908
+ }
13909
+ }
13910
+
13911
+ class ScrollBoxFilledPart extends ScrollBoxPart {
13912
+ _backgroundColor;
13913
+ get backgroundColor() {
13914
+ return RGBA2.clone(this._backgroundColor ?? RGBA2.fromValues(0, 0, 0, 0));
13915
+ }
13916
+ set backgroundColor(value) {
13917
+ this._backgroundColor = value == null ? undefined : RGBA2.clone(parseColor2(value));
13918
+ this.box._applyScrollOptions();
13919
+ }
13920
+ _fill() {
13921
+ return this._backgroundColor;
13922
+ }
13923
+ }
13924
+
13925
+ class ScrollBoxSizedPart extends ScrollBoxFilledPart {
13926
+ _onSizeChange;
13927
+ constructor(box) {
13928
+ super(box, "resize");
13929
+ }
13930
+ get onSizeChange() {
13931
+ return this._onSizeChange;
13932
+ }
13933
+ set onSizeChange(handler) {
13934
+ this._onSizeChange = handler ?? undefined;
13935
+ this.box._refreshScrollHook();
13936
+ }
13937
+ _listening() {
13938
+ return this._onSizeChange !== undefined || this.listenerCount("resize") > 0;
13939
+ }
13940
+ _emitResize() {
13941
+ this._onSizeChange?.();
13942
+ if (!this.box.isDestroyed)
13943
+ this.emit("resize");
13944
+ }
13945
+ }
13946
+
13947
+ class ScrollBoxWrapper extends ScrollBoxFilledPart {
13948
+ static keys = ["backgroundColor"];
13949
+ _listening() {
13950
+ return false;
13951
+ }
13952
+ rect() {
13953
+ return this.box._wrapperRect();
13954
+ }
13955
+ }
13956
+ var paddingKeys = ["padding", "paddingX", "paddingY", "paddingLeft", "paddingTop", "paddingRight", "paddingBottom"];
13957
+
13958
+ class ScrollBoxViewport extends ScrollBoxSizedPart {
13959
+ static keys = ["backgroundColor", "onSizeChange", ...paddingKeys];
13960
+ paddings = {};
13961
+ constructor(box) {
13962
+ super(box);
13963
+ paddingKeys.forEach((key, index) => Object.defineProperty(this, key, {
13964
+ configurable: true,
13965
+ get: index < 3 ? undefined : () => this._edges()[index - 3],
13966
+ set: (value) => this.setPadding(key, value)
13967
+ }));
13968
+ }
13969
+ rect() {
13970
+ return this.box._scrollState().viewport;
13971
+ }
13972
+ setPadding(key, value) {
13973
+ if (value != null && (typeof value !== "number" || !Number.isInteger(value) || value < 0 || value > 65535)) {
13974
+ throw new RangeError("ScrollBox viewport padding must be a whole number of cells");
13975
+ }
13976
+ if (value == null)
13977
+ delete this.paddings[key];
13978
+ else
13979
+ this.paddings[key] = value;
13980
+ this.box._applyScrollOptions();
13981
+ }
13982
+ _edges() {
13983
+ const p = this.paddings;
13984
+ const all = p.padding ?? 0;
13985
+ const x = p.paddingX ?? all;
13986
+ const y = p.paddingY ?? all;
13987
+ return [p.paddingLeft ?? x, p.paddingTop ?? y, p.paddingRight ?? x, p.paddingBottom ?? y];
13988
+ }
13989
+ }
13990
+ var content = NativeStyleFlags.Content;
13991
+ var contentStyles = {};
13992
+ {
13993
+ const value = (kind, edge = NATIVE_EDGE_NONE2) => (scene, node, input) => sceneSetValue(scene, node, kind, edge, input ?? undefined, content);
13994
+ const enums = [
13995
+ ["flexDirection", YogaEnumKind.FlexDirection, parseFlexDirection2],
13996
+ ["flexWrap", YogaEnumKind.FlexWrap, parseWrap2],
13997
+ ["alignItems", YogaEnumKind.AlignItems, parseAlignItems2],
13998
+ ["justifyContent", YogaEnumKind.JustifyContent, parseJustify2],
13999
+ ["alignSelf", YogaEnumKind.AlignSelf, parseAlign2]
14000
+ ];
14001
+ for (const [key, kind, parse] of enums) {
14002
+ contentStyles[key] = (scene, node, input) => sceneSetEnum(scene, node, kind, parse(input ?? undefined), content);
14003
+ }
14004
+ contentStyles.flexGrow = (scene, node, input) => sceneSetFloat(scene, node, YogaFloatKind.FlexGrow, input ?? 0, content);
14005
+ contentStyles.flexShrink = (scene, node, input) => sceneSetFloat(scene, node, YogaFloatKind.FlexShrink, input ?? 0, content);
14006
+ for (const [key, kind] of [
14007
+ ["width", YogaValueKind.Width],
14008
+ ["height", YogaValueKind.Height],
14009
+ ["flexBasis", YogaValueKind.FlexBasis],
14010
+ ["minWidth", YogaValueKind.MinWidth],
14011
+ ["minHeight", YogaValueKind.MinHeight],
14012
+ ["maxWidth", YogaValueKind.MaxWidth],
14013
+ ["maxHeight", YogaValueKind.MaxHeight]
14014
+ ]) {
14015
+ contentStyles[key] = value(kind);
14016
+ }
14017
+ for (const [suffix, edge] of [
14018
+ ["", Edge2.All],
14019
+ ["X", Edge2.Horizontal],
14020
+ ["Y", Edge2.Vertical],
14021
+ ["Top", Edge2.Top],
14022
+ ["Right", Edge2.Right],
14023
+ ["Bottom", Edge2.Bottom],
14024
+ ["Left", Edge2.Left]
14025
+ ]) {
14026
+ contentStyles[`padding${suffix}`] = value(YogaValueKind.Padding, edge);
14027
+ contentStyles[`margin${suffix}`] = value(YogaValueKind.Margin, edge);
14028
+ }
14029
+ contentStyles.gap = value(YogaValueKind.Gap, Gutter2.All);
14030
+ contentStyles.rowGap = value(YogaValueKind.Gap, Gutter2.Row);
14031
+ contentStyles.columnGap = value(YogaValueKind.Gap, Gutter2.Column);
14032
+ }
14033
+
14034
+ class ScrollBoxContent extends ScrollBoxSizedPart {
14035
+ static keys = ["backgroundColor", "onSizeChange", "viewportCulling", ...Object.keys(contentStyles)];
14036
+ styles = new Map;
14037
+ constructor(box) {
14038
+ super(box);
14039
+ for (const key of Object.keys(contentStyles)) {
14040
+ const size = key === "width" || key === "height";
14041
+ Object.defineProperty(this, key, {
14042
+ configurable: true,
14043
+ enumerable: false,
14044
+ get: () => size ? this.rect()[key] : this.styles.get(key),
14045
+ set: (input) => this.setStyle(key, input)
14046
+ });
13901
14047
  }
13902
14048
  }
14049
+ rect() {
14050
+ const { content, offset } = this.box._scrollState();
14051
+ return {
14052
+ x: this.box.screenX + content.x - offset[0],
14053
+ y: this.box.screenY + content.y - offset[1],
14054
+ width: content.width,
14055
+ height: content.height
14056
+ };
14057
+ }
14058
+ setStyle(key, input) {
14059
+ this.box._setContentStyle((scene, node) => contentStyles[key](scene, node, input));
14060
+ if (input == null)
14061
+ this.styles.delete(key);
14062
+ else
14063
+ this.styles.set(key, input);
14064
+ }
14065
+ get _row() {
14066
+ const direction = parseFlexDirection2(this.styles.get("flexDirection"));
14067
+ return direction === FlexDirection2.Row || direction === FlexDirection2.RowReverse;
14068
+ }
13903
14069
  get viewportCulling() {
13904
- return this._viewportCulling;
14070
+ return this.box.viewportCulling;
13905
14071
  }
13906
14072
  set viewportCulling(value) {
13907
- if (this.isFreed())
14073
+ this.box.viewportCulling = value;
14074
+ }
14075
+ add(obj, index) {
14076
+ return this.box.add(obj, index);
14077
+ }
14078
+ insertBefore(obj, anchor) {
14079
+ return this.box.insertBefore(obj, anchor);
14080
+ }
14081
+ remove(child) {
14082
+ this.box.remove(child);
14083
+ }
14084
+ getChildren() {
14085
+ return this.box.getChildren();
14086
+ }
14087
+ getChildrenCount() {
14088
+ return this.box.getChildrenCount();
14089
+ }
14090
+ getRenderable(id) {
14091
+ return this.box.getRenderable(id);
14092
+ }
14093
+ findDescendantById(id) {
14094
+ return this.box.findDescendantById(id);
14095
+ }
14096
+ }
14097
+ var defaultTrack = RGBA2.fromHex("#252527");
14098
+ var defaultThumb = RGBA2.fromHex("#9a9ea3");
14099
+ var defaultArrowForeground2 = RGBA2.fromValues(1, 1, 1, 1);
14100
+ var defaultArrowBackground2 = RGBA2.fromValues(0, 0, 0, 0);
14101
+
14102
+ class ScrollBoxBar extends ScrollBoxPart {
14103
+ static keys = [
14104
+ "visible",
14105
+ "showArrows",
14106
+ "arrowOptions",
14107
+ "trackOptions",
14108
+ "onChange",
14109
+ "width",
14110
+ "height",
14111
+ "paddingLeft",
14112
+ "paddingTop",
14113
+ "position",
14114
+ "scrollStep"
14115
+ ];
14116
+ orientation;
14117
+ scrollStep = null;
14118
+ axis;
14119
+ policy = "auto";
14120
+ _showArrows = false;
14121
+ _arrowOptions = {};
14122
+ trackForeground = defaultThumb;
14123
+ trackBackground = defaultTrack;
14124
+ thickness = 1;
14125
+ gap = 0;
14126
+ overlay = false;
14127
+ _onChange;
14128
+ constructor(box, orientation) {
14129
+ super(box, "change");
14130
+ this.orientation = orientation;
14131
+ this.axis = orientation === "vertical" ? 1 : 0;
14132
+ }
14133
+ rect() {
14134
+ const bar = this.box._scrollState().bars[this.axis];
14135
+ const arrows = this._showArrows ? 1 : 0;
14136
+ return this.axis === 1 ? {
14137
+ x: bar.track.x - this.gap,
14138
+ y: bar.track.y - arrows,
14139
+ width: bar.track.width + this.gap,
14140
+ height: bar.track.height + 2 * arrows
14141
+ } : {
14142
+ x: bar.track.x - arrows,
14143
+ y: bar.track.y - this.gap,
14144
+ width: bar.track.width + 2 * arrows,
14145
+ height: bar.track.height + this.gap
14146
+ };
14147
+ }
14148
+ _listening() {
14149
+ return this._onChange !== undefined || this.listenerCount("change") > 0;
14150
+ }
14151
+ _native() {
14152
+ return {
14153
+ policy: this.policy,
14154
+ overlay: this.overlay,
14155
+ thickness: this.thickness,
14156
+ gap: this.gap,
14157
+ arrows: this._showArrows,
14158
+ foregroundColor: this.trackForeground,
14159
+ backgroundColor: this.trackBackground
14160
+ };
14161
+ }
14162
+ _arrows() {
14163
+ const options = this._arrowOptions;
14164
+ const background = options.backgroundColor ?? undefined;
14165
+ const foreground = options.foregroundColor ?? background;
14166
+ const chars = options.arrowChars ?? {};
14167
+ return (this.axis === 1 ? ["up", "down"] : ["left", "right"]).map((direction) => ({
14168
+ attributes: options.attributes ?? 0,
14169
+ foregroundColor: RGBA2.clone(parseColor2(foreground || defaultArrowForeground2)),
14170
+ backgroundColor: RGBA2.clone(parseColor2(background || defaultArrowBackground2)),
14171
+ text: chars[direction]
14172
+ }));
14173
+ }
14174
+ _emitChange(position) {
14175
+ this._onChange?.(position);
14176
+ if (!this.box.isDestroyed)
14177
+ this.emit("change", { position });
14178
+ }
14179
+ get visible() {
14180
+ return this.box._scrollState().bars[this.axis].visible;
14181
+ }
14182
+ set visible(value) {
14183
+ this.setOption(() => this.policy = value == null ? "auto" : value ? "always" : "never");
14184
+ }
14185
+ resetVisibilityControl() {
14186
+ this.visible = null;
14187
+ }
14188
+ get onChange() {
14189
+ return this._onChange;
14190
+ }
14191
+ set onChange(handler) {
14192
+ this._onChange = handler ?? undefined;
14193
+ this.box._refreshScrollHook();
14194
+ }
14195
+ get showArrows() {
14196
+ return this._showArrows;
14197
+ }
14198
+ set showArrows(value) {
14199
+ this.setOption(() => this._showArrows = value ?? false);
14200
+ }
14201
+ set arrowOptions(options) {
14202
+ this._arrowOptions = { ...this._arrowOptions, ...options };
14203
+ if (!this.box.isDestroyed)
14204
+ this.box._applyScrollArrows(this.axis);
14205
+ }
14206
+ set trackOptions(options) {
14207
+ this.setOption(() => {
14208
+ if (options && "foregroundColor" in options) {
14209
+ this.trackForeground = RGBA2.clone(parseColor2(options.foregroundColor ?? defaultThumb));
14210
+ }
14211
+ if (options && "backgroundColor" in options) {
14212
+ this.trackBackground = RGBA2.clone(parseColor2(options.backgroundColor ?? defaultTrack));
14213
+ }
14214
+ });
14215
+ }
14216
+ get width() {
14217
+ return super.width;
14218
+ }
14219
+ set width(value) {
14220
+ if (this.axis === 1)
14221
+ this.setOption(() => this.thickness = Math.max(1, cells(value, 1)));
14222
+ }
14223
+ get height() {
14224
+ return super.height;
14225
+ }
14226
+ set height(value) {
14227
+ if (this.axis === 0)
14228
+ this.setOption(() => this.thickness = Math.max(1, cells(value, 1)));
14229
+ }
14230
+ set paddingLeft(value) {
14231
+ if (this.axis === 1)
14232
+ this.setOption(() => this.gap = cells(value, 0));
14233
+ }
14234
+ set paddingTop(value) {
14235
+ if (this.axis === 0)
14236
+ this.setOption(() => this.gap = cells(value, 0));
14237
+ }
14238
+ set position(value) {
14239
+ this.setOption(() => this.overlay = value === "absolute");
14240
+ }
14241
+ setOption(change) {
14242
+ if (this.box.isDestroyed)
13908
14243
  return;
13909
- this._ctx.nativeScene.setViewport(this, value ? this.viewport : null);
13910
- this._viewportCulling = value;
14244
+ change();
14245
+ this.box._applyScrollOptions();
14246
+ }
14247
+ get scrollSize() {
14248
+ const { content } = this.box._scrollState();
14249
+ return this.axis === 1 ? content.height : content.width;
14250
+ }
14251
+ get viewportSize() {
14252
+ const { viewport } = this.box._scrollState();
14253
+ return this.axis === 1 ? viewport.height : viewport.width;
13911
14254
  }
14255
+ get scrollPosition() {
14256
+ return this.box._scrollState().offset[this.axis];
14257
+ }
14258
+ set scrollPosition(value) {
14259
+ this.box._scrollAxis(this.axis, value, false);
14260
+ }
14261
+ scrollBy(delta, unit = "absolute") {
14262
+ this.box._scrollAxis(this.axis, scrollUnitSize(this, unit) * delta, true, true);
14263
+ }
14264
+ handleKeyPress(key) {
14265
+ return ScrollBarRenderable.prototype.handleKeyPress.call(this, key);
14266
+ }
14267
+ }
14268
+ function cells(value, fallback) {
14269
+ return typeof value === "number" && Number.isFinite(value) ? Math.max(0, Math.min(255, Math.trunc(value))) : fallback;
13912
14270
  }
14271
+
14272
+ // src/renderables/ScrollBox.ts
13913
14273
  var SCROLLBOX_PADDING_KEYS = [
13914
14274
  "padding",
13915
14275
  "paddingX",
@@ -13946,11 +14306,13 @@ class ScrollBoxRenderable extends BoxRenderable2 {
13946
14306
  update: {
13947
14307
  idle: this.prototype.onUpdate,
13948
14308
  active: (renderable) => renderable["isAutoScrolling"]
14309
+ },
14310
+ scroll: {
14311
+ active: (renderable) => renderable.scrollHook,
14312
+ notify: (renderable) => renderable.notifyScroll()
13949
14313
  }
13950
14314
  }
13951
14315
  };
13952
- static idCounter = 0;
13953
- internalId = 0;
13954
14316
  wrapper;
13955
14317
  viewport;
13956
14318
  content;
@@ -13972,126 +14334,70 @@ class ScrollBoxRenderable extends BoxRenderable2 {
13972
14334
  scrollAccumulatorX = 0;
13973
14335
  scrollAccumulatorY = 0;
13974
14336
  _stickyScroll;
13975
- _stickyScrollTop = false;
13976
- _stickyScrollBottom = false;
13977
- _stickyScrollLeft = false;
13978
- _stickyScrollRight = false;
13979
14337
  _stickyStart;
13980
- _hasManualScroll = false;
13981
- _isApplyingStickyScroll = false;
13982
14338
  scrollAccel;
14339
+ axes;
14340
+ _viewportCulling;
14341
+ state = emptySceneScrollState();
14342
+ stateRevision;
14343
+ scrollHook = false;
14344
+ configured = false;
14345
+ barPress;
14346
+ layoutCallbacks = [];
14347
+ anchorToken;
13983
14348
  get stickyScroll() {
13984
14349
  return this._stickyScroll;
13985
14350
  }
13986
14351
  set stickyScroll(value) {
13987
- this._stickyScroll = value;
13988
- this.updateStickyState();
14352
+ this.setScrollOption(() => this._stickyScroll = value);
13989
14353
  }
13990
14354
  get stickyStart() {
13991
14355
  return this._stickyStart;
13992
14356
  }
13993
14357
  set stickyStart(value) {
13994
- this._stickyStart = value;
13995
- this.updateStickyState();
14358
+ this.setScrollOption(() => this._stickyStart = value);
14359
+ }
14360
+ setScrollOption(change) {
14361
+ const previous = [this._stickyScroll, this._stickyStart, this._viewportCulling];
14362
+ change();
14363
+ try {
14364
+ this._applyScrollOptions();
14365
+ } catch (error) {
14366
+ [this._stickyScroll, this._stickyStart, this._viewportCulling] = previous;
14367
+ throw error;
14368
+ }
14369
+ }
14370
+ get scrollX() {
14371
+ return this.axes.x;
14372
+ }
14373
+ set scrollX(value) {
14374
+ this.axes.x = value ?? false;
14375
+ this._applyScrollOptions();
14376
+ }
14377
+ get scrollY() {
14378
+ return this.axes.y;
14379
+ }
14380
+ set scrollY(value) {
14381
+ this.axes.y = value ?? true;
14382
+ this._applyScrollOptions();
13996
14383
  }
13997
14384
  get scrollTop() {
13998
- return this.verticalScrollBar.scrollPosition;
14385
+ return this._scrollState().offset[1];
13999
14386
  }
14000
14387
  set scrollTop(value) {
14001
- this.verticalScrollBar.scrollPosition = value;
14002
- this.updateStickyState();
14388
+ this._scrollAxis(1, value, false);
14003
14389
  }
14004
14390
  get scrollLeft() {
14005
- return this.horizontalScrollBar.scrollPosition;
14391
+ return this._scrollState().offset[0];
14006
14392
  }
14007
14393
  set scrollLeft(value) {
14008
- this.horizontalScrollBar.scrollPosition = value;
14009
- this.updateStickyState();
14394
+ this._scrollAxis(0, value, false);
14010
14395
  }
14011
14396
  get scrollWidth() {
14012
- return this.horizontalScrollBar.scrollSize;
14397
+ return this._scrollState().content.width;
14013
14398
  }
14014
14399
  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
- }
14400
+ return this._scrollState().content.height;
14095
14401
  }
14096
14402
  constructor(ctx, options) {
14097
14403
  const {
@@ -14116,95 +14422,38 @@ class ScrollBoxRenderable extends BoxRenderable2 {
14116
14422
  };
14117
14423
  const sanitizedRootBoxOptions = stripScrollBoxPadding(rootBoxOptions);
14118
14424
  const sanitizedRootOptions = rootOptions ? stripScrollBoxPadding(rootOptions) : undefined;
14119
- const mergedContentOptions = {
14120
- ...forwardedContentPadding,
14121
- ...contentOptions
14122
- };
14123
14425
  super(ctx, {
14124
14426
  flexDirection: "row",
14125
14427
  alignItems: "stretch",
14126
14428
  ...sanitizedRootBoxOptions,
14127
- ...sanitizedRootOptions
14429
+ ...sanitizedRootOptions,
14430
+ overflow: "hidden"
14128
14431
  });
14129
- const children = [];
14130
14432
  try {
14131
- this.internalId = ScrollBoxRenderable.idCounter++;
14132
14433
  this._stickyScroll = stickyScroll;
14133
14434
  this._stickyStart = stickyStart;
14134
14435
  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
- }
14436
+ this.axes = { x: scrollX, y: scrollY };
14437
+ this._viewportCulling = viewportCulling;
14438
+ this.wrapper = new ScrollBoxWrapper(this);
14439
+ this.viewport = new ScrollBoxViewport(this);
14440
+ this.content = new ScrollBoxContent(this);
14441
+ this.verticalScrollBar = new ScrollBoxBar(this, "vertical");
14442
+ this.horizontalScrollBar = new ScrollBoxBar(this, "horizontal");
14443
+ this.wrapper._assign(wrapperOptions, ScrollBoxWrapper.keys);
14444
+ this.viewport._assign(viewportOptions, ScrollBoxViewport.keys);
14445
+ for (const [bar, own] of [
14446
+ [this.verticalScrollBar, verticalScrollbarOptions],
14447
+ [this.horizontalScrollBar, horizontalScrollbarOptions]
14448
+ ]) {
14449
+ bar._assign({ ...scrollbarOptions, ...own, arrowOptions: { ...scrollbarOptions?.arrowOptions, ...own?.arrowOptions } }, ScrollBoxBar.keys);
14450
+ }
14451
+ this.configured = true;
14452
+ this._applyScrollOptions();
14453
+ this._applyScrollArrows(0);
14454
+ this._applyScrollArrows(1);
14455
+ this.content._assign({ ...forwardedContentPadding, ...contentOptions }, ScrollBoxContent.keys);
14456
+ this._refreshScrollHook();
14208
14457
  this.selectionListener = () => {
14209
14458
  if (this.isDestroyed)
14210
14459
  return;
@@ -14216,14 +14465,149 @@ class ScrollBoxRenderable extends BoxRenderable2 {
14216
14465
  this._ctx.on("selection", this.selectionListener);
14217
14466
  this.setNativeScenePaint();
14218
14467
  } 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
- });
14468
+ this.abortConstruction(error, (run) => run(() => this.destroySelf()));
14225
14469
  }
14226
14470
  }
14471
+ _applyScrollOptions() {
14472
+ if (!this.configured || this.isFreed())
14473
+ return;
14474
+ const sticky = this._stickyScroll && this._stickyStart;
14475
+ this._ctx.nativeScene.setScroll(this, {
14476
+ scrollX: this.axes.x,
14477
+ scrollY: this.axes.y,
14478
+ follow: sticky ? this._stickyStart : "none",
14479
+ culling: this._viewportCulling,
14480
+ padding: this.viewport._edges(),
14481
+ fills: [this.wrapper._fill(), this.viewport._fill(), this.content._fill()],
14482
+ bars: [this.horizontalScrollBar._native(), this.verticalScrollBar._native()]
14483
+ });
14484
+ this.requestRender();
14485
+ }
14486
+ _applyScrollArrows(axis) {
14487
+ if (!this.configured || this.isFreed())
14488
+ return;
14489
+ const bar = axis === 1 ? this.verticalScrollBar : this.horizontalScrollBar;
14490
+ bar._arrows().forEach((arrow, end) => this._ctx.nativeScene.setScrollArrow(this, axis, end, arrow));
14491
+ this.requestRender();
14492
+ }
14493
+ _setContentStyle(apply) {
14494
+ if (this.isFreed())
14495
+ return;
14496
+ apply(this._ctx.nativeScene, this);
14497
+ this.requestRender();
14498
+ }
14499
+ _scrollState() {
14500
+ if (this.isFreed())
14501
+ return this.state;
14502
+ const revision = this._ctx.nativeScene.observedLayoutRevision;
14503
+ if (revision !== undefined && revision === this.stateRevision)
14504
+ return this.state;
14505
+ this.state = this._ctx.nativeScene.getScroll(this);
14506
+ this.stateRevision = revision;
14507
+ return this.state;
14508
+ }
14509
+ _wrapperRect() {
14510
+ const { viewport, bars } = this._scrollState();
14511
+ const horizontal = bars[0];
14512
+ const gutter = horizontal.visible ? horizontal.track.y + horizontal.track.height - viewport.y - viewport.height : 0;
14513
+ return { ...viewport, height: viewport.height + Math.max(0, gutter) };
14514
+ }
14515
+ _scrollAxis(axis, value, relative, reapply = false) {
14516
+ if (this.isFreed())
14517
+ return;
14518
+ this.assertMutable();
14519
+ value ??= 0;
14520
+ if (Number.isNaN(value))
14521
+ throw new RangeError("Scene scroll positions must be finite numbers");
14522
+ const x = axis === 0 ? value : 0;
14523
+ const y = axis === 1 ? value : 0;
14524
+ this.commitScroll(() => this._ctx.nativeScene.scrollTo(this, x, y, axis !== 0 || relative, axis !== 1 || relative, reapply));
14525
+ }
14526
+ commitScroll(scroll) {
14527
+ const before = this._scrollState().offset;
14528
+ const state = scroll();
14529
+ this.state = state;
14530
+ this.stateRevision = this._ctx.nativeScene.observedLayoutRevision;
14531
+ const moved = (state.offset[0] !== before[0] ? 1 : 0) | (state.offset[1] !== before[1] ? 2 : 0);
14532
+ if (moved)
14533
+ this.requestRender();
14534
+ this.notifyOffsets(state, moved);
14535
+ }
14536
+ notifyOffsets(state, moved) {
14537
+ for (const axis of [1, 0]) {
14538
+ if ((moved & axis + 1) === 0)
14539
+ continue;
14540
+ (axis === 1 ? this.verticalScrollBar : this.horizontalScrollBar)._emitChange(state.offset[axis]);
14541
+ if (this.isDestroyed)
14542
+ return;
14543
+ }
14544
+ }
14545
+ listening() {
14546
+ return this.verticalScrollBar?._listening() || this.horizontalScrollBar?._listening() || this.content?._listening() || this.viewport?._listening() || this.layoutCallbacks.length > 0;
14547
+ }
14548
+ _refreshScrollHook(adding = false) {
14549
+ if (!this.configured || this.isFreed())
14550
+ return;
14551
+ const listening = adding || this.listening();
14552
+ if (listening === this.scrollHook)
14553
+ return;
14554
+ this.scrollHook = listening;
14555
+ this.refreshNativeSceneHooks();
14556
+ }
14557
+ notifyScroll() {
14558
+ const state = this._scrollState();
14559
+ this.notifyOffsets(state, state.changes);
14560
+ if (!this.isDestroyed && state.changes & 8)
14561
+ this.viewport._emitResize();
14562
+ if (!this.isDestroyed && state.changes & 4)
14563
+ this.content._emitResize();
14564
+ if (this.isDestroyed || !(state.changes & 16))
14565
+ return;
14566
+ const frame = this._ctx.frameId;
14567
+ const due = this.layoutCallbacks.filter((entry) => entry.frame < frame);
14568
+ this.layoutCallbacks = this.layoutCallbacks.filter((entry) => entry.frame >= frame);
14569
+ if (this.layoutCallbacks.length > 0)
14570
+ this._ctx.nativeScene.scrollRequest(this, "layout", null);
14571
+ let failure;
14572
+ for (const { callback } of due) {
14573
+ if (this.isDestroyed)
14574
+ break;
14575
+ try {
14576
+ callback();
14577
+ } catch (error) {
14578
+ failure ??= { error };
14579
+ }
14580
+ }
14581
+ this._refreshScrollHook();
14582
+ if (failure)
14583
+ throw failure.error;
14584
+ }
14585
+ afterLayout(callback) {
14586
+ if (this.isFreed())
14587
+ return;
14588
+ this.assertMutable();
14589
+ this.layoutCallbacks.push({ frame: this._ctx.frameId, callback });
14590
+ this._refreshScrollHook();
14591
+ this._ctx.nativeScene.scrollRequest(this, "layout", null);
14592
+ this.requestRender();
14593
+ }
14594
+ anchor(node) {
14595
+ if (this.isFreed())
14596
+ return () => {};
14597
+ this.assertMutable();
14598
+ this._ctx.nativeScene.scrollRequest(this, "anchor", node);
14599
+ const token = {};
14600
+ this.anchorToken = token;
14601
+ return () => {
14602
+ if (this.anchorToken !== token || this.isFreed())
14603
+ return;
14604
+ this._ctx.nativeScene.scrollRequest(this, "anchor", null);
14605
+ this.anchorToken = undefined;
14606
+ };
14607
+ }
14608
+ get primaryAxis() {
14609
+ return this.content._row ? "row" : "column";
14610
+ }
14227
14611
  onUpdate(deltaTime) {
14228
14612
  this.handleAutoScroll(deltaTime);
14229
14613
  }
@@ -14237,120 +14621,42 @@ class ScrollBoxRenderable extends BoxRenderable2 {
14237
14621
  this.horizontalScrollBar.scrollBy(delta.x, unit);
14238
14622
  }
14239
14623
  }
14240
- scrollChildIntoView(childId) {
14241
- const child = this.content.findDescendantById(childId);
14242
- if (!child)
14624
+ scrollChildIntoView(child, options = {}) {
14625
+ const node = typeof child === "string" ? this.findDescendantById(child) : child;
14626
+ if (!node || this.isFreed())
14243
14627
  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
- }
14628
+ this.assertMutable();
14629
+ this.commitScroll(() => this._ctx.nativeScene.scrollRequest(this, "into-view", node, options.align, options.inset));
14273
14630
  }
14274
14631
  scrollTo(position) {
14275
14632
  if (typeof position === "number") {
14276
- this.scrollTop = position;
14633
+ this._scrollAxis(1, position, false, true);
14277
14634
  } else {
14278
- this.scrollTop = position.y;
14635
+ this._scrollAxis(1, position.y, false, true);
14279
14636
  if (this.isDestroyed)
14280
14637
  return;
14281
- this.scrollLeft = position.x;
14282
- }
14283
- }
14284
- isAtStickyPosition() {
14285
- if (!this._stickyScroll || !this._stickyStart) {
14286
- return false;
14287
- }
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;
14638
+ this._scrollAxis(0, position.x, false, true);
14313
14639
  }
14314
14640
  }
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
- }
14334
14641
  scrollByWheel(event) {
14335
14642
  const dir = wheelDirection(event);
14336
14643
  const vertical = dir === "up" || dir === "down";
14337
14644
  if (!vertical && dir !== "left" && dir !== "right")
14338
14645
  return false;
14339
- const bar = vertical ? this.verticalScrollBar : this.horizontalScrollBar;
14646
+ const axis = vertical ? 1 : 0;
14340
14647
  const sign = dir === "up" || dir === "left" ? -1 : 1;
14341
- const position = bar.scrollPosition;
14342
- if (sign < 0 ? position <= 0 : position >= bar.scrollSize - bar.viewportSize)
14648
+ const { offset, max } = this._scrollState();
14649
+ const position = offset[axis];
14650
+ if (sign < 0 ? position <= 0 : position >= max[axis])
14343
14651
  return false;
14344
14652
  let remainder = vertical ? this.scrollAccumulatorY : this.scrollAccumulatorX;
14345
14653
  if (remainder * sign < 0)
14346
14654
  remainder = 0;
14347
14655
  remainder += sign * (event.scroll?.delta ?? 0) * this.scrollAccel.tick(Date.now());
14348
14656
  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;
14657
+ if (step !== 0)
14658
+ this._scrollAxis(axis, position + step, false);
14659
+ remainder = this._scrollState().offset[axis] - position === step ? remainder - step : 0;
14354
14660
  if (vertical)
14355
14661
  this.scrollAccumulatorY = remainder;
14356
14662
  else
@@ -14360,23 +14666,97 @@ class ScrollBoxRenderable extends BoxRenderable2 {
14360
14666
  onMouseEvent(event) {
14361
14667
  if (event.type === "scroll")
14362
14668
  scrollOnce(event, this, () => this.scrollByWheel(event));
14669
+ if (this.handleBarMouse(event))
14670
+ return;
14363
14671
  if (event.type === "drag" && event.isDragging) {
14364
14672
  this.updateAutoScroll(event.x, event.y);
14365
14673
  } else if (event.type === "up") {
14366
14674
  this.stopAutoScroll();
14367
14675
  }
14368
14676
  }
14369
- handleKeyPress(key) {
14370
- if (this.verticalScrollBar.handleKeyPress(key)) {
14371
- this.scrollAccel.reset();
14372
- this.resetScrollAccumulators();
14373
- this.syncManualScrollState();
14677
+ handleBarMouse(event) {
14678
+ const press = this.barPress;
14679
+ if (press && (event.type === "drag" || event.type === "up" || event.type === "drag-end")) {
14680
+ if ("offset" in press && event.type !== "drag-end")
14681
+ this.dragThumb(press, event);
14682
+ if (event.type === "up")
14683
+ this.endBarPress();
14684
+ event.stopPropagation();
14685
+ return true;
14686
+ }
14687
+ if (event.type !== "down" || event.button !== 0 || event.target !== this)
14688
+ return false;
14689
+ const { bars } = this._scrollState();
14690
+ for (const axis of [1, 0]) {
14691
+ const bar = bars[axis];
14692
+ if (!bar.visible)
14693
+ continue;
14694
+ const part = axis === 1 ? this.verticalScrollBar : this.horizontalScrollBar;
14695
+ const inside = (rect) => event.x >= rect.x && event.x < rect.x + rect.width && event.y >= rect.y && event.y < rect.y + rect.height;
14696
+ const arrow = part.showArrows ? inside(bar.startArrow) ? -1 : inside(bar.endArrow) ? 1 : 0 : 0;
14697
+ if (arrow === 0 && !inside(bar.track))
14698
+ continue;
14699
+ event.stopPropagation();
14700
+ event.preventDefault();
14701
+ this.endBarPress();
14702
+ if (arrow !== 0)
14703
+ this.pressArrow(axis, arrow, part);
14704
+ else
14705
+ this.pressTrack(axis, event);
14374
14706
  return true;
14375
14707
  }
14376
- if (this.horizontalScrollBar.handleKeyPress(key)) {
14708
+ return false;
14709
+ }
14710
+ pressArrow(axis, arrow, part) {
14711
+ const press = { axis, arrow, timer: undefined };
14712
+ this.barPress = press;
14713
+ const step = (amount, delay) => {
14714
+ part.scrollBy(arrow * amount, "viewport");
14715
+ if (this.barPress !== press)
14716
+ return;
14717
+ press.timer = this._ctx.clock.setTimeout(() => step(delay === 500 ? 0.5 : 0.2, 200), delay);
14718
+ };
14719
+ step(0.5, 500);
14720
+ }
14721
+ thumbPointer(axis, event) {
14722
+ const bar = this._scrollState().bars[axis];
14723
+ const along = axis === 1 ? event.y - bar.track.y : event.x - bar.track.x;
14724
+ const length = axis === 1 ? bar.track.height : bar.track.width;
14725
+ return {
14726
+ at: Math.max(0, Math.min(length, along)) * 2,
14727
+ length: length * 2,
14728
+ start: bar.thumbStart,
14729
+ size: bar.thumbSize
14730
+ };
14731
+ }
14732
+ pressTrack(axis, event) {
14733
+ let thumb = this.thumbPointer(axis, event);
14734
+ const inThumb = thumb.at >= Math.floor(thumb.start / 2) * 2 && thumb.at < Math.ceil((thumb.start + thumb.size) / 2) * 2;
14735
+ if (!inThumb) {
14736
+ const max = this._scrollState().max[axis];
14737
+ this._scrollAxis(axis, thumb.length === 0 ? 0 : thumb.at / thumb.length * max, false);
14738
+ if (this.isDestroyed)
14739
+ return;
14740
+ thumb = this.thumbPointer(axis, event);
14741
+ }
14742
+ this.barPress = { axis, offset: Math.max(0, Math.min(thumb.size, thumb.at - thumb.start)) };
14743
+ }
14744
+ dragThumb(press, event) {
14745
+ const thumb = this.thumbPointer(press.axis, event);
14746
+ const span = Math.max(0, thumb.length - thumb.size);
14747
+ const start = Math.max(0, Math.min(span, thumb.at - press.offset));
14748
+ this._scrollAxis(press.axis, span === 0 ? 0 : start / span * this._scrollState().max[press.axis], false);
14749
+ }
14750
+ endBarPress() {
14751
+ const press = this.barPress;
14752
+ this.barPress = undefined;
14753
+ if (press && "timer" in press && press.timer !== undefined)
14754
+ this._ctx.clock.clearTimeout(press.timer);
14755
+ }
14756
+ handleKeyPress(key) {
14757
+ if (this.verticalScrollBar.handleKeyPress(key) || this.horizontalScrollBar.handleKeyPress(key)) {
14377
14758
  this.scrollAccel.reset();
14378
14759
  this.resetScrollAccumulators();
14379
- this.syncManualScrollState();
14380
14760
  return true;
14381
14761
  }
14382
14762
  return false;
@@ -14459,8 +14839,7 @@ class ScrollBoxRenderable extends BoxRenderable2 {
14459
14839
  if (distToLeft <= this.autoScrollThresholdHorizontal) {
14460
14840
  return this.scrollLeft > 0 ? -1 : 0;
14461
14841
  } else if (distToRight <= this.autoScrollThresholdHorizontal) {
14462
- const maxScrollLeft = this.scrollWidth - this.viewport.width;
14463
- return this.scrollLeft < maxScrollLeft ? 1 : 0;
14842
+ return this.scrollLeft < this._scrollState().max[0] ? 1 : 0;
14464
14843
  }
14465
14844
  return 0;
14466
14845
  }
@@ -14471,8 +14850,7 @@ class ScrollBoxRenderable extends BoxRenderable2 {
14471
14850
  if (distToTop <= this.autoScrollThresholdVertical) {
14472
14851
  return this.scrollTop > 0 ? -1 : 0;
14473
14852
  } else if (distToBottom <= this.autoScrollThresholdVertical) {
14474
- const maxScrollTop = this.scrollHeight - this.viewport.height;
14475
- return this.scrollTop < maxScrollTop ? 1 : 0;
14853
+ return this.scrollTop < this._scrollState().max[1] ? 1 : 0;
14476
14854
  }
14477
14855
  return 0;
14478
14856
  }
@@ -14492,115 +14870,31 @@ class ScrollBoxRenderable extends BoxRenderable2 {
14492
14870
  return this.autoScrollSpeedSlow;
14493
14871
  }
14494
14872
  }
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
14873
  set rootOptions(options) {
14570
- this.assignOptions(this, options);
14874
+ this.assignOptions(this, options && stripScrollBoxPadding(options));
14875
+ if (options)
14876
+ this.content._assign(pickScrollBoxPadding(options), ScrollBoxContent.keys);
14571
14877
  if (!this.isDestroyed)
14572
14878
  this.requestRender();
14573
14879
  }
14574
14880
  set wrapperOptions(options) {
14575
- this.assignOptions(this.wrapper, options);
14576
- if (!this.isDestroyed)
14577
- this.requestRender();
14881
+ this.wrapper._assign(options, ScrollBoxWrapper.keys);
14578
14882
  }
14579
14883
  set viewportOptions(options) {
14580
- this.assignOptions(this.viewport, options);
14581
- if (!this.isDestroyed)
14582
- this.requestRender();
14884
+ this.viewport._assign(options, ScrollBoxViewport.keys);
14583
14885
  }
14584
14886
  set contentOptions(options) {
14585
- this.assignOptions(this.content, options);
14586
- if (!this.isDestroyed)
14587
- this.requestRender();
14887
+ this.content._assign(options, ScrollBoxContent.keys);
14588
14888
  }
14589
14889
  set scrollbarOptions(options) {
14590
- this.assignOptions(this.verticalScrollBar, options);
14591
- this.assignOptions(this.horizontalScrollBar, options);
14592
- if (!this.isDestroyed)
14593
- this.requestRender();
14890
+ this.verticalScrollBar._assign(options ?? { onChange: undefined }, ScrollBoxBar.keys);
14891
+ this.horizontalScrollBar._assign(options ?? { onChange: undefined }, ScrollBoxBar.keys);
14594
14892
  }
14595
14893
  set verticalScrollbarOptions(options) {
14596
- this.assignOptions(this.verticalScrollBar, options);
14597
- if (!this.isDestroyed)
14598
- this.requestRender();
14894
+ this.verticalScrollBar._assign(options ?? { onChange: undefined }, ScrollBoxBar.keys);
14599
14895
  }
14600
14896
  set horizontalScrollbarOptions(options) {
14601
- this.assignOptions(this.horizontalScrollBar, options);
14602
- if (!this.isDestroyed)
14603
- this.requestRender();
14897
+ this.horizontalScrollBar._assign(options ?? { onChange: undefined }, ScrollBoxBar.keys);
14604
14898
  }
14605
14899
  get scrollAcceleration() {
14606
14900
  return this.scrollAccel;
@@ -14609,15 +14903,22 @@ class ScrollBoxRenderable extends BoxRenderable2 {
14609
14903
  this.scrollAccel = value;
14610
14904
  }
14611
14905
  get viewportCulling() {
14612
- return this.content.viewportCulling;
14906
+ return this._viewportCulling;
14613
14907
  }
14614
14908
  set viewportCulling(value) {
14615
- this.content.viewportCulling = value;
14616
- this.requestRender();
14909
+ this.setScrollOption(() => this._viewportCulling = value ?? true);
14910
+ }
14911
+ get overflow() {
14912
+ return "hidden";
14617
14913
  }
14914
+ set overflow(_value) {}
14618
14915
  destroySelf() {
14916
+ if (!this.isFreed())
14917
+ this._scrollState();
14619
14918
  const selectionListener = this.selectionListener;
14620
14919
  this.selectionListener = undefined;
14920
+ this.layoutCallbacks = [];
14921
+ this.endBarPress();
14621
14922
  this.runCleanup((run) => {
14622
14923
  if (selectionListener)
14623
14924
  run(() => this._ctx.off("selection", selectionListener));
@@ -14625,6 +14926,14 @@ class ScrollBoxRenderable extends BoxRenderable2 {
14625
14926
  });
14626
14927
  }
14627
14928
  }
14929
+ for (const key of SCROLLBOX_PADDING_KEYS) {
14930
+ Object.defineProperty(ScrollBoxRenderable.prototype, key, {
14931
+ configurable: true,
14932
+ set(value) {
14933
+ this.content[key] = value;
14934
+ }
14935
+ });
14936
+ }
14628
14937
  // src/renderables/Select.ts
14629
14938
  var defaultSelectKeybindings = [
14630
14939
  { name: "up", action: "move-up" },
@@ -15404,8 +15713,9 @@ class TimeToFirstDrawRenderable extends Renderable2 {
15404
15713
  const content = `${this.label}: ${this._runtimeMs.toFixed(this.precision)}ms`;
15405
15714
  const maxWidth = Math.max(this.width, 1);
15406
15715
  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);
15716
+ const [x, y] = this._paintOrigin(buffer);
15717
+ const centeredX = x + Math.max(0, Math.floor((maxWidth - visibleContent.width) / 2));
15718
+ buffer.drawText(visibleContent.text, centeredX, y, this.textColor);
15409
15719
  }
15410
15720
  normalizePrecision(value) {
15411
15721
  if (!Number.isFinite(value)) {
@@ -15537,7 +15847,11 @@ export {
15537
15847
  SYNTHWAVE_MATRIX,
15538
15848
  ScrollBarRenderable,
15539
15849
  ScrollBox,
15850
+ ScrollBoxBar,
15851
+ ScrollBoxContent,
15540
15852
  ScrollBoxRenderable,
15853
+ ScrollBoxViewport,
15854
+ ScrollBoxWrapper,
15541
15855
  Select,
15542
15856
  SelectRenderable,
15543
15857
  SelectRenderableEvents,
@@ -15705,6 +16019,7 @@ export {
15705
16019
  resolveRenderLib2 as resolveRenderLib,
15706
16020
  reverse2 as reverse,
15707
16021
  rgbToHex2 as rgbToHex,
16022
+ scrollUnitSize,
15708
16023
  setRenderLibPath2 as setRenderLibPath,
15709
16024
  setupAudio,
15710
16025
  strikethrough2 as strikethrough,
@@ -15722,5 +16037,5 @@ export {
15722
16037
  yellow2 as yellow
15723
16038
  };
15724
16039
 
15725
- //# debugId=B22B34CB6114361B64756E2164756E21
16040
+ //# debugId=41B4409C26AC698364756E2164756E21
15726
16041
  //# sourceMappingURL=index.node.js.map