opencode-usage 0.4.6 → 0.4.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -648,7 +648,7 @@ function renderTable(dailyStats) {
648
648
  console.log();
649
649
  }
650
650
 
651
- // node_modules/@opentui/core/index-vnvba6q9.js
651
+ // node_modules/@opentui/core/index-rje6z21e.js
652
652
  function wrapAssembly(lib) {
653
653
  function patch(prototype, name, fn) {
654
654
  const original = prototype[name];
@@ -1420,23 +1420,8 @@ function extractCompleteSequences(buffer) {
1420
1420
  return { sequences, remainder: remaining };
1421
1421
  }
1422
1422
  } else {
1423
- const code = remaining.charCodeAt(0);
1424
- if (code >= 55296 && code <= 56319) {
1425
- if (remaining.length === 1) {
1426
- return { sequences, remainder: remaining };
1427
- }
1428
- const next = remaining.charCodeAt(1);
1429
- if (next >= 56320 && next <= 57343) {
1430
- sequences.push(remaining.slice(0, 2));
1431
- pos += 2;
1432
- } else {
1433
- sequences.push(remaining[0]);
1434
- pos++;
1435
- }
1436
- } else {
1437
- sequences.push(remaining[0]);
1438
- pos++;
1439
- }
1423
+ sequences.push(remaining[0]);
1424
+ pos++;
1440
1425
  }
1441
1426
  }
1442
1427
  return { sequences, remainder: "" };
@@ -1881,7 +1866,7 @@ var highlights_default5 = "./highlights-hk7bwhj4.scm";
1881
1866
  // node_modules/@opentui/core/assets/zig/tree-sitter-zig.wasm
1882
1867
  var tree_sitter_zig_default = "./tree-sitter-zig-e78zbjpm.wasm";
1883
1868
 
