opencode-usage 0.4.5 → 0.4.6
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 +918 -278
- package/dist/index.js.map +11 -11
- package/dist/quota-loader.d.ts +0 -4
- package/package.json +1 -1
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-
|
|
651
|
+
// node_modules/@opentui/core/index-vnvba6q9.js
|
|
652
652
|
function wrapAssembly(lib) {
|
|
653
653
|
function patch(prototype, name, fn) {
|
|
654
654
|
const original = prototype[name];
|
|
@@ -1420,8 +1420,23 @@ function extractCompleteSequences(buffer) {
|
|
|
1420
1420
|
return { sequences, remainder: remaining };
|
|
1421
1421
|
}
|
|
1422
1422
|
} else {
|
|
1423
|
-
|
|
1424
|
-
|
|
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
|
+
}
|
|
1425
1440
|
}
|
|
1426
1441
|
}
|
|
1427
1442
|
return { sequences, remainder: "" };
|
|
@@ -1866,7 +1881,7 @@ var highlights_default5 = "./highlights-hk7bwhj4.scm";
|
|
|
1866
1881
|
// node_modules/@opentui/core/assets/zig/tree-sitter-zig.wasm
|
|
1867
1882
|
var tree_sitter_zig_default = "./tree-sitter-zig-e78zbjpm.wasm";
|
|
1868
1883
|
|
|
1869
|
-
// node_modules/@opentui/core/index-
|
|
1884
|
+
// node_modules/@opentui/core/index-vnvba6q9.js
|
|
1870
1885
|
function getParsers() {
|
|
1871
1886
|
if (!_cachedParsers) {
|
|
1872
1887
|
_cachedParsers = [
|
|
@@ -2628,6 +2643,18 @@ function defineStruct(fields, structDefOptions) {
|
|
|
2628
2643
|
};
|
|
2629
2644
|
}
|
|
2630
2645
|
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
|
+
}
|
|
2631
2658
|
function getOpenTUILib(libPath) {
|
|
2632
2659
|
const resolvedLibPath = libPath || targetLibPath;
|
|
2633
2660
|
const rawSymbols = dlopen(resolvedLibPath, {
|
|
@@ -2787,10 +2814,6 @@ function getOpenTUILib(libPath) {
|
|
|
2787
2814
|
args: ["ptr", "i32", "i32", "bool"],
|
|
2788
2815
|
returns: "void"
|
|
2789
2816
|
},
|
|
2790
|
-
setCursorStyle: {
|
|
2791
|
-
args: ["ptr", "ptr", "u32", "bool"],
|
|
2792
|
-
returns: "void"
|
|
2793
|
-
},
|
|
2794
2817
|
setCursorColor: {
|
|
2795
2818
|
args: ["ptr", "ptr"],
|
|
2796
2819
|
returns: "void"
|
|
@@ -2799,6 +2822,10 @@ function getOpenTUILib(libPath) {
|
|
|
2799
2822
|
args: ["ptr", "ptr"],
|
|
2800
2823
|
returns: "void"
|
|
2801
2824
|
},
|
|
2825
|
+
setCursorStyleOptions: {
|
|
2826
|
+
args: ["ptr", "ptr"],
|
|
2827
|
+
returns: "void"
|
|
2828
|
+
},
|
|
2802
2829
|
setDebugOverlay: {
|
|
2803
2830
|
args: ["ptr", "bool", "u8"],
|
|
2804
2831
|
returns: "void"
|
|
@@ -3526,6 +3553,54 @@ function getOpenTUILib(libPath) {
|
|
|
3526
3553
|
bufferDrawChar: {
|
|
3527
3554
|
args: ["ptr", "u32", "u32", "u32", "ptr", "ptr", "u32"],
|
|
3528
3555
|
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"
|
|
3529
3604
|
}
|
|
3530
3605
|
});
|
|
3531
3606
|
if (env.OTUI_DEBUG_FFI || env.OTUI_TRACE_FFI) {
|
|
@@ -9276,95 +9351,168 @@ class MouseParser {
|
|
|
9276
9351
|
reset() {
|
|
9277
9352
|
this.mouseButtonsPressed.clear();
|
|
9278
9353
|
}
|
|
9354
|
+
decodeInput(data) {
|
|
9355
|
+
return data.toString();
|
|
9356
|
+
}
|
|
9279
9357
|
parseMouseEvent(data) {
|
|
9280
|
-
const str =
|
|
9281
|
-
const
|
|
9282
|
-
|
|
9283
|
-
|
|
9284
|
-
|
|
9285
|
-
|
|
9286
|
-
|
|
9287
|
-
|
|
9288
|
-
|
|
9289
|
-
const
|
|
9290
|
-
|
|
9291
|
-
|
|
9292
|
-
|
|
9293
|
-
|
|
9294
|
-
|
|
9295
|
-
|
|
9296
|
-
|
|
9297
|
-
|
|
9298
|
-
|
|
9299
|
-
|
|
9300
|
-
|
|
9301
|
-
|
|
9302
|
-
|
|
9303
|
-
|
|
9304
|
-
|
|
9305
|
-
|
|
9306
|
-
|
|
9307
|
-
|
|
9308
|
-
|
|
9309
|
-
|
|
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;
|
|
9310
9410
|
}
|
|
9311
|
-
|
|
9312
|
-
|
|
9313
|
-
|
|
9314
|
-
|
|
9315
|
-
|
|
9316
|
-
|
|
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
|
+
};
|
|
9317
9419
|
}
|
|
9420
|
+
default:
|
|
9421
|
+
return null;
|
|
9318
9422
|
}
|
|
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
|
-
};
|
|
9327
9423
|
}
|
|
9328
|
-
|
|
9329
|
-
|
|
9330
|
-
|
|
9331
|
-
|
|
9332
|
-
|
|
9333
|
-
|
|
9334
|
-
|
|
9335
|
-
|
|
9336
|
-
|
|
9337
|
-
|
|
9338
|
-
|
|
9339
|
-
|
|
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
|
|
9340
9454
|
};
|
|
9341
|
-
|
|
9342
|
-
|
|
9343
|
-
|
|
9344
|
-
if (isScroll) {
|
|
9345
|
-
type = "scroll";
|
|
9346
|
-
actualButton = 0;
|
|
9347
|
-
scrollInfo = {
|
|
9348
|
-
direction: scrollDirection,
|
|
9349
|
-
delta: 1
|
|
9350
|
-
};
|
|
9351
|
-
} else if (isMotion) {
|
|
9455
|
+
} else if (isMotion) {
|
|
9456
|
+
const isDragging = this.mouseButtonsPressed.size > 0;
|
|
9457
|
+
if (button === 3) {
|
|
9352
9458
|
type = "move";
|
|
9353
|
-
|
|
9459
|
+
} else if (isDragging) {
|
|
9460
|
+
type = "drag";
|
|
9354
9461
|
} else {
|
|
9355
|
-
type =
|
|
9356
|
-
actualButton = button === 3 ? 0 : button;
|
|
9462
|
+
type = "move";
|
|
9357
9463
|
}
|
|
9358
|
-
|
|
9359
|
-
|
|
9360
|
-
|
|
9361
|
-
|
|
9362
|
-
|
|
9363
|
-
|
|
9364
|
-
|
|
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
|
|
9365
9500
|
};
|
|
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;
|
|
9366
9507
|
}
|
|
9367
|
-
return
|
|
9508
|
+
return {
|
|
9509
|
+
type,
|
|
9510
|
+
button: actualButton,
|
|
9511
|
+
x,
|
|
9512
|
+
y,
|
|
9513
|
+
modifiers,
|
|
9514
|
+
scroll: scrollInfo
|
|
9515
|
+
};
|
|
9368
9516
|
}
|
|
9369
9517
|
}
|
|
9370
9518
|
|
|
@@ -11556,6 +11704,59 @@ var CursorStateStruct = defineStruct([
|
|
|
11556
11704
|
["b", "f32"],
|
|
11557
11705
|
["a", "f32"]
|
|
11558
11706
|
]);
|
|
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
|
+
});
|
|
11559
11760
|
var module = await import(`@opentui/core-${process.platform}-${process.arch}/index.ts`);
|
|
11560
11761
|
var targetLibPath = module.default;
|
|
11561
11762
|
if (isBunfsPath(targetLibPath)) {
|
|
@@ -11600,6 +11801,9 @@ registerEnvVar({
|
|
|
11600
11801
|
type: "boolean",
|
|
11601
11802
|
default: false
|
|
11602
11803
|
});
|
|
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 };
|
|
11603
11807
|
var globalTraceSymbols = null;
|
|
11604
11808
|
var globalFFILogWriter = null;
|
|
11605
11809
|
var exitHandlerRegistered = false;
|
|
@@ -11619,6 +11823,8 @@ class FFIRenderLib {
|
|
|
11619
11823
|
eventCallbackWrapper;
|
|
11620
11824
|
_nativeEvents = new EventEmitter5;
|
|
11621
11825
|
_anyEventHandlers = [];
|
|
11826
|
+
nativeSpanFeedCallbackWrapper = null;
|
|
11827
|
+
nativeSpanFeedHandlers = new Map;
|
|
11622
11828
|
constructor(libPath) {
|
|
11623
11829
|
this.opentui = getOpenTUILib(libPath);
|
|
11624
11830
|
this.setupLogging();
|
|
@@ -11708,6 +11914,25 @@ class FFIRenderLib {
|
|
|
11708
11914
|
}
|
|
11709
11915
|
this.setEventCallback(eventCallback.ptr);
|
|
11710
11916
|
}
|
|
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
|
+
}
|
|
11711
11936
|
setEventCallback(callbackPtr) {
|
|
11712
11937
|
this.opentui.symbols.setEventCallback(callbackPtr);
|
|
11713
11938
|
}
|
|
@@ -11875,10 +12100,6 @@ class FFIRenderLib {
|
|
|
11875
12100
|
setCursorPosition(renderer, x, y, visible) {
|
|
11876
12101
|
this.opentui.symbols.setCursorPosition(renderer, x, y, visible);
|
|
11877
12102
|
}
|
|
11878
|
-
setCursorStyle(renderer, style, blinking) {
|
|
11879
|
-
const stylePtr = this.encoder.encode(style);
|
|
11880
|
-
this.opentui.symbols.setCursorStyle(renderer, stylePtr, style.length, blinking);
|
|
11881
|
-
}
|
|
11882
12103
|
setCursorColor(renderer, color) {
|
|
11883
12104
|
this.opentui.symbols.setCursorColor(renderer, color.buffer);
|
|
11884
12105
|
}
|
|
@@ -11886,20 +12107,22 @@ class FFIRenderLib {
|
|
|
11886
12107
|
const cursorBuffer = new ArrayBuffer(CursorStateStruct.size);
|
|
11887
12108
|
this.opentui.symbols.getCursorState(renderer, ptr4(cursorBuffer));
|
|
11888
12109
|
const struct = CursorStateStruct.unpack(cursorBuffer);
|
|
11889
|
-
const styleMap = {
|
|
11890
|
-
0: "block",
|
|
11891
|
-
1: "line",
|
|
11892
|
-
2: "underline"
|
|
11893
|
-
};
|
|
11894
12110
|
return {
|
|
11895
12111
|
x: struct.x,
|
|
11896
12112
|
y: struct.y,
|
|
11897
12113
|
visible: struct.visible,
|
|
11898
|
-
style:
|
|
12114
|
+
style: CURSOR_ID_TO_STYLE[struct.style] ?? "block",
|
|
11899
12115
|
blinking: struct.blinking,
|
|
11900
12116
|
color: RGBA.fromValues(struct.r, struct.g, struct.b, struct.a)
|
|
11901
12117
|
};
|
|
11902
12118
|
}
|
|
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
|
+
}
|
|
11903
12126
|
render(renderer, force) {
|
|
11904
12127
|
this.opentui.symbols.render(renderer, force);
|
|
11905
12128
|
}
|
|
@@ -12739,6 +12962,73 @@ class FFIRenderLib {
|
|
|
12739
12962
|
bufferDrawChar(buffer, char, x, y, fg2, bg2, attributes = 0) {
|
|
12740
12963
|
this.opentui.symbols.bufferDrawChar(buffer, char, x, y, fg2.buffer, bg2.buffer, attributes);
|
|
12741
12964
|
}
|
|
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
|
+
}
|
|
12742
13032
|
createSyntaxStyle() {
|
|
12743
13033
|
const stylePtr = this.opentui.symbols.createSyntaxStyle();
|
|
12744
13034
|
if (!stylePtr) {
|
|
@@ -15489,6 +15779,7 @@ class CliRenderer extends EventEmitter9 {
|
|
|
15489
15779
|
_latestPointer = { x: 0, y: 0 };
|
|
15490
15780
|
_hasPointer = false;
|
|
15491
15781
|
_lastPointerModifiers = { shift: false, alt: false, ctrl: false };
|
|
15782
|
+
_currentMousePointerStyle = undefined;
|
|
15492
15783
|
_currentFocusedRenderable = null;
|
|
15493
15784
|
lifecyclePasses = new Set;
|
|
15494
15785
|
_openConsoleOnError = true;
|
|
@@ -16073,127 +16364,135 @@ Captured output:
|
|
|
16073
16364
|
return event;
|
|
16074
16365
|
}
|
|
16075
16366
|
handleMouseData(data) {
|
|
16076
|
-
const
|
|
16077
|
-
if (
|
|
16078
|
-
|
|
16079
|
-
|
|
16080
|
-
|
|
16081
|
-
|
|
16082
|
-
|
|
16083
|
-
}
|
|
16084
|
-
this._latestPointer.x = mouseEvent.x;
|
|
16085
|
-
this._latestPointer.y = mouseEvent.y;
|
|
16086
|
-
this._hasPointer = true;
|
|
16087
|
-
this._lastPointerModifiers = mouseEvent.modifiers;
|
|
16088
|
-
if (this._console.visible) {
|
|
16089
|
-
const consoleBounds = this._console.bounds;
|
|
16090
|
-
if (mouseEvent.x >= consoleBounds.x && mouseEvent.x < consoleBounds.x + consoleBounds.width && mouseEvent.y >= consoleBounds.y && mouseEvent.y < consoleBounds.y + consoleBounds.height) {
|
|
16091
|
-
const event2 = new MouseEvent(null, mouseEvent);
|
|
16092
|
-
const handled = this._console.handleMouse(event2);
|
|
16093
|
-
if (handled)
|
|
16094
|
-
return true;
|
|
16095
|
-
}
|
|
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;
|
|
16096
16374
|
}
|
|
16097
|
-
|
|
16098
|
-
|
|
16099
|
-
|
|
16100
|
-
|
|
16101
|
-
|
|
16102
|
-
|
|
16103
|
-
|
|
16104
|
-
scrollTarget.processMouseEvent(event2);
|
|
16105
|
-
}
|
|
16106
|
-
return true;
|
|
16375
|
+
}
|
|
16376
|
+
return anyHandled;
|
|
16377
|
+
}
|
|
16378
|
+
processSingleMouseEvent(mouseEvent) {
|
|
16379
|
+
if (this._splitHeight > 0) {
|
|
16380
|
+
if (mouseEvent.y < this.renderOffset) {
|
|
16381
|
+
return false;
|
|
16107
16382
|
}
|
|
16108
|
-
|
|
16109
|
-
|
|
16110
|
-
|
|
16111
|
-
|
|
16112
|
-
|
|
16113
|
-
|
|
16114
|
-
|
|
16115
|
-
|
|
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)
|
|
16116
16395
|
return true;
|
|
16117
|
-
}
|
|
16118
16396
|
}
|
|
16119
|
-
|
|
16120
|
-
|
|
16121
|
-
|
|
16122
|
-
|
|
16123
|
-
|
|
16124
|
-
|
|
16125
|
-
|
|
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);
|
|
16126
16406
|
}
|
|
16127
|
-
|
|
16128
|
-
|
|
16129
|
-
|
|
16130
|
-
|
|
16131
|
-
|
|
16132
|
-
|
|
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);
|
|
16133
16417
|
return true;
|
|
16134
16418
|
}
|
|
16135
|
-
|
|
16136
|
-
|
|
16137
|
-
|
|
16138
|
-
|
|
16139
|
-
|
|
16140
|
-
|
|
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);
|
|
16141
16425
|
}
|
|
16142
|
-
|
|
16143
|
-
|
|
16144
|
-
|
|
16145
|
-
|
|
16146
|
-
}
|
|
16147
|
-
|
|
16148
|
-
if (maybeRenderable) {
|
|
16149
|
-
const event2 = new MouseEvent(maybeRenderable, {
|
|
16150
|
-
...mouseEvent,
|
|
16151
|
-
type: "over",
|
|
16152
|
-
source: this.capturedRenderable
|
|
16153
|
-
});
|
|
16154
|
-
maybeRenderable.processMouseEvent(event2);
|
|
16155
|
-
}
|
|
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);
|
|
16156
16432
|
}
|
|
16157
|
-
|
|
16158
|
-
|
|
16159
|
-
|
|
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);
|
|
16160
16440
|
return true;
|
|
16161
16441
|
}
|
|
16162
|
-
|
|
16163
|
-
|
|
16164
|
-
|
|
16165
|
-
|
|
16166
|
-
|
|
16167
|
-
const event3 = new MouseEvent(maybeRenderable, {
|
|
16168
|
-
...mouseEvent,
|
|
16169
|
-
type: "drop",
|
|
16170
|
-
source: this.capturedRenderable
|
|
16171
|
-
});
|
|
16172
|
-
maybeRenderable.processMouseEvent(event3);
|
|
16173
|
-
}
|
|
16174
|
-
this.lastOverRenderable = this.capturedRenderable;
|
|
16175
|
-
this.lastOverRenderableNum = this.capturedRenderable.num;
|
|
16176
|
-
this.setCapturedRenderable(undefined);
|
|
16177
|
-
this.requestRender();
|
|
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);
|
|
16178
16447
|
}
|
|
16179
|
-
|
|
16448
|
+
this.lastOverRenderable = maybeRenderable;
|
|
16180
16449
|
if (maybeRenderable) {
|
|
16181
|
-
|
|
16182
|
-
|
|
16183
|
-
|
|
16184
|
-
this.
|
|
16185
|
-
}
|
|
16186
|
-
|
|
16450
|
+
const event2 = new MouseEvent(maybeRenderable, {
|
|
16451
|
+
...mouseEvent,
|
|
16452
|
+
type: "over",
|
|
16453
|
+
source: this.capturedRenderable
|
|
16454
|
+
});
|
|
16455
|
+
maybeRenderable.processMouseEvent(event2);
|
|
16456
|
+
}
|
|
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));
|
|
16467
|
+
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);
|
|
16187
16484
|
} else {
|
|
16188
16485
|
this.setCapturedRenderable(undefined);
|
|
16189
|
-
this.lastOverRenderable = undefined;
|
|
16190
|
-
}
|
|
16191
|
-
if (!event?.defaultPrevented && mouseEvent.type === "down" && this.currentSelection) {
|
|
16192
|
-
this.clearSelection();
|
|
16193
16486
|
}
|
|
16194
|
-
|
|
16487
|
+
event = this.dispatchMouseEvent(maybeRenderable, mouseEvent);
|
|
16488
|
+
} else {
|
|
16489
|
+
this.setCapturedRenderable(undefined);
|
|
16490
|
+
this.lastOverRenderable = undefined;
|
|
16195
16491
|
}
|
|
16196
|
-
|
|
16492
|
+
if (!event?.defaultPrevented && mouseEvent.type === "down" && this.currentSelection) {
|
|
16493
|
+
this.clearSelection();
|
|
16494
|
+
}
|
|
16495
|
+
return true;
|
|
16197
16496
|
}
|
|
16198
16497
|
recheckHoverState() {
|
|
16199
16498
|
if (this._isDestroyed || !this._hasPointer)
|
|
@@ -16228,6 +16527,10 @@ Captured output:
|
|
|
16228
16527
|
hitRenderable.processMouseEvent(event);
|
|
16229
16528
|
}
|
|
16230
16529
|
}
|
|
16530
|
+
setMousePointer(style) {
|
|
16531
|
+
this._currentMousePointerStyle = style;
|
|
16532
|
+
this.lib.setCursorStyleOptions(this.rendererPtr, { cursor: style });
|
|
16533
|
+
}
|
|
16231
16534
|
hitTest(x, y) {
|
|
16232
16535
|
return this.lib.checkHit(this.rendererPtr, x, y);
|
|
16233
16536
|
}
|
|
@@ -16370,11 +16673,11 @@ Captured output:
|
|
|
16370
16673
|
const lib = resolveRenderLib();
|
|
16371
16674
|
lib.setCursorPosition(renderer.rendererPtr, x, y, visible);
|
|
16372
16675
|
}
|
|
16373
|
-
static setCursorStyle(renderer,
|
|
16676
|
+
static setCursorStyle(renderer, options) {
|
|
16374
16677
|
const lib = resolveRenderLib();
|
|
16375
|
-
lib.
|
|
16376
|
-
if (
|
|
16377
|
-
|
|
16678
|
+
lib.setCursorStyleOptions(renderer.rendererPtr, options);
|
|
16679
|
+
if (options.cursor !== undefined) {
|
|
16680
|
+
renderer._currentMousePointerStyle = options.cursor;
|
|
16378
16681
|
}
|
|
16379
16682
|
}
|
|
16380
16683
|
static setCursorColor(renderer, color) {
|
|
@@ -16384,10 +16687,10 @@ Captured output:
|
|
|
16384
16687
|
setCursorPosition(x, y, visible = true) {
|
|
16385
16688
|
this.lib.setCursorPosition(this.rendererPtr, x, y, visible);
|
|
16386
16689
|
}
|
|
16387
|
-
setCursorStyle(
|
|
16388
|
-
this.lib.
|
|
16389
|
-
if (
|
|
16390
|
-
this.
|
|
16690
|
+
setCursorStyle(options) {
|
|
16691
|
+
this.lib.setCursorStyleOptions(this.rendererPtr, options);
|
|
16692
|
+
if (options.cursor !== undefined) {
|
|
16693
|
+
this._currentMousePointerStyle = options.cursor;
|
|
16391
16694
|
}
|
|
16392
16695
|
}
|
|
16393
16696
|
setCursorColor(color) {
|
|
@@ -16893,6 +17196,19 @@ function convertThemeToStyles(theme) {
|
|
|
16893
17196
|
}
|
|
16894
17197
|
return flatStyles;
|
|
16895
17198
|
}
|
|
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
|
+
}
|
|
16896
17212
|
function isGapType(value) {
|
|
16897
17213
|
if (value === undefined) {
|
|
16898
17214
|
return true;
|
|
@@ -18248,6 +18564,252 @@ class TimelineEngine {
|
|
|
18248
18564
|
}
|
|
18249
18565
|
var engine = new TimelineEngine;
|
|
18250
18566
|
|
|
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
|
+
|
|
18251
18813
|
class FrameBufferRenderable extends Renderable {
|
|
18252
18814
|
frameBuffer;
|
|
18253
18815
|
respectAlpha;
|
|
@@ -19935,6 +20497,23 @@ class LineNumberRenderable extends Renderable {
|
|
|
19935
20497
|
getLineNumbers() {
|
|
19936
20498
|
return this._lineNumbers;
|
|
19937
20499
|
}
|
|
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
|
+
}
|
|
19938
20517
|
}
|
|
19939
20518
|
|
|
19940
20519
|
class Diff {
|
|
@@ -21328,6 +21907,30 @@ class DiffRenderable extends Renderable {
|
|
|
21328
21907
|
}
|
|
21329
21908
|
}
|
|
21330
21909
|
}
|
|
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
|
+
}
|
|
21331
21934
|
}
|
|
21332
21935
|
|
|
21333
21936
|
class EditBufferRenderable extends Renderable {
|
|
@@ -21759,13 +22362,11 @@ class EditBufferRenderable extends Renderable {
|
|
|
21759
22362
|
const cursorX = this.x + visualCursor.visualCol + 1;
|
|
21760
22363
|
const cursorY = this.y + visualCursor.visualRow + 1;
|
|
21761
22364
|
this._ctx.setCursorPosition(cursorX, cursorY, true);
|
|
21762
|
-
this._ctx.
|
|
21763
|
-
this._ctx.setCursorStyle(this._cursorStyle.style, this._cursorStyle.blinking);
|
|
22365
|
+
this._ctx.setCursorStyle({ ...this._cursorStyle, color: this._cursorColor });
|
|
21764
22366
|
}
|
|
21765
22367
|
focus() {
|
|
21766
22368
|
super.focus();
|
|
21767
|
-
this._ctx.setCursorStyle(this._cursorStyle
|
|
21768
|
-
this._ctx.setCursorColor(this._cursorColor);
|
|
22369
|
+
this._ctx.setCursorStyle({ ...this._cursorStyle, color: this._cursorColor });
|
|
21769
22370
|
this.requestRender();
|
|
21770
22371
|
}
|
|
21771
22372
|
blur() {
|
|
@@ -23786,7 +24387,8 @@ class MarkdownRenderable extends Renderable {
|
|
|
23786
24387
|
constructor(ctx, options) {
|
|
23787
24388
|
super(ctx, {
|
|
23788
24389
|
...options,
|
|
23789
|
-
flexDirection: "column"
|
|
24390
|
+
flexDirection: "column",
|
|
24391
|
+
flexShrink: options.flexShrink ?? 0
|
|
23790
24392
|
});
|
|
23791
24393
|
this._syntaxStyle = options.syntaxStyle;
|
|
23792
24394
|
this._conceal = options.conceal ?? this._contentDefaultOptions.conceal;
|
|
@@ -23830,8 +24432,7 @@ class MarkdownRenderable extends Renderable {
|
|
|
23830
24432
|
set streaming(value) {
|
|
23831
24433
|
if (this._streaming !== value) {
|
|
23832
24434
|
this._streaming = value;
|
|
23833
|
-
this.
|
|
23834
|
-
this.requestRender();
|
|
24435
|
+
this.clearCache();
|
|
23835
24436
|
}
|
|
23836
24437
|
}
|
|
23837
24438
|
getStyle(group) {
|
|
@@ -27610,6 +28211,10 @@ function _getParentNode(childNode) {
|
|
|
27610
28211
|
if (parent instanceof RootTextNodeRenderable) {
|
|
27611
28212
|
parent = parent.textParent ?? undefined;
|
|
27612
28213
|
}
|
|
28214
|
+
const scrollBoxCandidate = parent?.parent?.parent?.parent;
|
|
28215
|
+
if (scrollBoxCandidate instanceof ScrollBoxRenderable && scrollBoxCandidate.content === parent) {
|
|
28216
|
+
parent = scrollBoxCandidate;
|
|
28217
|
+
}
|
|
27613
28218
|
return parent;
|
|
27614
28219
|
}
|
|
27615
28220
|
function getComponentCatalogue() {
|
|
@@ -28110,9 +28715,19 @@ async function readJsonFile(filePath) {
|
|
|
28110
28715
|
return null;
|
|
28111
28716
|
}
|
|
28112
28717
|
}
|
|
28718
|
+
async function readJsonFileFromPaths(filePaths) {
|
|
28719
|
+
for (const filePath of filePaths) {
|
|
28720
|
+
const data = await readJsonFile(filePath);
|
|
28721
|
+
if (data !== null)
|
|
28722
|
+
return data;
|
|
28723
|
+
}
|
|
28724
|
+
return null;
|
|
28725
|
+
}
|
|
28113
28726
|
async function loadMultiAccountQuota() {
|
|
28114
|
-
const
|
|
28115
|
-
|
|
28727
|
+
const state = await readJsonFileFromPaths([
|
|
28728
|
+
ANTHROPIC_MULTI_ACCOUNT_STATE_PATH,
|
|
28729
|
+
ANTHROPIC_MULTI_ACCOUNT_STATE_LEGACY_PATH
|
|
28730
|
+
]);
|
|
28116
28731
|
if (!state?.usage) {
|
|
28117
28732
|
return [
|
|
28118
28733
|
{
|
|
@@ -28183,8 +28798,10 @@ function normalizeThresholds(value) {
|
|
|
28183
28798
|
};
|
|
28184
28799
|
}
|
|
28185
28800
|
async function loadMultiAccountThresholds() {
|
|
28186
|
-
const
|
|
28187
|
-
|
|
28801
|
+
const state = await readJsonFileFromPaths([
|
|
28802
|
+
ANTHROPIC_MULTI_ACCOUNT_STATE_PATH,
|
|
28803
|
+
ANTHROPIC_MULTI_ACCOUNT_STATE_LEGACY_PATH
|
|
28804
|
+
]);
|
|
28188
28805
|
if (!state)
|
|
28189
28806
|
return null;
|
|
28190
28807
|
return normalizeThresholds(state.config?.threshold);
|
|
@@ -28245,6 +28862,8 @@ async function loadAntigravityQuota() {
|
|
|
28245
28862
|
];
|
|
28246
28863
|
}
|
|
28247
28864
|
var isBun = typeof globalThis.Bun !== "undefined";
|
|
28865
|
+
var ANTHROPIC_MULTI_ACCOUNT_STATE_PATH = join3(homedir2(), ".config/opencode/anthropic-multi-account-state.json");
|
|
28866
|
+
var ANTHROPIC_MULTI_ACCOUNT_STATE_LEGACY_PATH = join3(homedir2(), ".local/share/opencode/multi-account-state.json");
|
|
28248
28867
|
|
|
28249
28868
|
// src/codex-client.ts
|
|
28250
28869
|
import { readFile as readFile2 } from "fs/promises";
|
|
@@ -28255,11 +28874,18 @@ function getCodexMultiAuthStorePaths() {
|
|
|
28255
28874
|
if (explicitFile)
|
|
28256
28875
|
return [explicitFile];
|
|
28257
28876
|
const explicitDir = process.env[CODEX_MULTI_AUTH_STORE_DIR_ENV]?.trim();
|
|
28258
|
-
if (explicitDir)
|
|
28259
|
-
return [
|
|
28877
|
+
if (explicitDir) {
|
|
28878
|
+
return [
|
|
28879
|
+
join4(explicitDir, "codex-multi-account-accounts.json"),
|
|
28880
|
+
join4(explicitDir, "codex-multi-accounts.json"),
|
|
28881
|
+
join4(explicitDir, "accounts.json")
|
|
28882
|
+
];
|
|
28883
|
+
}
|
|
28260
28884
|
return [
|
|
28261
|
-
|
|
28262
|
-
CODEX_MULTI_AUTH_LEGACY_STORE_PATH
|
|
28885
|
+
CODEX_MULTI_AUTH_STORE_PATH,
|
|
28886
|
+
CODEX_MULTI_AUTH_LEGACY_STORE_PATH,
|
|
28887
|
+
CODEX_MULTI_AUTH_OLDER_STORE_PATH,
|
|
28888
|
+
CODEX_MULTI_AUTH_OLDEST_STORE_PATH
|
|
28263
28889
|
];
|
|
28264
28890
|
}
|
|
28265
28891
|
function windowToUsed(window) {
|
|
@@ -28447,8 +29073,10 @@ async function loadCodexQuota(token) {
|
|
|
28447
29073
|
var isBun2 = typeof globalThis.Bun !== "undefined";
|
|
28448
29074
|
var CODEX_API_URL = "https://chatgpt.com/backend-api/wham/usage";
|
|
28449
29075
|
var CODEX_AUTH_PATH = join4(homedir3(), ".codex", "auth.json");
|
|
28450
|
-
var
|
|
28451
|
-
var CODEX_MULTI_AUTH_LEGACY_STORE_PATH = join4(homedir3(), ".config", "opencode
|
|
29076
|
+
var CODEX_MULTI_AUTH_STORE_PATH = join4(homedir3(), ".config", "opencode", "codex-multi-account-accounts.json");
|
|
29077
|
+
var CODEX_MULTI_AUTH_LEGACY_STORE_PATH = join4(homedir3(), ".config", "opencode", "codex-multi-accounts.json");
|
|
29078
|
+
var CODEX_MULTI_AUTH_OLDER_STORE_PATH = join4(homedir3(), ".config", "oc-codex-multi-account", "accounts.json");
|
|
29079
|
+
var CODEX_MULTI_AUTH_OLDEST_STORE_PATH = join4(homedir3(), ".config", "opencode-multi-auth", "accounts.json");
|
|
28452
29080
|
var CODEX_MULTI_AUTH_STORE_FILE_ENV = "OPENCODE_MULTI_AUTH_STORE_FILE";
|
|
28453
29081
|
var CODEX_MULTI_AUTH_STORE_DIR_ENV = "OPENCODE_MULTI_AUTH_STORE_DIR";
|
|
28454
29082
|
|
|
@@ -28698,7 +29326,7 @@ function UsageTable(props) {
|
|
|
28698
29326
|
insert(_el$11, () => padLeft2(formatNum(totalStats().tokens), 13));
|
|
28699
29327
|
insert(_el$12, () => padLeft2(formatCost2(totalStats().cost), 10));
|
|
28700
29328
|
effect((_p$) => {
|
|
28701
|
-
var _v$ = props.isSelected ? COLORS.accent.teal : COLORS.border, _v$2 = props.width ?? "
|
|
29329
|
+
var _v$ = props.isSelected ? COLORS.accent.teal : COLORS.border, _v$2 = props.width ?? "49%", _v$3 = COLORS.bg.secondary, _v$4 = COLORS.accent.teal, _v$5 = COLORS.border, _v$6 = COLORS.text.muted, _v$7 = COLORS.border, _v$8 = {
|
|
28702
29330
|
fg: COLORS.accent.teal,
|
|
28703
29331
|
bold: true
|
|
28704
29332
|
}, _v$9 = {
|
|
@@ -28753,7 +29381,7 @@ function QuotaPanel(props) {
|
|
|
28753
29381
|
const resetDate = new Date(resetAt * 1000);
|
|
28754
29382
|
const now = new Date;
|
|
28755
29383
|
if (resetDate <= now)
|
|
28756
|
-
return "\u27F3 resetting...";
|
|
29384
|
+
return compact ? "\u27F3 reset" : "\u27F3 resetting...";
|
|
28757
29385
|
const today = new Date(now.getFullYear(), now.getMonth(), now.getDate());
|
|
28758
29386
|
const tomorrow = new Date(today);
|
|
28759
29387
|
tomorrow.setDate(tomorrow.getDate() + 1);
|
|
@@ -28874,6 +29502,7 @@ function QuotaPanel(props) {
|
|
|
28874
29502
|
children: ([accountName, accountQuotas]) => {
|
|
28875
29503
|
const isActive = accountName.includes("[ACTIVE]");
|
|
28876
29504
|
const cleanName = accountName.replace(" [ACTIVE]", "").trim();
|
|
29505
|
+
const displayAccountName = props.twoColumns ? truncateText(cleanName, isActive ? 15 : 22) : cleanName;
|
|
28877
29506
|
return (() => {
|
|
28878
29507
|
var _el$52 = createElement("box"), _el$53 = createElement("box"), _el$54 = createElement("text");
|
|
28879
29508
|
insertNode(_el$52, _el$53);
|
|
@@ -28897,7 +29526,7 @@ function QuotaPanel(props) {
|
|
|
28897
29526
|
insert(_el$54, isActive ? [(() => {
|
|
28898
29527
|
var _el$55 = createElement("span"), _el$56 = createTextNode(`\u25CF `);
|
|
28899
29528
|
insertNode(_el$55, _el$56);
|
|
28900
|
-
insert(_el$55,
|
|
29529
|
+
insert(_el$55, displayAccountName, null);
|
|
28901
29530
|
effect((_$p) => setProp(_el$55, "style", {
|
|
28902
29531
|
fg: COLORS.accent.teal,
|
|
28903
29532
|
bold: true
|
|
@@ -28912,7 +29541,7 @@ function QuotaPanel(props) {
|
|
|
28912
29541
|
return _el$57;
|
|
28913
29542
|
})()] : (() => {
|
|
28914
29543
|
var _el$60 = createElement("span");
|
|
28915
|
-
insert(_el$60,
|
|
29544
|
+
insert(_el$60, displayAccountName);
|
|
28916
29545
|
effect((_$p) => setProp(_el$60, "style", {
|
|
28917
29546
|
fg: COLORS.text.primary,
|
|
28918
29547
|
bold: true
|
|
@@ -28925,22 +29554,24 @@ function QuotaPanel(props) {
|
|
|
28925
29554
|
const rawDisplayLabel = quota.label.replace(accountName, "").replace(/^[\s-]+/, "").trim();
|
|
28926
29555
|
const displayLabel = rawDisplayLabel || "Status";
|
|
28927
29556
|
const compact = Boolean(props.twoColumns);
|
|
28928
|
-
const labelWidth = compact ?
|
|
28929
|
-
const barWidth = compact ?
|
|
29557
|
+
const labelWidth = compact ? 10 : 15;
|
|
29558
|
+
const barWidth = compact ? 10 : 20;
|
|
29559
|
+
const displayLabelText = compact ? truncateText(displayLabel, labelWidth) : displayLabel;
|
|
29560
|
+
const resetText = formatResetTime(quota.resetAt, compact);
|
|
29561
|
+
const compactResetText = compact ? truncateText(resetText, 8) : resetText;
|
|
29562
|
+
const errorText = compact ? truncateText(`${displayLabel}: ${quota.error ?? "Error"}`, 28) : `${displayLabel}: ${quota.error}`;
|
|
28930
29563
|
return createComponent2(Show, {
|
|
28931
29564
|
get when() {
|
|
28932
29565
|
return !quota.error;
|
|
28933
29566
|
},
|
|
28934
29567
|
get fallback() {
|
|
28935
29568
|
return (() => {
|
|
28936
|
-
var _el$69 = createElement("box"), _el$70 = createElement("text"), _el$71 = createTextNode(`\u2717 `)
|
|
29569
|
+
var _el$69 = createElement("box"), _el$70 = createElement("text"), _el$71 = createTextNode(`\u2717 `);
|
|
28937
29570
|
insertNode(_el$69, _el$70);
|
|
28938
29571
|
setProp(_el$69, "paddingLeft", 1);
|
|
28939
29572
|
setProp(_el$69, "flexShrink", 0);
|
|
28940
29573
|
insertNode(_el$70, _el$71);
|
|
28941
|
-
|
|
28942
|
-
insert(_el$70, displayLabel, _el$72);
|
|
28943
|
-
insert(_el$70, () => quota.error, null);
|
|
29574
|
+
insert(_el$70, errorText, null);
|
|
28944
29575
|
effect((_$p) => setProp(_el$70, "fg", COLORS.accent.red, _$p));
|
|
28945
29576
|
return _el$69;
|
|
28946
29577
|
})();
|
|
@@ -28955,12 +29586,12 @@ function QuotaPanel(props) {
|
|
|
28955
29586
|
insertNode(_el$62, _el$65);
|
|
28956
29587
|
insertNode(_el$62, _el$67);
|
|
28957
29588
|
setProp(_el$62, "wrapMode", "none");
|
|
28958
|
-
insert(_el$63, () => padRight2(
|
|
29589
|
+
insert(_el$63, () => padRight2(displayLabelText, labelWidth));
|
|
28959
29590
|
insert(_el$64, () => renderBar(quota.used, barWidth));
|
|
28960
29591
|
insertNode(_el$65, _el$66);
|
|
28961
29592
|
insert(_el$65, () => padLeft2((quota.used * 100).toFixed(0) + "%", 4), null);
|
|
28962
29593
|
insertNode(_el$67, _el$68);
|
|
28963
|
-
insert(_el$67,
|
|
29594
|
+
insert(_el$67, compactResetText, null);
|
|
28964
29595
|
effect((_p$) => {
|
|
28965
29596
|
var _v$24 = {
|
|
28966
29597
|
fg: COLORS.text.secondary
|
|
@@ -28987,7 +29618,7 @@ function QuotaPanel(props) {
|
|
|
28987
29618
|
});
|
|
28988
29619
|
}
|
|
28989
29620
|
}), null);
|
|
28990
|
-
effect((_$p) => setProp(_el$52, "width", props.twoColumns ? "
|
|
29621
|
+
effect((_$p) => setProp(_el$52, "width", props.twoColumns ? "49%" : undefined, _$p));
|
|
28991
29622
|
return _el$52;
|
|
28992
29623
|
})();
|
|
28993
29624
|
}
|
|
@@ -29010,7 +29641,7 @@ function QuotaPanel(props) {
|
|
|
29010
29641
|
}
|
|
29011
29642
|
}), null);
|
|
29012
29643
|
effect((_p$) => {
|
|
29013
|
-
var _v$18 = props.isSelected ? COLORS.accent.teal : COLORS.border, _v$19 = props.width ?? "
|
|
29644
|
+
var _v$18 = props.isSelected ? COLORS.accent.teal : COLORS.border, _v$19 = props.width ?? "49%", _v$20 = COLORS.bg.secondary, _v$21 = COLORS.accent.teal;
|
|
29014
29645
|
_v$18 !== _p$.e && (_p$.e = setProp(_el$37, "borderColor", _v$18, _p$.e));
|
|
29015
29646
|
_v$19 !== _p$.t && (_p$.t = setProp(_el$37, "width", _v$19, _p$.t));
|
|
29016
29647
|
_v$20 !== _p$.a && (_p$.a = setProp(_el$37, "backgroundColor", _v$20, _p$.a));
|
|
@@ -29045,22 +29676,22 @@ function StatusBar(props) {
|
|
|
29045
29676
|
return days.toString();
|
|
29046
29677
|
};
|
|
29047
29678
|
return (() => {
|
|
29048
|
-
var _el$
|
|
29679
|
+
var _el$72 = createElement("box"), _el$73 = createElement("text"), _el$74 = createElement("span"), _el$75 = createTextNode(`\u27F3 `), _el$76 = createTextNode(` \u2502 DAYS: `), _el$78 = createElement("span"), _el$79 = createTextNode(` \u2502 `), _el$80 = createElement("span");
|
|
29680
|
+
insertNode(_el$72, _el$73);
|
|
29681
|
+
setProp(_el$72, "height", 1);
|
|
29682
|
+
setProp(_el$72, "border-top", true);
|
|
29683
|
+
setProp(_el$72, "padding-left", 1);
|
|
29684
|
+
setProp(_el$72, "padding-right", 1);
|
|
29049
29685
|
insertNode(_el$73, _el$74);
|
|
29050
|
-
|
|
29051
|
-
|
|
29052
|
-
|
|
29053
|
-
|
|
29686
|
+
insertNode(_el$73, _el$76);
|
|
29687
|
+
insertNode(_el$73, _el$78);
|
|
29688
|
+
insertNode(_el$73, _el$79);
|
|
29689
|
+
insertNode(_el$73, _el$80);
|
|
29690
|
+
setProp(_el$73, "wrapMode", "none");
|
|
29054
29691
|
insertNode(_el$74, _el$75);
|
|
29055
|
-
|
|
29056
|
-
|
|
29057
|
-
insertNode(_el$
|
|
29058
|
-
insertNode(_el$74, _el$81);
|
|
29059
|
-
setProp(_el$74, "wrapMode", "none");
|
|
29060
|
-
insertNode(_el$75, _el$76);
|
|
29061
|
-
insert(_el$75, () => formatTime(props.lastUpdate), null);
|
|
29062
|
-
insert(_el$79, daysLabel);
|
|
29063
|
-
insertNode(_el$81, createTextNode(`TAB:PANEL \u2191\u2193:SCROLL \u2190\u2192:DAYS t:TODAY w:WEEK m:MONTH a:ALL HOME:RESET ^C:EXIT`));
|
|
29692
|
+
insert(_el$74, () => formatTime(props.lastUpdate), null);
|
|
29693
|
+
insert(_el$78, daysLabel);
|
|
29694
|
+
insertNode(_el$80, createTextNode(`TAB:PANEL \u2191\u2193:SCROLL \u2190\u2192:DAYS t:TODAY w:WEEK m:MONTH a:ALL HOME:RESET ^C:EXIT`));
|
|
29064
29695
|
effect((_p$) => {
|
|
29065
29696
|
var _v$28 = COLORS.border, _v$29 = COLORS.bg.accent, _v$30 = COLORS.text.secondary, _v$31 = {
|
|
29066
29697
|
fg: COLORS.accent.teal
|
|
@@ -29069,12 +29700,12 @@ function StatusBar(props) {
|
|
|
29069
29700
|
}, _v$33 = {
|
|
29070
29701
|
fg: COLORS.text.muted
|
|
29071
29702
|
};
|
|
29072
|
-
_v$28 !== _p$.e && (_p$.e = setProp(_el$
|
|
29073
|
-
_v$29 !== _p$.t && (_p$.t = setProp(_el$
|
|
29074
|
-
_v$30 !== _p$.a && (_p$.a = setProp(_el$
|
|
29075
|
-
_v$31 !== _p$.o && (_p$.o = setProp(_el$
|
|
29076
|
-
_v$32 !== _p$.i && (_p$.i = setProp(_el$
|
|
29077
|
-
_v$33 !== _p$.n && (_p$.n = setProp(_el$
|
|
29703
|
+
_v$28 !== _p$.e && (_p$.e = setProp(_el$72, "border-color", _v$28, _p$.e));
|
|
29704
|
+
_v$29 !== _p$.t && (_p$.t = setProp(_el$72, "background-color", _v$29, _p$.t));
|
|
29705
|
+
_v$30 !== _p$.a && (_p$.a = setProp(_el$73, "fg", _v$30, _p$.a));
|
|
29706
|
+
_v$31 !== _p$.o && (_p$.o = setProp(_el$74, "style", _v$31, _p$.o));
|
|
29707
|
+
_v$32 !== _p$.i && (_p$.i = setProp(_el$78, "style", _v$32, _p$.i));
|
|
29708
|
+
_v$33 !== _p$.n && (_p$.n = setProp(_el$80, "style", _v$33, _p$.n));
|
|
29078
29709
|
return _p$;
|
|
29079
29710
|
}, {
|
|
29080
29711
|
e: undefined,
|
|
@@ -29084,7 +29715,7 @@ function StatusBar(props) {
|
|
|
29084
29715
|
i: undefined,
|
|
29085
29716
|
n: undefined
|
|
29086
29717
|
});
|
|
29087
|
-
return _el$
|
|
29718
|
+
return _el$72;
|
|
29088
29719
|
})();
|
|
29089
29720
|
}
|
|
29090
29721
|
function Dashboard(props) {
|
|
@@ -29250,15 +29881,15 @@ function Dashboard(props) {
|
|
|
29250
29881
|
const sideBySide = () => dimensions().width >= 168;
|
|
29251
29882
|
const quotaTwoColumns = () => dimensions().width >= 150;
|
|
29252
29883
|
return (() => {
|
|
29253
|
-
var _el$
|
|
29254
|
-
insertNode(_el$
|
|
29255
|
-
setProp(_el$
|
|
29256
|
-
setProp(_el$
|
|
29257
|
-
setProp(_el$
|
|
29258
|
-
setProp(_el$
|
|
29259
|
-
setProp(_el$
|
|
29260
|
-
setProp(_el$
|
|
29261
|
-
insert(_el$
|
|
29884
|
+
var _el$82 = createElement("box"), _el$83 = createElement("box");
|
|
29885
|
+
insertNode(_el$82, _el$83);
|
|
29886
|
+
setProp(_el$82, "width", "100%");
|
|
29887
|
+
setProp(_el$82, "height", "100%");
|
|
29888
|
+
setProp(_el$82, "flex-direction", "column");
|
|
29889
|
+
setProp(_el$83, "flex-grow", 1);
|
|
29890
|
+
setProp(_el$83, "gap", 0);
|
|
29891
|
+
setProp(_el$83, "padding", 0);
|
|
29892
|
+
insert(_el$83, createComponent2(UsageTable, {
|
|
29262
29893
|
get stats() {
|
|
29263
29894
|
return displayedStats();
|
|
29264
29895
|
},
|
|
@@ -29281,10 +29912,10 @@ function Dashboard(props) {
|
|
|
29281
29912
|
return selectedPanel() === "usage";
|
|
29282
29913
|
},
|
|
29283
29914
|
get width() {
|
|
29284
|
-
return sideBySide() ? "
|
|
29915
|
+
return sideBySide() ? "49%" : "100%";
|
|
29285
29916
|
}
|
|
29286
29917
|
}), null);
|
|
29287
|
-
insert(_el$
|
|
29918
|
+
insert(_el$83, createComponent2(QuotaPanel, {
|
|
29288
29919
|
get quotas() {
|
|
29289
29920
|
return quotas();
|
|
29290
29921
|
},
|
|
@@ -29292,7 +29923,7 @@ function Dashboard(props) {
|
|
|
29292
29923
|
return selectedPanel() === "quota";
|
|
29293
29924
|
},
|
|
29294
29925
|
get width() {
|
|
29295
|
-
return sideBySide() ? "
|
|
29926
|
+
return sideBySide() ? "49%" : "100%";
|
|
29296
29927
|
},
|
|
29297
29928
|
get twoColumns() {
|
|
29298
29929
|
return quotaTwoColumns();
|
|
@@ -29304,7 +29935,7 @@ function Dashboard(props) {
|
|
|
29304
29935
|
return codexThresholds();
|
|
29305
29936
|
}
|
|
29306
29937
|
}), null);
|
|
29307
|
-
insert(_el$
|
|
29938
|
+
insert(_el$82, createComponent2(StatusBar, {
|
|
29308
29939
|
get daysFilter() {
|
|
29309
29940
|
return daysFilter();
|
|
29310
29941
|
},
|
|
@@ -29314,14 +29945,14 @@ function Dashboard(props) {
|
|
|
29314
29945
|
}), null);
|
|
29315
29946
|
effect((_p$) => {
|
|
29316
29947
|
var _v$34 = COLORS.bg.primary, _v$35 = sideBySide() ? "row" : "column";
|
|
29317
|
-
_v$34 !== _p$.e && (_p$.e = setProp(_el$
|
|
29318
|
-
_v$35 !== _p$.t && (_p$.t = setProp(_el$
|
|
29948
|
+
_v$34 !== _p$.e && (_p$.e = setProp(_el$82, "background-color", _v$34, _p$.e));
|
|
29949
|
+
_v$35 !== _p$.t && (_p$.t = setProp(_el$83, "flex-direction", _v$35, _p$.t));
|
|
29319
29950
|
return _p$;
|
|
29320
29951
|
}, {
|
|
29321
29952
|
e: undefined,
|
|
29322
29953
|
t: undefined
|
|
29323
29954
|
});
|
|
29324
|
-
return _el$
|
|
29955
|
+
return _el$82;
|
|
29325
29956
|
})();
|
|
29326
29957
|
}
|
|
29327
29958
|
async function runSolidDashboard(options) {
|
|
@@ -29362,6 +29993,15 @@ var COLORS = {
|
|
|
29362
29993
|
};
|
|
29363
29994
|
var padLeft2 = (str, width) => str.padStart(width, " ");
|
|
29364
29995
|
var padRight2 = (str, width) => str.padEnd(width, " ");
|
|
29996
|
+
var truncateText = (str, width) => {
|
|
29997
|
+
if (width <= 0)
|
|
29998
|
+
return "";
|
|
29999
|
+
if (str.length <= width)
|
|
30000
|
+
return str;
|
|
30001
|
+
if (width <= 3)
|
|
30002
|
+
return str.slice(0, width);
|
|
30003
|
+
return `${str.slice(0, width - 3)}...`;
|
|
30004
|
+
};
|
|
29365
30005
|
|
|
29366
30006
|
// src/config-commands.ts
|
|
29367
30007
|
import { readFile as readFile3 } from "fs/promises";
|
|
@@ -29372,7 +30012,7 @@ import { join as join6 } from "path";
|
|
|
29372
30012
|
import { join as join5 } from "path";
|
|
29373
30013
|
function getConfigPath() {
|
|
29374
30014
|
const configDir = "/home/runner/.config";
|
|
29375
|
-
return join5(configDir, "opencode
|
|
30015
|
+
return join5(configDir, "opencode", "opencode-usage-config.json");
|
|
29376
30016
|
}
|
|
29377
30017
|
|
|
29378
30018
|
// src/config-commands.ts
|
|
@@ -29485,4 +30125,4 @@ async function main2() {
|
|
|
29485
30125
|
var WATCH_INTERVAL_MS = 5 * 60 * 1000;
|
|
29486
30126
|
main2().catch(console.error);
|
|
29487
30127
|
|
|
29488
|
-
//# debugId=
|
|
30128
|
+
//# debugId=97BCA2744D0BF01A64756E2164756E21
|