1884
- // node_modules/@opentui/core/index-vnvba6q9.js
1869
+ // node_modules/@opentui/core/index-rje6z21e.js
1885
1870
  function getParsers() {
1886
1871
  if (!_cachedParsers) {
1887
1872
  _cachedParsers = [
@@ -2643,18 +2628,6 @@ function defineStruct(fields, structDefOptions) {
2643
2628
  };
2644
2629
  }
2645
2630
  import { ptr as ptr3, toArrayBuffer as toArrayBuffer3 } from "bun:ffi";
2646
- function toPointer(value) {
2647
- if (typeof value === "bigint") {
2648
- if (value > BigInt(Number.MAX_SAFE_INTEGER)) {
2649
- throw new Error("Pointer exceeds safe integer range");
2650
- }
2651
- return Number(value);
2652
- }
2653
- return value;
2654
- }
2655
- function toNumber(value) {
2656
- return typeof value === "bigint" ? Number(value) : value;
2657
- }
2658
2631
  function getOpenTUILib(libPath) {
2659
2632
  const resolvedLibPath = libPath || targetLibPath;
2660
2633
  const rawSymbols = dlopen(resolvedLibPath, {
@@ -2814,15 +2787,15 @@ function getOpenTUILib(libPath) {
2814
2787
  args: ["ptr", "i32", "i32", "bool"],
2815
2788
  returns: "void"
2816
2789
  },
2817
- setCursorColor: {
2818
- args: ["ptr", "ptr"],
2790
+ setCursorStyle: {
2791
+ args: ["ptr", "ptr", "u32", "bool"],
2819
2792
  returns: "void"
2820
2793
  },
2821
- getCursorState: {
2794
+ setCursorColor: {
2822
2795
  args: ["ptr", "ptr"],
2823
2796
  returns: "void"
2824
2797
  },
2825
- setCursorStyleOptions: {
2798
+ getCursorState: {
2826
2799
  args: ["ptr", "ptr"],
2827
2800
  returns: "void"
2828
2801
  },
@@ -3553,54 +3526,6 @@ function getOpenTUILib(libPath) {
3553
3526
  bufferDrawChar: {
3554
3527
  args: ["ptr", "u32", "u32", "u32", "ptr", "ptr", "u32"],
3555
3528
  returns: "void"
3556
- },
3557
- createNativeSpanFeed: {
3558
- args: ["ptr"],
3559
- returns: "ptr"
3560
- },
3561
- attachNativeSpanFeed: {
3562
- args: ["ptr"],
3563
- returns: "i32"
3564
- },
3565
- destroyNativeSpanFeed: {
3566
- args: ["ptr"],
3567
- returns: "void"
3568
- },
3569
- streamWrite: {
3570
- args: ["ptr", "ptr", "u64"],
3571
- returns: "i32"
3572
- },
3573
- streamCommit: {
3574
- args: ["ptr"],
3575
- returns: "i32"
3576
- },
3577
- streamDrainSpans: {
3578
- args: ["ptr", "ptr", "u32"],
3579
- returns: "u32"
3580
- },
3581
- streamClose: {
3582
- args: ["ptr"],
3583
- returns: "i32"
3584
- },
3585
- streamReserve: {
3586
- args: ["ptr", "u32", "ptr"],
3587
- returns: "i32"
3588
- },
3589
- streamCommitReserved: {
3590
- args: ["ptr", "u32"],
3591
- returns: "i32"
3592
- },
3593
- streamSetOptions: {
3594
- args: ["ptr", "ptr"],
3595
- returns: "i32"
3596
- },
3597
- streamGetStats: {
3598
- args: ["ptr", "ptr"],
3599
- returns: "i32"
3600
- },
3601
- streamSetCallback: {
3602
- args: ["ptr", "ptr"],
3603
- returns: "void"
3604
3529
  }
3605
3530
  });
3606
3531
  if (env.OTUI_DEBUG_FFI || env.OTUI_TRACE_FFI) {
@@ -9351,168 +9276,91 @@ class MouseParser {
9351
9276
  reset() {
9352
9277
  this.mouseButtonsPressed.clear();
9353
9278
  }
9354
- decodeInput(data) {
9355
- return data.toString();
9356
- }
9357
9279
  parseMouseEvent(data) {
9358
- const str = this.decodeInput(data);
9359
- const parsed = this.parseMouseSequenceAt(str, 0);
9360
- return parsed?.event ?? null;
9361
- }
9362
- parseAllMouseEvents(data) {
9363
- const str = this.decodeInput(data);
9364
- const events = [];
9365
- let offset = 0;
9366
- while (offset < str.length) {
9367
- const parsed = this.parseMouseSequenceAt(str, offset);
9368
- if (!parsed) {
9369
- break;
9370
- }
9371
- events.push(parsed.event);
9372
- offset += parsed.consumed;
9373
- }
9374
- return events;
9375
- }
9376
- parseMouseSequenceAt(str, offset) {
9377
- if (!str.startsWith("\x1B[", offset))
9378
- return null;
9379
- const introducer = str[offset + 2];
9380
- if (introducer === "<") {
9381
- return this.parseSgrSequence(str, offset);
9382
- }
9383
- if (introducer === "M") {
9384
- return this.parseBasicSequence(str, offset);
9385
- }
9386
- return null;
9387
- }
9388
- parseSgrSequence(str, offset) {
9389
- let index = offset + 3;
9390
- const values = [0, 0, 0];
9391
- let part = 0;
9392
- let hasDigit = false;
9393
- while (index < str.length) {
9394
- const char = str[index];
9395
- const charCode = str.charCodeAt(index);
9396
- if (charCode >= 48 && charCode <= 57) {
9397
- hasDigit = true;
9398
- values[part] = values[part] * 10 + (charCode - 48);
9399
- index++;
9400
- continue;
9401
- }
9402
- switch (char) {
9403
- case ";": {
9404
- if (!hasDigit || part >= 2)
9405
- return null;
9406
- part++;
9407
- hasDigit = false;
9408
- index++;
9409
- break;
9280
+ const str = data.toString();
9281
+ const sgrMatch = str.match(/\x1b\[<(\d+);(\d+);(\d+)([Mm])/);
9282
+ if (sgrMatch) {
9283
+ const [, buttonCode, x, y, pressRelease] = sgrMatch;
9284
+ const rawButtonCode = parseInt(buttonCode);
9285
+ const button = rawButtonCode & 3;
9286
+ const isScroll = (rawButtonCode & 64) !== 0;
9287
+ const scrollDirection = !isScroll ? undefined : MouseParser.SCROLL_DIRECTIONS[button];
9288
+ const isMotion = (rawButtonCode & 32) !== 0;
9289
+ const modifiers = {
9290
+ shift: (rawButtonCode & 4) !== 0,
9291
+ alt: (rawButtonCode & 8) !== 0,
9292
+ ctrl: (rawButtonCode & 16) !== 0
9293
+ };
9294
+ let type;
9295
+ let scrollInfo;
9296
+ if (isScroll && pressRelease === "M") {
9297
+ type = "scroll";
9298
+ scrollInfo = {
9299
+ direction: scrollDirection,
9300
+ delta: 1
9301
+ };
9302
+ } else if (isMotion) {
9303
+ const isDragging = this.mouseButtonsPressed.size > 0;
9304
+ if (button === 3) {
9305
+ type = "move";
9306
+ } else if (isDragging) {
9307
+ type = "drag";
9308
+ } else {
9309
+ type = "move";
9410
9310
  }
9411
- case "M":
9412
- case "m": {
9413
- if (!hasDigit || part !== 2)
9414
- return null;
9415
- return {
9416
- event: this.decodeSgrEvent(values[0], values[1], values[2], char),
9417
- consumed: index - offset + 1
9418
- };
9311
+ } else {
9312
+ type = pressRelease === "M" ? "down" : "up";
9313
+ if (type === "down" && button !== 3) {
9314
+ this.mouseButtonsPressed.add(button);
9315
+ } else if (type === "up") {
9316
+ this.mouseButtonsPressed.clear();
9419
9317
  }
9420
- default:
9421
- return null;
9422
9318
  }
9319
+ return {
9320
+ type,
9321
+ button: button === 3 ? 0 : button,
9322
+ x: parseInt(x) - 1,
9323
+ y: parseInt(y) - 1,
9324
+ modifiers,
9325
+ scroll: scrollInfo
9326
+ };
9423
9327
  }
9424
- return null;
9425
- }
9426
- parseBasicSequence(str, offset) {
9427
- if (offset + 6 > str.length)
9428
- return null;
9429
- const buttonByte = str.charCodeAt(offset + 3) - 32;
9430
- const x = str.charCodeAt(offset + 4) - 33;
9431
- const y = str.charCodeAt(offset + 5) - 33;
9432
- return {
9433
- event: this.decodeBasicEvent(buttonByte, x, y),
9434
- consumed: 6
9435
- };
9436
- }
9437
- decodeSgrEvent(rawButtonCode, wireX, wireY, pressRelease) {
9438
- const button = rawButtonCode & 3;
9439
- const isScroll = (rawButtonCode & 64) !== 0;
9440
- const scrollDirection = !isScroll ? undefined : MouseParser.SCROLL_DIRECTIONS[button];
9441
- const isMotion = (rawButtonCode & 32) !== 0;
9442
- const modifiers = {
9443
- shift: (rawButtonCode & 4) !== 0,
9444
- alt: (rawButtonCode & 8) !== 0,
9445
- ctrl: (rawButtonCode & 16) !== 0
9446
- };
9447
- let type;
9448
- let scrollInfo;
9449
- if (isScroll && pressRelease === "M") {
9450
- type = "scroll";
9451
- scrollInfo = {
9452
- direction: scrollDirection,
9453
- delta: 1
9328
+ if (str.startsWith("\x1B[M") && str.length >= 6) {
9329
+ const buttonByte = str.charCodeAt(3) - 32;
9330
+ const x = str.charCodeAt(4) - 33;
9331
+ const y = str.charCodeAt(5) - 33;
9332
+ const button = buttonByte & 3;
9333
+ const isScroll = (buttonByte & 64) !== 0;
9334
+ const scrollDirection = !isScroll ? undefined : MouseParser.SCROLL_DIRECTIONS[button];
9335
+ const modifiers = {
9336
+ shift: (buttonByte & 4) !== 0,
9337
+ alt: (buttonByte & 8) !== 0,
9338
+ ctrl: (buttonByte & 16) !== 0
9454
9339
  };
9455
- } else if (isMotion) {
9456
- const isDragging = this.mouseButtonsPressed.size > 0;
9457
- if (button === 3) {
9458
- type = "move";
9459
- } else if (isDragging) {
9460
- type = "drag";
9340
+ let type;
9341
+ let actualButton;
9342
+ let scrollInfo;
9343
+ if (isScroll) {
9344
+ type = "scroll";
9345
+ actualButton = 0;
9346
+ scrollInfo = {
9347
+ direction: scrollDirection,
9348
+ delta: 1
9349
+ };
9461
9350
  } else {
9462
- type = "move";
9351
+ type = button === 3 ? "up" : "down";
9352
+ actualButton = button === 3 ? 0 : button;
9463
9353
  }
9464
- } else {
9465
- type = pressRelease === "M" ? "down" : "up";
9466
- if (type === "down" && button !== 3) {
9467
- this.mouseButtonsPressed.add(button);
9468
- } else if (type === "up") {
9469
- this.mouseButtonsPressed.clear();
9470
- }
9471
- }
9472
- return {
9473
- type,
9474
- button: button === 3 ? 0 : button,
9475
- x: wireX - 1,
9476
- y: wireY - 1,
9477
- modifiers,
9478
- scroll: scrollInfo
9479
- };
9480
- }
9481
- decodeBasicEvent(buttonByte, x, y) {
9482
- const button = buttonByte & 3;
9483
- const isScroll = (buttonByte & 64) !== 0;
9484
- const isMotion = (buttonByte & 32) !== 0;
9485
- const scrollDirection = !isScroll ? undefined : MouseParser.SCROLL_DIRECTIONS[button];
9486
- const modifiers = {
9487
- shift: (buttonByte & 4) !== 0,
9488
- alt: (buttonByte & 8) !== 0,
9489
- ctrl: (buttonByte & 16) !== 0
9490
- };
9491
- let type;
9492
- let actualButton;
9493
- let scrollInfo;
9494
- if (isScroll) {
9495
- type = "scroll";
9496
- actualButton = 0;
9497
- scrollInfo = {
9498
- direction: scrollDirection,
9499
- delta: 1
9354
+ return {
9355
+ type,
9356
+ button: actualButton,
9357
+ x,
9358
+ y,
9359
+ modifiers,
9360
+ scroll: scrollInfo
9500
9361
  };
9501
- } else if (isMotion) {
9502
- type = "move";
9503
- actualButton = button === 3 ? -1 : button;
9504
- } else {
9505
- type = button === 3 ? "up" : "down";
9506
- actualButton = button === 3 ? 0 : button;
9507
9362
  }
9508
- return {
9509
- type,
9510
- button: actualButton,
9511
- x,
9512
- y,
9513
- modifiers,
9514
- scroll: scrollInfo
9515
- };
9363
+ return null;
9516
9364
  }
9517
9365
  }
9518
9366
 
@@ -11704,59 +11552,6 @@ var CursorStateStruct = defineStruct([
11704
11552
  ["b", "f32"],
11705
11553
  ["a", "f32"]
11706
11554
  ]);
11707
- var CursorStyleOptionsStruct = defineStruct([
11708
- ["style", "u8", { default: 255 }],
11709
- ["blinking", "u8", { default: 255 }],
11710
- [
11711
- "color",
11712
- "pointer",
11713
- {
11714
- optional: true,
11715
- packTransform: rgbaPackTransform,
11716
- unpackTransform: rgbaUnpackTransform
11717
- }
11718
- ],
11719
- ["cursor", "u8", { default: 255 }]
11720
- ]);
11721
- var GrowthPolicyEnum = defineEnum({ grow: 0, block: 1 }, "u8");
11722
- var NativeSpanFeedOptionsStruct = defineStruct([
11723
- ["chunkSize", "u32", { default: 65536 }],
11724
- ["initialChunks", "u32", { default: 2 }],
11725
- ["maxBytes", "u64", { default: 0n }],
11726
- ["growthPolicy", GrowthPolicyEnum, { default: "grow" }],
11727
- ["autoCommitOnFull", "bool_u8", { default: true }],
11728
- ["spanQueueCapacity", "u32", { default: 0 }]
11729
- ]);
11730
- var NativeSpanFeedStatsStruct = defineStruct([
11731
- ["bytesWritten", "u64"],
11732
- ["spansCommitted", "u64"],
11733
- ["chunks", "u32"],
11734
- ["pendingSpans", "u32"]
11735
- ]);
11736
- var SpanInfoStruct = defineStruct([
11737
- ["chunkPtr", "pointer"],
11738
- ["offset", "u32"],
11739
- ["len", "u32"],
11740
- ["chunkIndex", "u32"],
11741
- ["reserved", "u32", { default: 0 }]
11742
- ], {
11743
- reduceValue: (value) => ({
11744
- chunkPtr: value.chunkPtr,
11745
- offset: value.offset,
11746
- len: value.len,
11747
- chunkIndex: value.chunkIndex
11748
- })
11749
- });
11750
- var ReserveInfoStruct = defineStruct([
11751
- ["ptr", "pointer"],
11752
- ["len", "u32"],
11753
- ["reserved", "u32", { default: 0 }]
11754
- ], {
11755
- reduceValue: (value) => ({
11756
- ptr: value.ptr,
11757
- len: value.len
11758
- })
11759
- });
11760
11555
  var module = await import(`@opentui/core-${process.platform}-${process.arch}/index.ts`);
11761
11556
  var targetLibPath = module.default;
11762
11557
  if (isBunfsPath(targetLibPath)) {
@@ -11801,9 +11596,6 @@ registerEnvVar({
11801
11596
  type: "boolean",
11802
11597
  default: false
11803
11598
  });
11804
- var CURSOR_STYLE_TO_ID = { block: 0, line: 1, underline: 2 };
11805
- var CURSOR_ID_TO_STYLE = ["block", "line", "underline"];
11806
- var MOUSE_STYLE_TO_ID = { default: 0, pointer: 1, text: 2, crosshair: 3, move: 4, "not-allowed": 5 };
11807
11599
  var globalTraceSymbols = null;
11808
11600
  var globalFFILogWriter = null;
11809
11601
  var exitHandlerRegistered = false;
@@ -11823,8 +11615,6 @@ class FFIRenderLib {
11823
11615
  eventCallbackWrapper;
11824
11616
  _nativeEvents = new EventEmitter5;
11825
11617
  _anyEventHandlers = [];
11826
- nativeSpanFeedCallbackWrapper = null;
11827
- nativeSpanFeedHandlers = new Map;
11828
11618
  constructor(libPath) {
11829
11619
  this.opentui = getOpenTUILib(libPath);
11830
11620
  this.setupLogging();
@@ -11914,25 +11704,6 @@ class FFIRenderLib {
11914
11704
  }
11915
11705
  this.setEventCallback(eventCallback.ptr);
11916
11706
  }
11917
- ensureNativeSpanFeedCallback() {
11918
- if (this.nativeSpanFeedCallbackWrapper) {
11919
- return this.nativeSpanFeedCallbackWrapper;
11920
- }
11921
- const callback = new JSCallback((streamPtr, eventId, arg0, arg1) => {
11922
- const handler = this.nativeSpanFeedHandlers.get(toPointer(streamPtr));
11923
- if (handler) {
11924
- handler(eventId, arg0, arg1);
11925
- }
11926
- }, {
11927
- args: ["ptr", "u32", "ptr", "u64"],
11928
- returns: "void"
11929
- });
11930
- this.nativeSpanFeedCallbackWrapper = callback;
11931
- if (!callback.ptr) {
11932
- throw new Error("Failed to create native span feed callback");
11933
- }
11934
- return callback;
11935
- }
11936
11707
  setEventCallback(callbackPtr) {
11937
11708
  this.opentui.symbols.setEventCallback(callbackPtr);
11938
11709
  }
@@ -12100,6 +11871,10 @@ class FFIRenderLib {
12100
11871
  setCursorPosition(renderer, x, y, visible) {
12101
11872
  this.opentui.symbols.setCursorPosition(renderer, x, y, visible);
12102
11873
  }
11874
+ setCursorStyle(renderer, style, blinking) {
11875
+ const stylePtr = this.encoder.encode(style);
11876
+ this.opentui.symbols.setCursorStyle(renderer, stylePtr, style.length, blinking);
11877
+ }
12103
11878
  setCursorColor(renderer, color) {
12104
11879
  this.opentui.symbols.setCursorColor(renderer, color.buffer);
12105
11880
  }
@@ -12107,22 +11882,20 @@ class FFIRenderLib {
12107
11882
  const cursorBuffer = new ArrayBuffer(CursorStateStruct.size);
12108
11883
  this.opentui.symbols.getCursorState(renderer, ptr4(cursorBuffer));
12109
11884
  const struct = CursorStateStruct.unpack(cursorBuffer);
11885
+ const styleMap = {
11886
+ 0: "block",
11887
+ 1: "line",
11888
+ 2: "underline"
11889
+ };
12110
11890
  return {
12111
11891
  x: struct.x,
12112
11892
  y: struct.y,
12113
11893
  visible: struct.visible,
12114
- style: CURSOR_ID_TO_STYLE[struct.style] ?? "block",
11894
+ style: styleMap[struct.style] || "block",
12115
11895
  blinking: struct.blinking,
12116
11896
  color: RGBA.fromValues(struct.r, struct.g, struct.b, struct.a)
12117
11897
  };
12118
11898
  }
12119
- setCursorStyleOptions(renderer, options) {
12120
- const style = options.style != null ? CURSOR_STYLE_TO_ID[options.style] : 255;
12121
- const blinking = options.blinking != null ? options.blinking ? 1 : 0 : 255;
12122
- const cursor = options.cursor != null ? MOUSE_STYLE_TO_ID[options.cursor] : 255;
12123
- const buffer = CursorStyleOptionsStruct.pack({ style, blinking, color: options.color, cursor });
12124
- this.opentui.symbols.setCursorStyleOptions(renderer, ptr4(buffer));
12125
- }
12126
11899
  render(renderer, force) {
12127
11900
  this.opentui.symbols.render(renderer, force);
12128
11901
  }
@@ -12962,73 +12735,6 @@ class FFIRenderLib {
12962
12735
  bufferDrawChar(buffer, char, x, y, fg2, bg2, attributes = 0) {
12963
12736
  this.opentui.symbols.bufferDrawChar(buffer, char, x, y, fg2.buffer, bg2.buffer, attributes);
12964
12737
  }
12965
- registerNativeSpanFeedStream(stream, handler) {
12966
- const callback = this.ensureNativeSpanFeedCallback();
12967
- this.nativeSpanFeedHandlers.set(toPointer(stream), handler);
12968
- this.opentui.symbols.streamSetCallback(stream, callback.ptr);
12969
- }
12970
- unregisterNativeSpanFeedStream(stream) {
12971
- this.opentui.symbols.streamSetCallback(stream, null);
12972
- this.nativeSpanFeedHandlers.delete(toPointer(stream));
12973
- }
12974
- createNativeSpanFeed(options) {
12975
- const optionsBuffer = options == null ? null : NativeSpanFeedOptionsStruct.pack(options);
12976
- const streamPtr = this.opentui.symbols.createNativeSpanFeed(optionsBuffer ? ptr4(optionsBuffer) : null);
12977
- if (!streamPtr) {
12978
- throw new Error("Failed to create stream");
12979
- }
12980
- return toPointer(streamPtr);
12981
- }
12982
- attachNativeSpanFeed(stream) {
12983
- return this.opentui.symbols.attachNativeSpanFeed(stream);
12984
- }
12985
- destroyNativeSpanFeed(stream) {
12986
- this.opentui.symbols.destroyNativeSpanFeed(stream);
12987
- this.nativeSpanFeedHandlers.delete(toPointer(stream));
12988
- }
12989
- streamWrite(stream, data) {
12990
- const bytes = typeof data === "string" ? this.encoder.encode(data) : data;
12991
- return this.opentui.symbols.streamWrite(stream, ptr4(bytes), bytes.length);
12992
- }
12993
- streamCommit(stream) {
12994
- return this.opentui.symbols.streamCommit(stream);
12995
- }
12996
- streamDrainSpans(stream, outBuffer, maxSpans) {
12997
- const count = this.opentui.symbols.streamDrainSpans(stream, ptr4(outBuffer), maxSpans);
12998
- return toNumber(count);
12999
- }
13000
- streamClose(stream) {
13001
- return this.opentui.symbols.streamClose(stream);
13002
- }
13003
- streamSetOptions(stream, options) {
13004
- const optionsBuffer = NativeSpanFeedOptionsStruct.pack(options);
13005
- return this.opentui.symbols.streamSetOptions(stream, ptr4(optionsBuffer));
13006
- }
13007
- streamGetStats(stream) {
13008
- const statsBuffer = new ArrayBuffer(NativeSpanFeedStatsStruct.size);
13009
- const status = this.opentui.symbols.streamGetStats(stream, ptr4(statsBuffer));
13010
- if (status !== 0) {
13011
- return null;
13012
- }
13013
- const stats = NativeSpanFeedStatsStruct.unpack(statsBuffer);
13014
- return {
13015
- bytesWritten: typeof stats.bytesWritten === "bigint" ? stats.bytesWritten : BigInt(stats.bytesWritten),
13016
- spansCommitted: typeof stats.spansCommitted === "bigint" ? stats.spansCommitted : BigInt(stats.spansCommitted),
13017
- chunks: stats.chunks,
13018
- pendingSpans: stats.pendingSpans
13019
- };
13020
- }
13021
- streamReserve(stream, minLen) {
13022
- const reserveBuffer = new ArrayBuffer(ReserveInfoStruct.size);
13023
- const status = this.opentui.symbols.streamReserve(stream, minLen, ptr4(reserveBuffer));
13024
- if (status !== 0) {
13025
- return { status, info: null };
13026
- }
13027
- return { status, info: ReserveInfoStruct.unpack(reserveBuffer) };
13028
- }
13029
- streamCommitReserved(stream, length) {
13030
- return this.opentui.symbols.streamCommitReserved(stream, length);
13031
- }
13032
12738
  createSyntaxStyle() {
13033
12739
  const stylePtr = this.opentui.symbols.createSyntaxStyle();
13034
12740
  if (!stylePtr) {
@@ -15779,7 +15485,6 @@ class CliRenderer extends EventEmitter9 {
15779
15485
  _latestPointer = { x: 0, y: 0 };
15780
15486
  _hasPointer = false;
15781
15487
  _lastPointerModifiers = { shift: false, alt: false, ctrl: false };
15782
- _currentMousePointerStyle = undefined;
15783
15488
  _currentFocusedRenderable = null;
15784
15489
  lifecyclePasses = new Set;
15785
15490
  _openConsoleOnError = true;
@@ -16364,135 +16069,125 @@ Captured output:
16364
16069
  return event;
16365
16070
  }
16366
16071
  handleMouseData(data) {
16367
- const mouseEvents = this.mouseParser.parseAllMouseEvents(data);
16368
- if (mouseEvents.length === 0)
16369
- return false;
16370
- let anyHandled = false;
16371
- for (const mouseEvent of mouseEvents) {
16372
- if (this.processSingleMouseEvent(mouseEvent)) {
16373
- anyHandled = true;
16072
+ const mouseEvent = this.mouseParser.parseMouseEvent(data);
16073
+ if (mouseEvent) {
16074
+ if (this._splitHeight > 0) {
16075
+ if (mouseEvent.y < this.renderOffset) {
16076
+ return false;
16077
+ }
16078
+ mouseEvent.y -= this.renderOffset;
16079
+ }
16080
+ this._latestPointer.x = mouseEvent.x;
16081
+ this._latestPointer.y = mouseEvent.y;
16082
+ this._hasPointer = true;
16083
+ this._lastPointerModifiers = mouseEvent.modifiers;
16084
+ if (this._console.visible) {
16085
+ const consoleBounds = this._console.bounds;
16086
+ if (mouseEvent.x >= consoleBounds.x && mouseEvent.x < consoleBounds.x + consoleBounds.width && mouseEvent.y >= consoleBounds.y && mouseEvent.y < consoleBounds.y + consoleBounds.height) {
16087
+ const event2 = new MouseEvent(null, mouseEvent);
16088
+ const handled = this._console.handleMouse(event2);
16089
+ if (handled)
16090
+ return true;
16091
+ }
16374
16092
  }
16375
- }
16376
- return anyHandled;
16377
- }
16378
- processSingleMouseEvent(mouseEvent) {
16379
- if (this._splitHeight > 0) {
16380
- if (mouseEvent.y < this.renderOffset) {
16381
- return false;
16093
+ if (mouseEvent.type === "scroll") {
16094
+ const maybeRenderableId2 = this.hitTest(mouseEvent.x, mouseEvent.y);
16095
+ const maybeRenderable2 = Renderable.renderablesByNumber.get(maybeRenderableId2);
16096
+ if (maybeRenderable2) {
16097
+ const event2 = new MouseEvent(maybeRenderable2, mouseEvent);
16098
+ maybeRenderable2.processMouseEvent(event2);
16099
+ }
16100
+ return true;
16382
16101
  }
16383
- mouseEvent.y -= this.renderOffset;
16384
- }
16385
- this._latestPointer.x = mouseEvent.x;
16386
- this._latestPointer.y = mouseEvent.y;
16387
- this._hasPointer = true;
16388
- this._lastPointerModifiers = mouseEvent.modifiers;
16389
- if (this._console.visible) {
16390
- const consoleBounds = this._console.bounds;
16391
- if (mouseEvent.x >= consoleBounds.x && mouseEvent.x < consoleBounds.x + consoleBounds.width && mouseEvent.y >= consoleBounds.y && mouseEvent.y < consoleBounds.y + consoleBounds.height) {
16392
- const event2 = new MouseEvent(null, mouseEvent);
16393
- const handled = this._console.handleMouse(event2);
16394
- if (handled)
16102
+ const maybeRenderableId = this.hitTest(mouseEvent.x, mouseEvent.y);
16103
+ const sameElement = maybeRenderableId === this.lastOverRenderableNum;
16104
+ this.lastOverRenderableNum = maybeRenderableId;
16105
+ const maybeRenderable = Renderable.renderablesByNumber.get(maybeRenderableId);
16106
+ if (mouseEvent.type === "down" && mouseEvent.button === 0 && !this.currentSelection?.isDragging && !mouseEvent.modifiers.ctrl) {
16107
+ if (maybeRenderable && maybeRenderable.selectable && !maybeRenderable.isDestroyed && maybeRenderable.shouldStartSelection(mouseEvent.x, mouseEvent.y)) {
16108
+ this.startSelection(maybeRenderable, mouseEvent.x, mouseEvent.y);
16109
+ this.dispatchMouseEvent(maybeRenderable, mouseEvent);
16395
16110
  return true;
16111
+ }
16396
16112
  }
16397
- }
16398
- if (mouseEvent.type === "scroll") {
16399
- const maybeRenderableId2 = this.hitTest(mouseEvent.x, mouseEvent.y);
16400
- const maybeRenderable2 = Renderable.renderablesByNumber.get(maybeRenderableId2);
16401
- const fallbackTarget = this._currentFocusedRenderable && !this._currentFocusedRenderable.isDestroyed && this._currentFocusedRenderable.focused ? this._currentFocusedRenderable : null;
16402
- const scrollTarget = maybeRenderable2 ?? fallbackTarget;
16403
- if (scrollTarget) {
16404
- const event2 = new MouseEvent(scrollTarget, mouseEvent);
16405
- scrollTarget.processMouseEvent(event2);
16113
+ if (mouseEvent.type === "drag" && this.currentSelection?.isDragging) {
16114
+ this.updateSelection(maybeRenderable, mouseEvent.x, mouseEvent.y);
16115
+ if (maybeRenderable) {
16116
+ const event2 = new MouseEvent(maybeRenderable, { ...mouseEvent, isDragging: true });
16117
+ maybeRenderable.processMouseEvent(event2);
16118
+ }
16119
+ return true;
16406
16120
  }
16407
- return true;
16408
- }
16409
- const maybeRenderableId = this.hitTest(mouseEvent.x, mouseEvent.y);
16410
- const sameElement = maybeRenderableId === this.lastOverRenderableNum;
16411
- this.lastOverRenderableNum = maybeRenderableId;
16412
- const maybeRenderable = Renderable.renderablesByNumber.get(maybeRenderableId);
16413
- if (mouseEvent.type === "down" && mouseEvent.button === 0 && !this.currentSelection?.isDragging && !mouseEvent.modifiers.ctrl) {
16414
- if (maybeRenderable && maybeRenderable.selectable && !maybeRenderable.isDestroyed && maybeRenderable.shouldStartSelection(mouseEvent.x, mouseEvent.y)) {
16415
- this.startSelection(maybeRenderable, mouseEvent.x, mouseEvent.y);
16416
- this.dispatchMouseEvent(maybeRenderable, mouseEvent);
16121
+ if (mouseEvent.type === "up" && this.currentSelection?.isDragging) {
16122
+ if (maybeRenderable) {
16123
+ const event2 = new MouseEvent(maybeRenderable, { ...mouseEvent, isDragging: true });
16124
+ maybeRenderable.processMouseEvent(event2);
16125
+ }
16126
+ this.finishSelection();
16417
16127
  return true;
16418
16128
  }
16419
- }
16420
- if (mouseEvent.type === "drag" && this.currentSelection?.isDragging) {
16421
- this.updateSelection(maybeRenderable, mouseEvent.x, mouseEvent.y);
16422
- if (maybeRenderable) {
16423
- const event2 = new MouseEvent(maybeRenderable, { ...mouseEvent, isDragging: true });
16424
- maybeRenderable.processMouseEvent(event2);
16129
+ if (mouseEvent.type === "down" && mouseEvent.button === 0 && this.currentSelection) {
16130
+ if (mouseEvent.modifiers.ctrl) {
16131
+ this.currentSelection.isDragging = true;
16132
+ this.updateSelection(maybeRenderable, mouseEvent.x, mouseEvent.y);
16133
+ return true;
16134
+ }
16425
16135
  }
16426
- return true;
16427
- }
16428
- if (mouseEvent.type === "up" && this.currentSelection?.isDragging) {
16429
- if (maybeRenderable) {
16430
- const event2 = new MouseEvent(maybeRenderable, { ...mouseEvent, isDragging: true });
16431
- maybeRenderable.processMouseEvent(event2);
16136
+ if (!sameElement && (mouseEvent.type === "drag" || mouseEvent.type === "move")) {
16137
+ if (this.lastOverRenderable && this.lastOverRenderable !== this.capturedRenderable) {
16138
+ const event2 = new MouseEvent(this.lastOverRenderable, { ...mouseEvent, type: "out" });
16139
+ this.lastOverRenderable.processMouseEvent(event2);
16140
+ }
16141
+ this.lastOverRenderable = maybeRenderable;
16142
+ if (maybeRenderable) {
16143
+ const event2 = new MouseEvent(maybeRenderable, {
16144
+ ...mouseEvent,
16145
+ type: "over",
16146
+ source: this.capturedRenderable
16147
+ });
16148
+ maybeRenderable.processMouseEvent(event2);
16149
+ }
16432
16150
  }
16433
- this.finishSelection();
16434
- return true;
16435
- }
16436
- if (mouseEvent.type === "down" && mouseEvent.button === 0 && this.currentSelection) {
16437
- if (mouseEvent.modifiers.ctrl) {
16438
- this.currentSelection.isDragging = true;
16439
- this.updateSelection(maybeRenderable, mouseEvent.x, mouseEvent.y);
16151
+ if (this.capturedRenderable && mouseEvent.type !== "up") {
16152
+ const event2 = new MouseEvent(this.capturedRenderable, mouseEvent);
16153
+ this.capturedRenderable.processMouseEvent(event2);
16440
16154
  return true;
16441
16155
  }
16442
- }
16443
- if (!sameElement && (mouseEvent.type === "drag" || mouseEvent.type === "move")) {
16444
- if (this.lastOverRenderable && this.lastOverRenderable !== this.capturedRenderable) {
16445
- const event2 = new MouseEvent(this.lastOverRenderable, { ...mouseEvent, type: "out" });
16446
- this.lastOverRenderable.processMouseEvent(event2);
16447
- }
16448
- this.lastOverRenderable = maybeRenderable;
16449
- if (maybeRenderable) {
16450
- const event2 = new MouseEvent(maybeRenderable, {
16451
- ...mouseEvent,
16452
- type: "over",
16453
- source: this.capturedRenderable
16454
- });
16455
- maybeRenderable.processMouseEvent(event2);
16156
+ if (this.capturedRenderable && mouseEvent.type === "up") {
16157
+ const event2 = new MouseEvent(this.capturedRenderable, { ...mouseEvent, type: "drag-end" });
16158
+ this.capturedRenderable.processMouseEvent(event2);
16159
+ this.capturedRenderable.processMouseEvent(new MouseEvent(this.capturedRenderable, mouseEvent));
16160
+ if (maybeRenderable) {
16161
+ const event3 = new MouseEvent(maybeRenderable, {
16162
+ ...mouseEvent,
16163
+ type: "drop",
16164
+ source: this.capturedRenderable
16165
+ });
16166
+ maybeRenderable.processMouseEvent(event3);
16167
+ }
16168
+ this.lastOverRenderable = this.capturedRenderable;
16169
+ this.lastOverRenderableNum = this.capturedRenderable.num;
16170
+ this.setCapturedRenderable(undefined);
16171
+ this.requestRender();
16456
16172
  }
16457
- }
16458
- if (this.capturedRenderable && mouseEvent.type !== "up") {
16459
- const event2 = new MouseEvent(this.capturedRenderable, mouseEvent);
16460
- this.capturedRenderable.processMouseEvent(event2);
16461
- return true;
16462
- }
16463
- if (this.capturedRenderable && mouseEvent.type === "up") {
16464
- const event2 = new MouseEvent(this.capturedRenderable, { ...mouseEvent, type: "drag-end" });
16465
- this.capturedRenderable.processMouseEvent(event2);
16466
- this.capturedRenderable.processMouseEvent(new MouseEvent(this.capturedRenderable, mouseEvent));
16173
+ let event;
16467
16174
  if (maybeRenderable) {
16468
- const event3 = new MouseEvent(maybeRenderable, {
16469
- ...mouseEvent,
16470
- type: "drop",
16471
- source: this.capturedRenderable
16472
- });
16473
- maybeRenderable.processMouseEvent(event3);
16474
- }
16475
- this.lastOverRenderable = this.capturedRenderable;
16476
- this.lastOverRenderableNum = this.capturedRenderable.num;
16477
- this.setCapturedRenderable(undefined);
16478
- this.requestRender();
16479
- }
16480
- let event;
16481
- if (maybeRenderable) {
16482
- if (mouseEvent.type === "drag" && mouseEvent.button === 0) {
16483
- this.setCapturedRenderable(maybeRenderable);
16175
+ if (mouseEvent.type === "drag" && mouseEvent.button === 0) {
16176
+ this.setCapturedRenderable(maybeRenderable);
16177
+ } else {
16178
+ this.setCapturedRenderable(undefined);
16179
+ }
16180
+ event = this.dispatchMouseEvent(maybeRenderable, mouseEvent);
16484
16181
  } else {
16485
16182
  this.setCapturedRenderable(undefined);
16183
+ this.lastOverRenderable = undefined;
16486
16184
  }
16487
- event = this.dispatchMouseEvent(maybeRenderable, mouseEvent);
16488
- } else {
16489
- this.setCapturedRenderable(undefined);
16490
- this.lastOverRenderable = undefined;
16491
- }
16492
- if (!event?.defaultPrevented && mouseEvent.type === "down" && this.currentSelection) {
16493
- this.clearSelection();
16185
+ if (!event?.defaultPrevented && mouseEvent.type === "down" && this.currentSelection) {
16186
+ this.clearSelection();
16187
+ }
16188
+ return true;
16494
16189
  }
16495
- return true;
16190
+ return false;
16496
16191
  }
16497
16192
  recheckHoverState() {
16498
16193
  if (this._isDestroyed || !this._hasPointer)
@@ -16527,10 +16222,6 @@ Captured output:
16527
16222
  hitRenderable.processMouseEvent(event);
16528
16223
  }
16529
16224
  }
16530
- setMousePointer(style) {
16531
- this._currentMousePointerStyle = style;
16532
- this.lib.setCursorStyleOptions(this.rendererPtr, { cursor: style });
16533
- }
16534
16225
  hitTest(x, y) {
16535
16226
  return this.lib.checkHit(this.rendererPtr, x, y);
16536
16227
  }
@@ -16673,11 +16364,11 @@ Captured output:
16673
16364
  const lib = resolveRenderLib();
16674
16365
  lib.setCursorPosition(renderer.rendererPtr, x, y, visible);
16675
16366
  }
16676
- static setCursorStyle(renderer, options) {
16367
+ static setCursorStyle(renderer, style, blinking = false, color) {
16677
16368
  const lib = resolveRenderLib();
16678
- lib.setCursorStyleOptions(renderer.rendererPtr, options);
16679
- if (options.cursor !== undefined) {
16680
- renderer._currentMousePointerStyle = options.cursor;
16369
+ lib.setCursorStyle(renderer.rendererPtr, style, blinking);
16370
+ if (color) {
16371
+ lib.setCursorColor(renderer.rendererPtr, color);
16681
16372
  }
16682
16373
  }
16683
16374
  static setCursorColor(renderer, color) {
@@ -16687,10 +16378,10 @@ Captured output:
16687
16378
  setCursorPosition(x, y, visible = true) {
16688
16379
  this.lib.setCursorPosition(this.rendererPtr, x, y, visible);
16689
16380
  }
16690
- setCursorStyle(options) {
16691
- this.lib.setCursorStyleOptions(this.rendererPtr, options);
16692
- if (options.cursor !== undefined) {
16693
- this._currentMousePointerStyle = options.cursor;
16381
+ setCursorStyle(style, blinking = false, color) {
16382
+ this.lib.setCursorStyle(this.rendererPtr, style, blinking);
16383
+ if (color) {
16384
+ this.lib.setCursorColor(this.rendererPtr, color);
16694
16385
  }
16695
16386
  }
16696
16387
  setCursorColor(color) {
@@ -17196,19 +16887,6 @@ function convertThemeToStyles(theme) {
17196
16887
  }
17197
16888
  return flatStyles;
17198
16889
  }
17199
- import { toArrayBuffer as toArrayBuffer5 } from "bun:ffi";
17200
- function toPointer2(value) {
17201
- if (typeof value === "bigint") {
17202
- if (value > BigInt(Number.MAX_SAFE_INTEGER)) {
17203
- throw new Error("Pointer exceeds safe integer range");
17204
- }
17205
- return Number(value);
17206
- }
17207
- return value;
17208
- }
17209
- function toNumber2(value) {
17210
- return typeof value === "bigint" ? Number(value) : value;
17211
- }
17212
16890
  function isGapType(value) {
17213
16891
  if (value === undefined) {
17214
16892
  return true;
@@ -18564,252 +18242,6 @@ class TimelineEngine {
18564
18242
  }
18565
18243
  var engine = new TimelineEngine;
18566
18244
 
18567
- class NativeSpanFeed {
18568
- static create(options) {
18569
- const lib = resolveRenderLib();
18570
- const streamPtr = lib.createNativeSpanFeed(options);
18571
- const stream = new NativeSpanFeed(streamPtr);
18572
- lib.registerNativeSpanFeedStream(streamPtr, stream.eventHandler);
18573
- const status = lib.attachNativeSpanFeed(streamPtr);
18574
- if (status !== 0) {
18575
- lib.unregisterNativeSpanFeedStream(streamPtr);
18576
- lib.destroyNativeSpanFeed(streamPtr);
18577
- throw new Error(`Failed to attach stream: ${status}`);
18578
- }
18579
- return stream;
18580
- }
18581
- static attach(streamPtr, _options) {
18582
- const lib = resolveRenderLib();
18583
- const ptr5 = toPointer2(streamPtr);
18584
- const stream = new NativeSpanFeed(ptr5);
18585
- lib.registerNativeSpanFeedStream(ptr5, stream.eventHandler);
18586
- const status = lib.attachNativeSpanFeed(ptr5);
18587
- if (status !== 0) {
18588
- lib.unregisterNativeSpanFeedStream(ptr5);
18589
- throw new Error(`Failed to attach stream: ${status}`);
18590
- }
18591
- return stream;
18592
- }
18593
- streamPtr;
18594
- lib = resolveRenderLib();
18595
- eventHandler;
18596
- chunkMap = new Map;
18597
- chunkSizes = new Map;
18598
- dataHandlers = new Set;
18599
- errorHandlers = new Set;
18600
- drainBuffer = null;
18601
- stateBuffer = null;
18602
- closed = false;
18603
- destroyed = false;
18604
- draining = false;
18605
- pendingDataAvailable = false;
18606
- pendingClose = false;
18607
- closing = false;
18608
- pendingAsyncHandlers = 0;
18609
- inCallback = false;
18610
- closeQueued = false;
18611
- constructor(streamPtr) {
18612
- this.streamPtr = streamPtr;
18613
- this.eventHandler = (eventId, arg0, arg1) => {
18614
- this.handleEvent(eventId, arg0, arg1);
18615
- };
18616
- this.ensureDrainBuffer();
18617
- }
18618
- ensureDrainBuffer() {
18619
- if (this.drainBuffer)
18620
- return;
18621
- const capacity = 256;
18622
- this.drainBuffer = new Uint8Array(capacity * SpanInfoStruct.size);
18623
- }
18624
- onData(handler) {
18625
- this.dataHandlers.add(handler);
18626
- if (this.pendingDataAvailable) {
18627
- this.pendingDataAvailable = false;
18628
- this.drainAll();
18629
- }
18630
- return () => this.dataHandlers.delete(handler);
18631
- }
18632
- onError(handler) {
18633
- this.errorHandlers.add(handler);
18634
- return () => this.errorHandlers.delete(handler);
18635
- }
18636
- close() {
18637
- if (this.destroyed)
18638
- return;
18639
- if (this.inCallback || this.draining || this.pendingAsyncHandlers > 0) {
18640
- this.pendingClose = true;
18641
- if (!this.closeQueued) {
18642
- this.closeQueued = true;
18643
- queueMicrotask(() => {
18644
- this.closeQueued = false;
18645
- this.processPendingClose();
18646
- });
18647
- }
18648
- return;
18649
- }
18650
- this.performClose();
18651
- }
18652
- processPendingClose() {
18653
- if (!this.pendingClose || this.destroyed)
18654
- return;
18655
- if (this.inCallback || this.draining || this.pendingAsyncHandlers > 0)
18656
- return;
18657
- this.pendingClose = false;
18658
- this.performClose();
18659
- }
18660
- performClose() {
18661
- if (this.closing)
18662
- return;
18663
- this.closing = true;
18664
- if (!this.closed) {
18665
- const status = this.lib.streamClose(this.streamPtr);
18666
- if (status !== 0) {
18667
- this.closing = false;
18668
- return;
18669
- }
18670
- this.closed = true;
18671
- }
18672
- this.finalizeDestroy();
18673
- }
18674
- finalizeDestroy() {
18675
- if (this.destroyed)
18676
- return;
18677
- this.lib.unregisterNativeSpanFeedStream(this.streamPtr);
18678
- this.lib.destroyNativeSpanFeed(this.streamPtr);
18679
- this.destroyed = true;
18680
- this.chunkMap.clear();
18681
- this.chunkSizes.clear();
18682
- this.stateBuffer = null;
18683
- this.drainBuffer = null;
18684
- this.dataHandlers.clear();
18685
- this.errorHandlers.clear();
18686
- this.pendingDataAvailable = false;
18687
- }
18688
- handleEvent(eventId, arg0, arg1) {
18689
- this.inCallback = true;
18690
- try {
18691
- switch (eventId) {
18692
- case 8: {
18693
- const len = toNumber2(arg1);
18694
- if (len > 0 && arg0) {
18695
- const buffer = toArrayBuffer5(arg0, 0, len);
18696
- this.stateBuffer = new Uint8Array(buffer);
18697
- }
18698
- break;
18699
- }
18700
- case 7: {
18701
- if (this.closing)
18702
- break;
18703
- if (this.dataHandlers.size === 0) {
18704
- this.pendingDataAvailable = true;
18705
- break;
18706
- }
18707
- this.drainAll();
18708
- break;
18709
- }
18710
- case 2: {
18711
- const chunkLen = toNumber2(arg1);
18712
- if (chunkLen > 0 && arg0) {
18713
- if (!this.chunkMap.has(arg0)) {
18714
- const buffer = toArrayBuffer5(arg0, 0, chunkLen);
18715
- this.chunkMap.set(arg0, buffer);
18716
- }
18717
- this.chunkSizes.set(arg0, chunkLen);
18718
- }
18719
- break;
18720
- }
18721
- case 6: {
18722
- const code = arg0;
18723
- for (const handler of this.errorHandlers)
18724
- handler(code);
18725
- break;
18726
- }
18727
- case 5: {
18728
- this.closed = true;
18729
- break;
18730
- }
18731
- default:
18732
- break;
18733
- }
18734
- } finally {
18735
- this.inCallback = false;
18736
- }
18737
- }
18738
- decrementRefcount(chunkIndex) {
18739
- if (this.stateBuffer && chunkIndex < this.stateBuffer.length) {
18740
- const prev = this.stateBuffer[chunkIndex];
18741
- this.stateBuffer[chunkIndex] = prev > 0 ? prev - 1 : 0;
18742
- }
18743
- }
18744
- drainOnce() {
18745
- if (!this.drainBuffer || this.draining || this.pendingClose)
18746
- return 0;
18747
- const capacity = Math.floor(this.drainBuffer.byteLength / SpanInfoStruct.size);
18748
- if (capacity === 0)
18749
- return 0;
18750
- const count = this.lib.streamDrainSpans(this.streamPtr, this.drainBuffer, capacity);
18751
- if (count === 0)
18752
- return 0;
18753
- this.draining = true;
18754
- const spans = SpanInfoStruct.unpackList(this.drainBuffer.buffer, count);
18755
- let firstError = null;
18756
- try {
18757
- for (const span of spans) {
18758
- if (span.len === 0)
18759
- continue;
18760
- let buffer = this.chunkMap.get(span.chunkPtr);
18761
- if (!buffer) {
18762
- const size = this.chunkSizes.get(span.chunkPtr);
18763
- if (!size)
18764
- continue;
18765
- buffer = toArrayBuffer5(span.chunkPtr, 0, size);
18766
- this.chunkMap.set(span.chunkPtr, buffer);
18767
- }
18768
- if (span.offset + span.len > buffer.byteLength)
18769
- continue;
18770
- const slice = new Uint8Array(buffer, span.offset, span.len);
18771
- let asyncResults = null;
18772
- for (const handler of this.dataHandlers) {
18773
- try {
18774
- const result = handler(slice);
18775
- if (result && typeof result.then === "function") {
18776
- asyncResults ??= [];
18777
- asyncResults.push(result);
18778
- }
18779
- } catch (e) {
18780
- firstError ??= e;
18781
- }
18782
- }
18783
- const shouldStopAfterThisSpan = this.pendingClose;
18784
- if (asyncResults) {
18785
- const chunkIndex = span.chunkIndex;
18786
- this.pendingAsyncHandlers += 1;
18787
- Promise.allSettled(asyncResults).then(() => {
18788
- this.decrementRefcount(chunkIndex);
18789
- this.pendingAsyncHandlers -= 1;
18790
- this.processPendingClose();
18791
- });
18792
- } else {
18793
- this.decrementRefcount(span.chunkIndex);
18794
- }
18795
- if (shouldStopAfterThisSpan)
18796
- break;
18797
- }
18798
- } finally {
18799
- this.draining = false;
18800
- }
18801
- if (firstError)
18802
- throw firstError;
18803
- return count;
18804
- }
18805
- drainAll() {
18806
- let count = this.drainOnce();
18807
- while (count > 0) {
18808
- count = this.drainOnce();
18809
- }
18810
- }
18811
- }
18812
-
18813
18245
  class FrameBufferRenderable extends Renderable {
18814
18246
  frameBuffer;
18815
18247
  respectAlpha;
@@ -20497,23 +19929,6 @@ class LineNumberRenderable extends Renderable {
20497
19929
  getLineNumbers() {
20498
19930
  return this._lineNumbers;
20499
19931
  }
20500
- highlightLines(startLine, endLine, color) {
20501
- for (let i = startLine;i <= endLine; i++) {
20502
- this.parseLineColor(i, color);
20503
- }
20504
- if (this.gutter) {
20505
- this.gutter.setLineColors(this._lineColorsGutter, this._lineColorsContent);
20506
- }
20507
- }
20508
- clearHighlightLines(startLine, endLine) {
20509
- for (let i = startLine;i <= endLine; i++) {
20510
- this._lineColorsGutter.delete(i);
20511
- this._lineColorsContent.delete(i);
20512
- }
20513
- if (this.gutter) {
20514
- this.gutter.setLineColors(this._lineColorsGutter, this._lineColorsContent);
20515
- }
20516
- }
20517
19932
  }
20518
19933
 
20519
19934
  class Diff {
@@ -21907,30 +21322,6 @@ class DiffRenderable extends Renderable {
21907
21322
  }
21908
21323
  }
21909
21324
  }
21910
- setLineColor(line, color) {
21911
- this.leftSide?.setLineColor(line, color);
21912
- this.rightSide?.setLineColor(line, color);
21913
- }
21914
- clearLineColor(line) {
21915
- this.leftSide?.clearLineColor(line);
21916
- this.rightSide?.clearLineColor(line);
21917
- }
21918
- setLineColors(lineColors) {
21919
- this.leftSide?.setLineColors(lineColors);
21920
- this.rightSide?.setLineColors(lineColors);
21921
- }
21922
- clearAllLineColors() {
21923
- this.leftSide?.clearAllLineColors();
21924
- this.rightSide?.clearAllLineColors();
21925
- }
21926
- highlightLines(startLine, endLine, color) {
21927
- this.leftSide?.highlightLines(startLine, endLine, color);
21928
- this.rightSide?.highlightLines(startLine, endLine, color);
21929
- }
21930
- clearHighlightLines(startLine, endLine) {
21931
- this.leftSide?.clearHighlightLines(startLine, endLine);
21932
- this.rightSide?.clearHighlightLines(startLine, endLine);
21933
- }
21934
21325
  }
21935
21326
 
21936
21327
  class EditBufferRenderable extends Renderable {
@@ -22362,11 +21753,13 @@ class EditBufferRenderable extends Renderable {
22362
21753
  const cursorX = this.x + visualCursor.visualCol + 1;
22363
21754
  const cursorY = this.y + visualCursor.visualRow + 1;
22364
21755
  this._ctx.setCursorPosition(cursorX, cursorY, true);
22365
- this._ctx.setCursorStyle({ ...this._cursorStyle, color: this._cursorColor });
21756
+ this._ctx.setCursorColor(this._cursorColor);
21757
+ this._ctx.setCursorStyle(this._cursorStyle.style, this._cursorStyle.blinking);
22366
21758
  }
22367
21759
  focus() {
22368
21760
  super.focus();
22369
- this._ctx.setCursorStyle({ ...this._cursorStyle, color: this._cursorColor });
21761
+ this._ctx.setCursorStyle(this._cursorStyle.style, this._cursorStyle.blinking);
21762
+ this._ctx.setCursorColor(this._cursorColor);
22370
21763
  this.requestRender();
22371
21764
  }
22372
21765
  blur() {
@@ -23142,41 +22535,6 @@ class InputRenderable extends TextareaRenderable {
23142
22535
  this.emit("input", this.plainText);
23143
22536
  return result;
23144
22537
  }
23145
- deleteLine() {
23146
- const result = super.deleteLine();
23147
- this.emit("input", this.plainText);
23148
- return result;
23149
- }
23150
- deleteWordBackward() {
23151
- const result = super.deleteWordBackward();
23152
- this.emit("input", this.plainText);
23153
- return result;
23154
- }
23155
- deleteWordForward() {
23156
- const result = super.deleteWordForward();
23157
- this.emit("input", this.plainText);
23158
- return result;
23159
- }
23160
- deleteToLineStart() {
23161
- const result = super.deleteToLineStart();
23162
- this.emit("input", this.plainText);
23163
- return result;
23164
- }
23165
- deleteToLineEnd() {
23166
- const result = super.deleteToLineEnd();
23167
- this.emit("input", this.plainText);
23168
- return result;
23169
- }
23170
- undo() {
23171
- const result = super.undo();
23172
- this.emit("input", this.plainText);
23173
- return result;
23174
- }
23175
- redo() {
23176
- const result = super.redo();
23177
- this.emit("input", this.plainText);
23178
- return result;
23179
- }
23180
22538
  deleteCharacter(direction) {
23181
22539
  if (direction === "backward") {
23182
22540
  this.deleteCharBackward();
@@ -24387,8 +23745,7 @@ class MarkdownRenderable extends Renderable {
24387
23745
  constructor(ctx, options) {
24388
23746
  super(ctx, {
24389
23747
  ...options,
24390
- flexDirection: "column",
24391
- flexShrink: options.flexShrink ?? 0
23748
+ flexDirection: "column"
24392
23749
  });
24393
23750
  this._syntaxStyle = options.syntaxStyle;
24394
23751
  this._conceal = options.conceal ?? this._contentDefaultOptions.conceal;
@@ -24432,7 +23789,8 @@ class MarkdownRenderable extends Renderable {
24432
23789
  set streaming(value) {
24433
23790
  if (this._streaming !== value) {
24434
23791
  this._streaming = value;
24435
- this.clearCache();
23792
+ this.updateBlocks();
23793
+ this.requestRender();
24436
23794
  }
24437
23795
  }
24438
23796
  getStyle(group) {
@@ -28057,7 +27415,7 @@ function createRenderer({
28057
27415
  while (removed = getFirstChild(parent))
28058
27416
  removeNode(parent, removed);
28059
27417
  replacement && insertNode(parent, replacement);
28060
- return replacement ?? "";
27418
+ return replacement;
28061
27419
  }
28062
27420
  const node = replacement || createSlotNode();
28063
27421
  if (current.length) {
@@ -28211,10 +27569,6 @@ function _getParentNode(childNode) {
28211
27569
  if (parent instanceof RootTextNodeRenderable) {
28212
27570
  parent = parent.textParent ?? undefined;
28213
27571
  }
28214
- const scrollBoxCandidate = parent?.parent?.parent?.parent;
28215
- if (scrollBoxCandidate instanceof ScrollBoxRenderable && scrollBoxCandidate.content === parent) {
28216
- parent = scrollBoxCandidate;
28217
- }
28218
27572
  return parent;
28219
27573
  }
28220
27574
  function getComponentCatalogue() {
@@ -30125,4 +29479,4 @@ async function main2() {
30125
29479
  var WATCH_INTERVAL_MS = 5 * 60 * 1000;
30126
29480
  main2().catch(console.error);
30127
29481
 
30128
- //# debugId=97BCA2744D0BF01A64756E2164756E21
29482
+ //# debugId=C12EF127A8F53A8064756E2164756E21