@opentui/core 0.1.28 → 0.1.29
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/3d.js +1 -1
- package/3d.js.map +1 -1
- package/README.md +10 -0
- package/Renderable.d.ts +25 -24
- package/buffer.d.ts +4 -7
- package/edit-buffer.d.ts +76 -0
- package/editor-view.d.ts +50 -0
- package/{index-phjxdb6g.js → index-bztetjc3.js} +1649 -323
- package/{index-phjxdb6g.js.map → index-bztetjc3.js.map} +18 -17
- package/index.d.ts +4 -0
- package/index.js +1334 -65
- package/index.js.map +12 -6
- package/lib/hast-styled-text.d.ts +2 -3
- package/lib/index.d.ts +0 -1
- package/lib/objects-in-viewport.d.ts +14 -0
- package/lib/tree-sitter/index.d.ts +0 -2
- package/lib/tree-sitter-styled-text.d.ts +1 -1
- package/lib/yoga.options.d.ts +6 -6
- package/package.json +8 -7
- package/renderables/Code.d.ts +1 -1
- package/renderables/EditBufferRenderable.d.ts +106 -0
- package/renderables/Text.d.ts +0 -3
- package/renderables/TextBufferRenderable.d.ts +8 -14
- package/renderables/Textarea.d.ts +66 -0
- package/renderables/index.d.ts +1 -0
- package/renderer.d.ts +6 -2
- package/{lib/syntax-style.d.ts → syntax-style.d.ts} +21 -5
- package/testing/mock-keys.d.ts +10 -2
- package/testing.js +14 -5
- package/testing.js.map +3 -3
- package/text-buffer-view.d.ts +31 -0
- package/text-buffer.d.ts +28 -21
- package/types.d.ts +10 -0
- package/zig-structs.d.ts +20 -0
- package/zig.d.ts +126 -23
- package/lib/word-jumps.d.ts +0 -2
|
@@ -2406,18 +2406,22 @@ function hexToRgb(hex) {
|
|
|
2406
2406
|
hex = hex.replace(/^#/, "");
|
|
2407
2407
|
if (hex.length === 3) {
|
|
2408
2408
|
hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2];
|
|
2409
|
+
} else if (hex.length === 4) {
|
|
2410
|
+
hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2] + hex[3] + hex[3];
|
|
2409
2411
|
}
|
|
2410
|
-
if (!/^[0-9A-Fa-f]{6}$/.test(hex)) {
|
|
2412
|
+
if (!/^[0-9A-Fa-f]{6}$/.test(hex) && !/^[0-9A-Fa-f]{8}$/.test(hex)) {
|
|
2411
2413
|
console.warn(`Invalid hex color: ${hex}, defaulting to magenta`);
|
|
2412
2414
|
return RGBA.fromValues(1, 0, 1, 1);
|
|
2413
2415
|
}
|
|
2414
2416
|
const r = parseInt(hex.substring(0, 2), 16) / 255;
|
|
2415
2417
|
const g = parseInt(hex.substring(2, 4), 16) / 255;
|
|
2416
2418
|
const b = parseInt(hex.substring(4, 6), 16) / 255;
|
|
2417
|
-
|
|
2419
|
+
const a = hex.length === 8 ? parseInt(hex.substring(6, 8), 16) / 255 : 1;
|
|
2420
|
+
return RGBA.fromValues(r, g, b, a);
|
|
2418
2421
|
}
|
|
2419
2422
|
function rgbToHex(rgb) {
|
|
2420
|
-
|
|
2423
|
+
const components = rgb.a === 1 ? [rgb.r, rgb.g, rgb.b] : [rgb.r, rgb.g, rgb.b, rgb.a];
|
|
2424
|
+
return "#" + components.map((x) => {
|
|
2421
2425
|
const hex = Math.floor(Math.max(0, Math.min(1, x) * 255)).toString(16);
|
|
2422
2426
|
return hex.length === 1 ? "0" + hex : hex;
|
|
2423
2427
|
}).join("");
|
|
@@ -4299,104 +4303,6 @@ function t(strings, ...values) {
|
|
|
4299
4303
|
return new StyledText(chunks);
|
|
4300
4304
|
}
|
|
4301
4305
|
|
|
4302
|
-
// src/lib/syntax-style.ts
|
|
4303
|
-
function convertThemeToStyles(theme) {
|
|
4304
|
-
const flatStyles = {};
|
|
4305
|
-
for (const tokenStyle of theme) {
|
|
4306
|
-
const styleDefinition = {};
|
|
4307
|
-
if (tokenStyle.style.foreground) {
|
|
4308
|
-
styleDefinition.fg = parseColor(tokenStyle.style.foreground);
|
|
4309
|
-
}
|
|
4310
|
-
if (tokenStyle.style.background) {
|
|
4311
|
-
styleDefinition.bg = parseColor(tokenStyle.style.background);
|
|
4312
|
-
}
|
|
4313
|
-
if (tokenStyle.style.bold !== undefined) {
|
|
4314
|
-
styleDefinition.bold = tokenStyle.style.bold;
|
|
4315
|
-
}
|
|
4316
|
-
if (tokenStyle.style.italic !== undefined) {
|
|
4317
|
-
styleDefinition.italic = tokenStyle.style.italic;
|
|
4318
|
-
}
|
|
4319
|
-
if (tokenStyle.style.underline !== undefined) {
|
|
4320
|
-
styleDefinition.underline = tokenStyle.style.underline;
|
|
4321
|
-
}
|
|
4322
|
-
if (tokenStyle.style.dim !== undefined) {
|
|
4323
|
-
styleDefinition.dim = tokenStyle.style.dim;
|
|
4324
|
-
}
|
|
4325
|
-
for (const scope of tokenStyle.scope) {
|
|
4326
|
-
flatStyles[scope] = styleDefinition;
|
|
4327
|
-
}
|
|
4328
|
-
}
|
|
4329
|
-
return flatStyles;
|
|
4330
|
-
}
|
|
4331
|
-
|
|
4332
|
-
class SyntaxStyle {
|
|
4333
|
-
styles;
|
|
4334
|
-
mergedStyleCache;
|
|
4335
|
-
constructor(styles) {
|
|
4336
|
-
this.styles = styles;
|
|
4337
|
-
this.mergedStyleCache = new Map;
|
|
4338
|
-
}
|
|
4339
|
-
static fromTheme(theme) {
|
|
4340
|
-
const flatStyles = convertThemeToStyles(theme);
|
|
4341
|
-
return new SyntaxStyle(flatStyles);
|
|
4342
|
-
}
|
|
4343
|
-
mergeStyles(...styleNames) {
|
|
4344
|
-
const cacheKey = styleNames.join(":");
|
|
4345
|
-
const cached = this.mergedStyleCache.get(cacheKey);
|
|
4346
|
-
if (cached)
|
|
4347
|
-
return cached;
|
|
4348
|
-
const styleDefinition = {};
|
|
4349
|
-
for (const name of styleNames) {
|
|
4350
|
-
const style = this.getStyle(name);
|
|
4351
|
-
if (!style)
|
|
4352
|
-
continue;
|
|
4353
|
-
if (style.fg)
|
|
4354
|
-
styleDefinition.fg = style.fg;
|
|
4355
|
-
if (style.bg)
|
|
4356
|
-
styleDefinition.bg = style.bg;
|
|
4357
|
-
if (style.bold !== undefined)
|
|
4358
|
-
styleDefinition.bold = style.bold;
|
|
4359
|
-
if (style.italic !== undefined)
|
|
4360
|
-
styleDefinition.italic = style.italic;
|
|
4361
|
-
if (style.underline !== undefined)
|
|
4362
|
-
styleDefinition.underline = style.underline;
|
|
4363
|
-
if (style.dim !== undefined)
|
|
4364
|
-
styleDefinition.dim = style.dim;
|
|
4365
|
-
}
|
|
4366
|
-
const attributes = createTextAttributes({
|
|
4367
|
-
bold: styleDefinition.bold,
|
|
4368
|
-
italic: styleDefinition.italic,
|
|
4369
|
-
underline: styleDefinition.underline,
|
|
4370
|
-
dim: styleDefinition.dim
|
|
4371
|
-
});
|
|
4372
|
-
const merged = {
|
|
4373
|
-
fg: styleDefinition.fg,
|
|
4374
|
-
bg: styleDefinition.bg,
|
|
4375
|
-
attributes
|
|
4376
|
-
};
|
|
4377
|
-
this.mergedStyleCache.set(cacheKey, merged);
|
|
4378
|
-
return merged;
|
|
4379
|
-
}
|
|
4380
|
-
getStyle(name) {
|
|
4381
|
-
if (Object.prototype.hasOwnProperty.call(this.styles, name)) {
|
|
4382
|
-
return this.styles[name];
|
|
4383
|
-
}
|
|
4384
|
-
if (name.includes(".")) {
|
|
4385
|
-
const baseName = name.split(".")[0];
|
|
4386
|
-
if (Object.prototype.hasOwnProperty.call(this.styles, baseName)) {
|
|
4387
|
-
return this.styles[baseName];
|
|
4388
|
-
}
|
|
4389
|
-
}
|
|
4390
|
-
return;
|
|
4391
|
-
}
|
|
4392
|
-
clearCache() {
|
|
4393
|
-
this.mergedStyleCache.clear();
|
|
4394
|
-
}
|
|
4395
|
-
getCacheSize() {
|
|
4396
|
-
return this.mergedStyleCache.size;
|
|
4397
|
-
}
|
|
4398
|
-
}
|
|
4399
|
-
|
|
4400
4306
|
// src/lib/hast-styled-text.ts
|
|
4401
4307
|
function hastToTextChunks(node, syntaxStyle, parentStyles = []) {
|
|
4402
4308
|
const chunks = [];
|
|
@@ -4480,6 +4386,9 @@ class MacOSScrollAccel {
|
|
|
4480
4386
|
|
|
4481
4387
|
// src/lib/yoga.options.ts
|
|
4482
4388
|
function parseAlign(value) {
|
|
4389
|
+
if (value == null) {
|
|
4390
|
+
return Align.Auto;
|
|
4391
|
+
}
|
|
4483
4392
|
switch (value.toLowerCase()) {
|
|
4484
4393
|
case "auto":
|
|
4485
4394
|
return Align.Auto;
|
|
@@ -4504,6 +4413,9 @@ function parseAlign(value) {
|
|
|
4504
4413
|
}
|
|
4505
4414
|
}
|
|
4506
4415
|
function parseBoxSizing(value) {
|
|
4416
|
+
if (value == null) {
|
|
4417
|
+
return BoxSizing.BorderBox;
|
|
4418
|
+
}
|
|
4507
4419
|
switch (value.toLowerCase()) {
|
|
4508
4420
|
case "border-box":
|
|
4509
4421
|
return BoxSizing.BorderBox;
|
|
@@ -4514,6 +4426,9 @@ function parseBoxSizing(value) {
|
|
|
4514
4426
|
}
|
|
4515
4427
|
}
|
|
4516
4428
|
function parseDimension(value) {
|
|
4429
|
+
if (value == null) {
|
|
4430
|
+
return Dimension.Width;
|
|
4431
|
+
}
|
|
4517
4432
|
switch (value.toLowerCase()) {
|
|
4518
4433
|
case "width":
|
|
4519
4434
|
return Dimension.Width;
|
|
@@ -4524,6 +4439,9 @@ function parseDimension(value) {
|
|
|
4524
4439
|
}
|
|
4525
4440
|
}
|
|
4526
4441
|
function parseDirection(value) {
|
|
4442
|
+
if (value == null) {
|
|
4443
|
+
return Direction.LTR;
|
|
4444
|
+
}
|
|
4527
4445
|
switch (value.toLowerCase()) {
|
|
4528
4446
|
case "inherit":
|
|
4529
4447
|
return Direction.Inherit;
|
|
@@ -4536,6 +4454,9 @@ function parseDirection(value) {
|
|
|
4536
4454
|
}
|
|
4537
4455
|
}
|
|
4538
4456
|
function parseDisplay(value) {
|
|
4457
|
+
if (value == null) {
|
|
4458
|
+
return Display.Flex;
|
|
4459
|
+
}
|
|
4539
4460
|
switch (value.toLowerCase()) {
|
|
4540
4461
|
case "flex":
|
|
4541
4462
|
return Display.Flex;
|
|
@@ -4548,6 +4469,9 @@ function parseDisplay(value) {
|
|
|
4548
4469
|
}
|
|
4549
4470
|
}
|
|
4550
4471
|
function parseEdge(value) {
|
|
4472
|
+
if (value == null) {
|
|
4473
|
+
return Edge.All;
|
|
4474
|
+
}
|
|
4551
4475
|
switch (value.toLowerCase()) {
|
|
4552
4476
|
case "left":
|
|
4553
4477
|
return Edge.Left;
|
|
@@ -4572,6 +4496,9 @@ function parseEdge(value) {
|
|
|
4572
4496
|
}
|
|
4573
4497
|
}
|
|
4574
4498
|
function parseFlexDirection(value) {
|
|
4499
|
+
if (value == null) {
|
|
4500
|
+
return FlexDirection.Column;
|
|
4501
|
+
}
|
|
4575
4502
|
switch (value.toLowerCase()) {
|
|
4576
4503
|
case "column":
|
|
4577
4504
|
return FlexDirection.Column;
|
|
@@ -4586,6 +4513,9 @@ function parseFlexDirection(value) {
|
|
|
4586
4513
|
}
|
|
4587
4514
|
}
|
|
4588
4515
|
function parseGutter(value) {
|
|
4516
|
+
if (value == null) {
|
|
4517
|
+
return Gutter.All;
|
|
4518
|
+
}
|
|
4589
4519
|
switch (value.toLowerCase()) {
|
|
4590
4520
|
case "column":
|
|
4591
4521
|
return Gutter.Column;
|
|
@@ -4598,6 +4528,9 @@ function parseGutter(value) {
|
|
|
4598
4528
|
}
|
|
4599
4529
|
}
|
|
4600
4530
|
function parseJustify(value) {
|
|
4531
|
+
if (value == null) {
|
|
4532
|
+
return Justify.FlexStart;
|
|
4533
|
+
}
|
|
4601
4534
|
switch (value.toLowerCase()) {
|
|
4602
4535
|
case "flex-start":
|
|
4603
4536
|
return Justify.FlexStart;
|
|
@@ -4616,6 +4549,9 @@ function parseJustify(value) {
|
|
|
4616
4549
|
}
|
|
4617
4550
|
}
|
|
4618
4551
|
function parseLogLevel(value) {
|
|
4552
|
+
if (value == null) {
|
|
4553
|
+
return LogLevel.Info;
|
|
4554
|
+
}
|
|
4619
4555
|
switch (value.toLowerCase()) {
|
|
4620
4556
|
case "error":
|
|
4621
4557
|
return LogLevel.Error;
|
|
@@ -4634,6 +4570,9 @@ function parseLogLevel(value) {
|
|
|
4634
4570
|
}
|
|
4635
4571
|
}
|
|
4636
4572
|
function parseMeasureMode(value) {
|
|
4573
|
+
if (value == null) {
|
|
4574
|
+
return MeasureMode.Undefined;
|
|
4575
|
+
}
|
|
4637
4576
|
switch (value.toLowerCase()) {
|
|
4638
4577
|
case "undefined":
|
|
4639
4578
|
return MeasureMode.Undefined;
|
|
@@ -4646,6 +4585,9 @@ function parseMeasureMode(value) {
|
|
|
4646
4585
|
}
|
|
4647
4586
|
}
|
|
4648
4587
|
function parseOverflow(value) {
|
|
4588
|
+
if (value == null) {
|
|
4589
|
+
return Overflow.Visible;
|
|
4590
|
+
}
|
|
4649
4591
|
switch (value.toLowerCase()) {
|
|
4650
4592
|
case "visible":
|
|
4651
4593
|
return Overflow.Visible;
|
|
@@ -4658,6 +4600,9 @@ function parseOverflow(value) {
|
|
|
4658
4600
|
}
|
|
4659
4601
|
}
|
|
4660
4602
|
function parsePositionType(value) {
|
|
4603
|
+
if (value == null) {
|
|
4604
|
+
return PositionType.Relative;
|
|
4605
|
+
}
|
|
4661
4606
|
switch (value.toLowerCase()) {
|
|
4662
4607
|
case "static":
|
|
4663
4608
|
return PositionType.Static;
|
|
@@ -4670,6 +4615,9 @@ function parsePositionType(value) {
|
|
|
4670
4615
|
}
|
|
4671
4616
|
}
|
|
4672
4617
|
function parseUnit(value) {
|
|
4618
|
+
if (value == null) {
|
|
4619
|
+
return Unit.Point;
|
|
4620
|
+
}
|
|
4673
4621
|
switch (value.toLowerCase()) {
|
|
4674
4622
|
case "undefined":
|
|
4675
4623
|
return Unit.Undefined;
|
|
@@ -4684,6 +4632,9 @@ function parseUnit(value) {
|
|
|
4684
4632
|
}
|
|
4685
4633
|
}
|
|
4686
4634
|
function parseWrap(value) {
|
|
4635
|
+
if (value == null) {
|
|
4636
|
+
return Wrap.NoWrap;
|
|
4637
|
+
}
|
|
4687
4638
|
switch (value.toLowerCase()) {
|
|
4688
4639
|
case "no-wrap":
|
|
4689
4640
|
return Wrap.NoWrap;
|
|
@@ -6254,8 +6205,9 @@ function getTreeSitterClient() {
|
|
|
6254
6205
|
});
|
|
6255
6206
|
}
|
|
6256
6207
|
// src/zig.ts
|
|
6257
|
-
import { dlopen, toArrayBuffer as
|
|
6208
|
+
import { dlopen, toArrayBuffer as toArrayBuffer4, JSCallback, ptr as ptr3 } from "bun:ffi";
|
|
6258
6209
|
import { existsSync as existsSync2 } from "fs";
|
|
6210
|
+
import { EventEmitter as EventEmitter4 } from "events";
|
|
6259
6211
|
|
|
6260
6212
|
// src/buffer.ts
|
|
6261
6213
|
import { toArrayBuffer } from "bun:ffi";
|
|
@@ -6411,9 +6363,13 @@ class OptimizedBuffer {
|
|
|
6411
6363
|
this._destroyed = true;
|
|
6412
6364
|
this.lib.destroyOptimizedBuffer(this.bufferPtr);
|
|
6413
6365
|
}
|
|
6414
|
-
drawTextBuffer(
|
|
6366
|
+
drawTextBuffer(textBufferView, x, y) {
|
|
6367
|
+
this.guard();
|
|
6368
|
+
this.lib.bufferDrawTextBufferView(this.bufferPtr, textBufferView.ptr, x, y);
|
|
6369
|
+
}
|
|
6370
|
+
drawEditorView(editorView, x, y) {
|
|
6415
6371
|
this.guard();
|
|
6416
|
-
this.lib.
|
|
6372
|
+
this.lib.bufferDrawEditorView(this.bufferPtr, editorView.ptr, x, y);
|
|
6417
6373
|
}
|
|
6418
6374
|
drawSuperSampleBuffer(x, y, pixelDataPtr, pixelDataLength, format, alignedBytesPerRow) {
|
|
6419
6375
|
this.guard();
|
|
@@ -6453,6 +6409,612 @@ class OptimizedBuffer {
|
|
|
6453
6409
|
}
|
|
6454
6410
|
}
|
|
6455
6411
|
|
|
6412
|
+
// ../../node_modules/.bun/bun-ffi-structs@0.1.0+ca84541ac88a3075/node_modules/bun-ffi-structs/index.js
|
|
6413
|
+
import { ptr, toArrayBuffer as toArrayBuffer2 } from "bun:ffi";
|
|
6414
|
+
function fatalError(...args) {
|
|
6415
|
+
const message = args.join(" ");
|
|
6416
|
+
console.error("FATAL ERROR:", message);
|
|
6417
|
+
throw new Error(message);
|
|
6418
|
+
}
|
|
6419
|
+
var pointerSize = process.arch === "x64" || process.arch === "arm64" ? 8 : 4;
|
|
6420
|
+
var typeSizes = {
|
|
6421
|
+
u8: 1,
|
|
6422
|
+
bool_u8: 1,
|
|
6423
|
+
bool_u32: 4,
|
|
6424
|
+
u16: 2,
|
|
6425
|
+
i16: 2,
|
|
6426
|
+
u32: 4,
|
|
6427
|
+
u64: 8,
|
|
6428
|
+
f32: 4,
|
|
6429
|
+
f64: 8,
|
|
6430
|
+
pointer: pointerSize,
|
|
6431
|
+
i32: 4
|
|
6432
|
+
};
|
|
6433
|
+
var primitiveKeys = Object.keys(typeSizes);
|
|
6434
|
+
function isPrimitiveType(type) {
|
|
6435
|
+
return typeof type === "string" && primitiveKeys.includes(type);
|
|
6436
|
+
}
|
|
6437
|
+
var typeAlignments = { ...typeSizes };
|
|
6438
|
+
var typeGetters = {
|
|
6439
|
+
u8: (view, offset) => view.getUint8(offset),
|
|
6440
|
+
bool_u8: (view, offset) => Boolean(view.getUint8(offset)),
|
|
6441
|
+
bool_u32: (view, offset) => Boolean(view.getUint32(offset, true)),
|
|
6442
|
+
u16: (view, offset) => view.getUint16(offset, true),
|
|
6443
|
+
i16: (view, offset) => view.getInt16(offset, true),
|
|
6444
|
+
u32: (view, offset) => view.getUint32(offset, true),
|
|
6445
|
+
u64: (view, offset) => view.getBigUint64(offset, true),
|
|
6446
|
+
f32: (view, offset) => view.getFloat32(offset, true),
|
|
6447
|
+
f64: (view, offset) => view.getFloat64(offset, true),
|
|
6448
|
+
i32: (view, offset) => view.getInt32(offset, true),
|
|
6449
|
+
pointer: (view, offset) => pointerSize === 8 ? view.getBigUint64(offset, true) : BigInt(view.getUint32(offset, true))
|
|
6450
|
+
};
|
|
6451
|
+
function isObjectPointerDef(type) {
|
|
6452
|
+
return typeof type === "object" && type !== null && type.__type === "objectPointer";
|
|
6453
|
+
}
|
|
6454
|
+
function alignOffset(offset, align) {
|
|
6455
|
+
return offset + (align - 1) & ~(align - 1);
|
|
6456
|
+
}
|
|
6457
|
+
function isEnum(type) {
|
|
6458
|
+
return typeof type === "object" && type.__type === "enum";
|
|
6459
|
+
}
|
|
6460
|
+
function isStruct(type) {
|
|
6461
|
+
return typeof type === "object" && type.__type === "struct";
|
|
6462
|
+
}
|
|
6463
|
+
function primitivePackers(type) {
|
|
6464
|
+
let pack;
|
|
6465
|
+
let unpack;
|
|
6466
|
+
switch (type) {
|
|
6467
|
+
case "u8":
|
|
6468
|
+
pack = (view, off, val) => view.setUint8(off, val);
|
|
6469
|
+
unpack = (view, off) => view.getUint8(off);
|
|
6470
|
+
break;
|
|
6471
|
+
case "bool_u8":
|
|
6472
|
+
pack = (view, off, val) => view.setUint8(off, val ? 1 : 0);
|
|
6473
|
+
unpack = (view, off) => Boolean(view.getUint8(off));
|
|
6474
|
+
break;
|
|
6475
|
+
case "bool_u32":
|
|
6476
|
+
pack = (view, off, val) => view.setUint32(off, val ? 1 : 0, true);
|
|
6477
|
+
unpack = (view, off) => Boolean(view.getUint32(off, true));
|
|
6478
|
+
break;
|
|
6479
|
+
case "u16":
|
|
6480
|
+
pack = (view, off, val) => view.setUint16(off, val, true);
|
|
6481
|
+
unpack = (view, off) => view.getUint16(off, true);
|
|
6482
|
+
break;
|
|
6483
|
+
case "i16":
|
|
6484
|
+
pack = (view, off, val) => view.setInt16(off, val, true);
|
|
6485
|
+
unpack = (view, off) => view.getInt16(off, true);
|
|
6486
|
+
break;
|
|
6487
|
+
case "u32":
|
|
6488
|
+
pack = (view, off, val) => view.setUint32(off, val, true);
|
|
6489
|
+
unpack = (view, off) => view.getUint32(off, true);
|
|
6490
|
+
break;
|
|
6491
|
+
case "i32":
|
|
6492
|
+
pack = (view, off, val) => view.setInt32(off, val, true);
|
|
6493
|
+
unpack = (view, off) => view.getInt32(off, true);
|
|
6494
|
+
break;
|
|
6495
|
+
case "u64":
|
|
6496
|
+
pack = (view, off, val) => view.setBigUint64(off, BigInt(val), true);
|
|
6497
|
+
unpack = (view, off) => view.getBigUint64(off, true);
|
|
6498
|
+
break;
|
|
6499
|
+
case "f32":
|
|
6500
|
+
pack = (view, off, val) => view.setFloat32(off, val, true);
|
|
6501
|
+
unpack = (view, off) => view.getFloat32(off, true);
|
|
6502
|
+
break;
|
|
6503
|
+
case "f64":
|
|
6504
|
+
pack = (view, off, val) => view.setFloat64(off, val, true);
|
|
6505
|
+
unpack = (view, off) => view.getFloat64(off, true);
|
|
6506
|
+
break;
|
|
6507
|
+
case "pointer":
|
|
6508
|
+
pack = (view, off, val) => {
|
|
6509
|
+
pointerSize === 8 ? view.setBigUint64(off, val ? BigInt(val) : 0n, true) : view.setUint32(off, val ? Number(val) : 0, true);
|
|
6510
|
+
};
|
|
6511
|
+
unpack = (view, off) => {
|
|
6512
|
+
const bint = pointerSize === 8 ? view.getBigUint64(off, true) : BigInt(view.getUint32(off, true));
|
|
6513
|
+
return Number(bint);
|
|
6514
|
+
};
|
|
6515
|
+
break;
|
|
6516
|
+
default:
|
|
6517
|
+
fatalError(`Unsupported primitive type: ${type}`);
|
|
6518
|
+
}
|
|
6519
|
+
return { pack, unpack };
|
|
6520
|
+
}
|
|
6521
|
+
var { pack: pointerPacker, unpack: pointerUnpacker } = primitivePackers("pointer");
|
|
6522
|
+
function packObjectArray(val) {
|
|
6523
|
+
const buffer = new ArrayBuffer(val.length * pointerSize);
|
|
6524
|
+
const bufferView = new DataView(buffer);
|
|
6525
|
+
for (let i = 0;i < val.length; i++) {
|
|
6526
|
+
const instance = val[i];
|
|
6527
|
+
const ptrValue = instance?.ptr ?? null;
|
|
6528
|
+
pointerPacker(bufferView, i * pointerSize, ptrValue);
|
|
6529
|
+
}
|
|
6530
|
+
return bufferView;
|
|
6531
|
+
}
|
|
6532
|
+
var encoder = new TextEncoder;
|
|
6533
|
+
function defineStruct(fields, structDefOptions) {
|
|
6534
|
+
let offset = 0;
|
|
6535
|
+
let maxAlign = 1;
|
|
6536
|
+
const layout = [];
|
|
6537
|
+
const lengthOfFields = {};
|
|
6538
|
+
const lengthOfRequested = [];
|
|
6539
|
+
const arrayFieldsMetadata = {};
|
|
6540
|
+
for (const [name, typeOrStruct, options = {}] of fields) {
|
|
6541
|
+
if (options.condition && !options.condition()) {
|
|
6542
|
+
continue;
|
|
6543
|
+
}
|
|
6544
|
+
let size = 0, align = 0;
|
|
6545
|
+
let pack;
|
|
6546
|
+
let unpack;
|
|
6547
|
+
let needsLengthOf = false;
|
|
6548
|
+
let lengthOfDef = null;
|
|
6549
|
+
if (isPrimitiveType(typeOrStruct)) {
|
|
6550
|
+
size = typeSizes[typeOrStruct];
|
|
6551
|
+
align = typeAlignments[typeOrStruct];
|
|
6552
|
+
({ pack, unpack } = primitivePackers(typeOrStruct));
|
|
6553
|
+
} else if (typeof typeOrStruct === "string" && typeOrStruct === "cstring") {
|
|
6554
|
+
size = pointerSize;
|
|
6555
|
+
align = pointerSize;
|
|
6556
|
+
pack = (view, off, val) => {
|
|
6557
|
+
const bufPtr = val ? ptr(encoder.encode(val + "\x00")) : null;
|
|
6558
|
+
pointerPacker(view, off, bufPtr);
|
|
6559
|
+
};
|
|
6560
|
+
unpack = (view, off) => {
|
|
6561
|
+
const ptrVal = pointerUnpacker(view, off);
|
|
6562
|
+
return ptrVal;
|
|
6563
|
+
};
|
|
6564
|
+
} else if (typeof typeOrStruct === "string" && typeOrStruct === "char*") {
|
|
6565
|
+
size = pointerSize;
|
|
6566
|
+
align = pointerSize;
|
|
6567
|
+
pack = (view, off, val) => {
|
|
6568
|
+
const bufPtr = val ? ptr(encoder.encode(val)) : null;
|
|
6569
|
+
pointerPacker(view, off, bufPtr);
|
|
6570
|
+
};
|
|
6571
|
+
unpack = (view, off) => {
|
|
6572
|
+
const ptrVal = pointerUnpacker(view, off);
|
|
6573
|
+
return ptrVal;
|
|
6574
|
+
};
|
|
6575
|
+
} else if (isEnum(typeOrStruct)) {
|
|
6576
|
+
const base = typeOrStruct.type;
|
|
6577
|
+
size = typeSizes[base];
|
|
6578
|
+
align = typeAlignments[base];
|
|
6579
|
+
const { pack: packEnum } = primitivePackers(base);
|
|
6580
|
+
pack = (view, off, val) => {
|
|
6581
|
+
const num = typeOrStruct.to(val);
|
|
6582
|
+
packEnum(view, off, num);
|
|
6583
|
+
};
|
|
6584
|
+
unpack = (view, off) => {
|
|
6585
|
+
const raw = typeGetters[base](view, off);
|
|
6586
|
+
return typeOrStruct.from(raw);
|
|
6587
|
+
};
|
|
6588
|
+
} else if (isStruct(typeOrStruct)) {
|
|
6589
|
+
if (options.asPointer === true) {
|
|
6590
|
+
size = pointerSize;
|
|
6591
|
+
align = pointerSize;
|
|
6592
|
+
pack = (view, off, val, obj, options2) => {
|
|
6593
|
+
if (!val) {
|
|
6594
|
+
pointerPacker(view, off, null);
|
|
6595
|
+
return;
|
|
6596
|
+
}
|
|
6597
|
+
const nestedBuf = typeOrStruct.pack(val, options2);
|
|
6598
|
+
pointerPacker(view, off, ptr(nestedBuf));
|
|
6599
|
+
};
|
|
6600
|
+
unpack = (view, off) => {
|
|
6601
|
+
throw new Error("Not implemented yet");
|
|
6602
|
+
};
|
|
6603
|
+
} else {
|
|
6604
|
+
size = typeOrStruct.size;
|
|
6605
|
+
align = typeOrStruct.align;
|
|
6606
|
+
pack = (view, off, val, obj, options2) => {
|
|
6607
|
+
const nestedBuf = typeOrStruct.pack(val, options2);
|
|
6608
|
+
const nestedView = new Uint8Array(nestedBuf);
|
|
6609
|
+
const dView = new Uint8Array(view.buffer);
|
|
6610
|
+
dView.set(nestedView, off);
|
|
6611
|
+
};
|
|
6612
|
+
unpack = (view, off) => {
|
|
6613
|
+
const slice = view.buffer.slice(off, off + size);
|
|
6614
|
+
return typeOrStruct.unpack(slice);
|
|
6615
|
+
};
|
|
6616
|
+
}
|
|
6617
|
+
} else if (isObjectPointerDef(typeOrStruct)) {
|
|
6618
|
+
size = pointerSize;
|
|
6619
|
+
align = pointerSize;
|
|
6620
|
+
pack = (view, off, value) => {
|
|
6621
|
+
const ptrValue = value?.ptr ?? null;
|
|
6622
|
+
if (ptrValue === undefined) {
|
|
6623
|
+
console.warn(`Field '${name}' expected object with '.ptr' property, but got undefined pointer value from:`, value);
|
|
6624
|
+
pointerPacker(view, off, null);
|
|
6625
|
+
} else {
|
|
6626
|
+
pointerPacker(view, off, ptrValue);
|
|
6627
|
+
}
|
|
6628
|
+
};
|
|
6629
|
+
unpack = (view, off) => {
|
|
6630
|
+
return pointerUnpacker(view, off);
|
|
6631
|
+
};
|
|
6632
|
+
} else if (Array.isArray(typeOrStruct) && typeOrStruct.length === 1 && typeOrStruct[0] !== undefined) {
|
|
6633
|
+
const [def] = typeOrStruct;
|
|
6634
|
+
size = pointerSize;
|
|
6635
|
+
align = pointerSize;
|
|
6636
|
+
let arrayElementSize;
|
|
6637
|
+
if (isEnum(def)) {
|
|
6638
|
+
arrayElementSize = typeSizes[def.type];
|
|
6639
|
+
pack = (view, off, val, obj) => {
|
|
6640
|
+
if (!val || val.length === 0) {
|
|
6641
|
+
pointerPacker(view, off, null);
|
|
6642
|
+
return;
|
|
6643
|
+
}
|
|
6644
|
+
const buffer = new ArrayBuffer(val.length * arrayElementSize);
|
|
6645
|
+
const bufferView = new DataView(buffer);
|
|
6646
|
+
for (let i = 0;i < val.length; i++) {
|
|
6647
|
+
const num = def.to(val[i]);
|
|
6648
|
+
bufferView.setUint32(i * arrayElementSize, num, true);
|
|
6649
|
+
}
|
|
6650
|
+
pointerPacker(view, off, ptr(buffer));
|
|
6651
|
+
};
|
|
6652
|
+
unpack = null;
|
|
6653
|
+
needsLengthOf = true;
|
|
6654
|
+
lengthOfDef = def;
|
|
6655
|
+
} else if (isStruct(def)) {
|
|
6656
|
+
arrayElementSize = def.size;
|
|
6657
|
+
pack = (view, off, val, obj, options2) => {
|
|
6658
|
+
if (!val || val.length === 0) {
|
|
6659
|
+
pointerPacker(view, off, null);
|
|
6660
|
+
return;
|
|
6661
|
+
}
|
|
6662
|
+
const buffer = new ArrayBuffer(val.length * arrayElementSize);
|
|
6663
|
+
const bufferView = new DataView(buffer);
|
|
6664
|
+
for (let i = 0;i < val.length; i++) {
|
|
6665
|
+
def.packInto(val[i], bufferView, i * arrayElementSize, options2);
|
|
6666
|
+
}
|
|
6667
|
+
pointerPacker(view, off, ptr(buffer));
|
|
6668
|
+
};
|
|
6669
|
+
unpack = (view, off) => {
|
|
6670
|
+
throw new Error("Not implemented yet");
|
|
6671
|
+
};
|
|
6672
|
+
} else if (isPrimitiveType(def)) {
|
|
6673
|
+
arrayElementSize = typeSizes[def];
|
|
6674
|
+
const { pack: primitivePack } = primitivePackers(def);
|
|
6675
|
+
pack = (view, off, val) => {
|
|
6676
|
+
if (!val || val.length === 0) {
|
|
6677
|
+
pointerPacker(view, off, null);
|
|
6678
|
+
return;
|
|
6679
|
+
}
|
|
6680
|
+
const buffer = new ArrayBuffer(val.length * arrayElementSize);
|
|
6681
|
+
const bufferView = new DataView(buffer);
|
|
6682
|
+
for (let i = 0;i < val.length; i++) {
|
|
6683
|
+
primitivePack(bufferView, i * arrayElementSize, val[i]);
|
|
6684
|
+
}
|
|
6685
|
+
pointerPacker(view, off, ptr(buffer));
|
|
6686
|
+
};
|
|
6687
|
+
unpack = null;
|
|
6688
|
+
needsLengthOf = true;
|
|
6689
|
+
lengthOfDef = def;
|
|
6690
|
+
} else if (isObjectPointerDef(def)) {
|
|
6691
|
+
arrayElementSize = pointerSize;
|
|
6692
|
+
pack = (view, off, val) => {
|
|
6693
|
+
if (!val || val.length === 0) {
|
|
6694
|
+
pointerPacker(view, off, null);
|
|
6695
|
+
return;
|
|
6696
|
+
}
|
|
6697
|
+
const packedView = packObjectArray(val);
|
|
6698
|
+
pointerPacker(view, off, ptr(packedView.buffer));
|
|
6699
|
+
};
|
|
6700
|
+
unpack = () => {
|
|
6701
|
+
throw new Error("not implemented yet");
|
|
6702
|
+
};
|
|
6703
|
+
} else {
|
|
6704
|
+
throw new Error(`Unsupported array element type for ${name}: ${JSON.stringify(def)}`);
|
|
6705
|
+
}
|
|
6706
|
+
const lengthOfField = Object.values(lengthOfFields).find((f) => f.lengthOf === name);
|
|
6707
|
+
if (lengthOfField && isPrimitiveType(lengthOfField.type)) {
|
|
6708
|
+
const { pack: lengthPack } = primitivePackers(lengthOfField.type);
|
|
6709
|
+
arrayFieldsMetadata[name] = {
|
|
6710
|
+
elementSize: arrayElementSize,
|
|
6711
|
+
arrayOffset: offset,
|
|
6712
|
+
lengthOffset: lengthOfField.offset,
|
|
6713
|
+
lengthPack
|
|
6714
|
+
};
|
|
6715
|
+
}
|
|
6716
|
+
} else {
|
|
6717
|
+
throw new Error(`Unsupported field type for ${name}: ${JSON.stringify(typeOrStruct)}`);
|
|
6718
|
+
}
|
|
6719
|
+
offset = alignOffset(offset, align);
|
|
6720
|
+
if (options.unpackTransform) {
|
|
6721
|
+
const originalUnpack = unpack;
|
|
6722
|
+
unpack = (view, off) => options.unpackTransform(originalUnpack(view, off));
|
|
6723
|
+
}
|
|
6724
|
+
if (options.packTransform) {
|
|
6725
|
+
const originalPack = pack;
|
|
6726
|
+
pack = (view, off, val, obj, packOptions) => originalPack(view, off, options.packTransform(val), obj, packOptions);
|
|
6727
|
+
}
|
|
6728
|
+
if (options.optional) {
|
|
6729
|
+
const originalPack = pack;
|
|
6730
|
+
if (isStruct(typeOrStruct) && !options.asPointer) {
|
|
6731
|
+
pack = (view, off, val, obj, packOptions) => {
|
|
6732
|
+
if (val || options.mapOptionalInline) {
|
|
6733
|
+
originalPack(view, off, val, obj, packOptions);
|
|
6734
|
+
}
|
|
6735
|
+
};
|
|
6736
|
+
} else {
|
|
6737
|
+
pack = (view, off, val, obj, packOptions) => originalPack(view, off, val ?? 0, obj, packOptions);
|
|
6738
|
+
}
|
|
6739
|
+
}
|
|
6740
|
+
if (options.lengthOf) {
|
|
6741
|
+
const originalPack = pack;
|
|
6742
|
+
pack = (view, off, val, obj, packOptions) => {
|
|
6743
|
+
const targetValue = obj[options.lengthOf];
|
|
6744
|
+
let length = 0;
|
|
6745
|
+
if (targetValue) {
|
|
6746
|
+
if (typeof targetValue === "string") {
|
|
6747
|
+
length = Buffer.byteLength(targetValue);
|
|
6748
|
+
} else {
|
|
6749
|
+
length = targetValue.length;
|
|
6750
|
+
}
|
|
6751
|
+
}
|
|
6752
|
+
return originalPack(view, off, length, obj, packOptions);
|
|
6753
|
+
};
|
|
6754
|
+
}
|
|
6755
|
+
let validateFunctions;
|
|
6756
|
+
if (options.validate) {
|
|
6757
|
+
validateFunctions = Array.isArray(options.validate) ? options.validate : [options.validate];
|
|
6758
|
+
}
|
|
6759
|
+
const layoutField = {
|
|
6760
|
+
name,
|
|
6761
|
+
offset,
|
|
6762
|
+
size,
|
|
6763
|
+
align,
|
|
6764
|
+
validate: validateFunctions,
|
|
6765
|
+
optional: !!options.optional || !!options.lengthOf || options.default !== undefined,
|
|
6766
|
+
default: options.default,
|
|
6767
|
+
pack,
|
|
6768
|
+
unpack,
|
|
6769
|
+
type: typeOrStruct,
|
|
6770
|
+
lengthOf: options.lengthOf
|
|
6771
|
+
};
|
|
6772
|
+
layout.push(layoutField);
|
|
6773
|
+
if (options.lengthOf) {
|
|
6774
|
+
lengthOfFields[options.lengthOf] = layoutField;
|
|
6775
|
+
}
|
|
6776
|
+
if (needsLengthOf) {
|
|
6777
|
+
if (!lengthOfDef)
|
|
6778
|
+
fatalError(`Internal error: needsLengthOf=true but lengthOfDef is null for ${name}`);
|
|
6779
|
+
lengthOfRequested.push({ requester: layoutField, def: lengthOfDef });
|
|
6780
|
+
}
|
|
6781
|
+
offset += size;
|
|
6782
|
+
maxAlign = Math.max(maxAlign, align);
|
|
6783
|
+
}
|
|
6784
|
+
for (const { requester, def } of lengthOfRequested) {
|
|
6785
|
+
const lengthOfField = lengthOfFields[requester.name];
|
|
6786
|
+
if (!lengthOfField) {
|
|
6787
|
+
throw new Error(`lengthOf field not found for array field ${requester.name}`);
|
|
6788
|
+
}
|
|
6789
|
+
if (isPrimitiveType(def)) {
|
|
6790
|
+
const elemSize = typeSizes[def];
|
|
6791
|
+
const { unpack: primitiveUnpack } = primitivePackers(def);
|
|
6792
|
+
requester.unpack = (view, off) => {
|
|
6793
|
+
const result = [];
|
|
6794
|
+
const length = lengthOfField.unpack(view, lengthOfField.offset);
|
|
6795
|
+
const ptrAddress = pointerUnpacker(view, off);
|
|
6796
|
+
if (ptrAddress === 0n && length > 0) {
|
|
6797
|
+
throw new Error(`Array field ${requester.name} has null pointer but length ${length}.`);
|
|
6798
|
+
}
|
|
6799
|
+
if (ptrAddress === 0n || length === 0) {
|
|
6800
|
+
return [];
|
|
6801
|
+
}
|
|
6802
|
+
const buffer = toArrayBuffer2(ptrAddress, 0, length * elemSize);
|
|
6803
|
+
const bufferView = new DataView(buffer);
|
|
6804
|
+
for (let i = 0;i < length; i++) {
|
|
6805
|
+
result.push(primitiveUnpack(bufferView, i * elemSize));
|
|
6806
|
+
}
|
|
6807
|
+
return result;
|
|
6808
|
+
};
|
|
6809
|
+
} else {
|
|
6810
|
+
const elemSize = def.type === "u32" ? 4 : 8;
|
|
6811
|
+
requester.unpack = (view, off) => {
|
|
6812
|
+
const result = [];
|
|
6813
|
+
const length = lengthOfField.unpack(view, lengthOfField.offset);
|
|
6814
|
+
const ptrAddress = pointerUnpacker(view, off);
|
|
6815
|
+
if (ptrAddress === 0n && length > 0) {
|
|
6816
|
+
throw new Error(`Array field ${requester.name} has null pointer but length ${length}.`);
|
|
6817
|
+
}
|
|
6818
|
+
if (ptrAddress === 0n || length === 0) {
|
|
6819
|
+
return [];
|
|
6820
|
+
}
|
|
6821
|
+
const buffer = toArrayBuffer2(ptrAddress, 0, length * elemSize);
|
|
6822
|
+
const bufferView = new DataView(buffer);
|
|
6823
|
+
for (let i = 0;i < length; i++) {
|
|
6824
|
+
result.push(def.from(bufferView.getUint32(i * elemSize, true)));
|
|
6825
|
+
}
|
|
6826
|
+
return result;
|
|
6827
|
+
};
|
|
6828
|
+
}
|
|
6829
|
+
}
|
|
6830
|
+
const totalSize = alignOffset(offset, maxAlign);
|
|
6831
|
+
const description = layout.map((f) => ({
|
|
6832
|
+
name: f.name,
|
|
6833
|
+
offset: f.offset,
|
|
6834
|
+
size: f.size,
|
|
6835
|
+
align: f.align,
|
|
6836
|
+
optional: f.optional,
|
|
6837
|
+
type: f.type,
|
|
6838
|
+
lengthOf: f.lengthOf
|
|
6839
|
+
}));
|
|
6840
|
+
const layoutByName = new Map(description.map((f) => [f.name, f]));
|
|
6841
|
+
const arrayFields = new Map(Object.entries(arrayFieldsMetadata));
|
|
6842
|
+
return {
|
|
6843
|
+
__type: "struct",
|
|
6844
|
+
size: totalSize,
|
|
6845
|
+
align: maxAlign,
|
|
6846
|
+
hasMapValue: !!structDefOptions?.mapValue,
|
|
6847
|
+
layoutByName,
|
|
6848
|
+
arrayFields,
|
|
6849
|
+
pack(obj, options) {
|
|
6850
|
+
const buf = new ArrayBuffer(totalSize);
|
|
6851
|
+
const view = new DataView(buf);
|
|
6852
|
+
let mappedObj = obj;
|
|
6853
|
+
if (structDefOptions?.mapValue) {
|
|
6854
|
+
mappedObj = structDefOptions.mapValue(obj);
|
|
6855
|
+
}
|
|
6856
|
+
for (const field of layout) {
|
|
6857
|
+
const value = mappedObj[field.name] ?? field.default;
|
|
6858
|
+
if (!field.optional && value === undefined) {
|
|
6859
|
+
fatalError(`Packing non-optional field '${field.name}' but value is undefined (and no default provided)`);
|
|
6860
|
+
}
|
|
6861
|
+
if (field.validate) {
|
|
6862
|
+
for (const validateFn of field.validate) {
|
|
6863
|
+
validateFn(value, field.name, {
|
|
6864
|
+
hints: options?.validationHints,
|
|
6865
|
+
input: mappedObj
|
|
6866
|
+
});
|
|
6867
|
+
}
|
|
6868
|
+
}
|
|
6869
|
+
field.pack(view, field.offset, value, mappedObj, options);
|
|
6870
|
+
}
|
|
6871
|
+
return view.buffer;
|
|
6872
|
+
},
|
|
6873
|
+
packInto(obj, view, offset2, options) {
|
|
6874
|
+
let mappedObj = obj;
|
|
6875
|
+
if (structDefOptions?.mapValue) {
|
|
6876
|
+
mappedObj = structDefOptions.mapValue(obj);
|
|
6877
|
+
}
|
|
6878
|
+
for (const field of layout) {
|
|
6879
|
+
const value = mappedObj[field.name] ?? field.default;
|
|
6880
|
+
if (!field.optional && value === undefined) {
|
|
6881
|
+
console.warn(`packInto missing value for non-optional field '${field.name}' at offset ${offset2 + field.offset}. Writing default or zero.`);
|
|
6882
|
+
}
|
|
6883
|
+
if (field.validate) {
|
|
6884
|
+
for (const validateFn of field.validate) {
|
|
6885
|
+
validateFn(value, field.name, {
|
|
6886
|
+
hints: options?.validationHints,
|
|
6887
|
+
input: mappedObj
|
|
6888
|
+
});
|
|
6889
|
+
}
|
|
6890
|
+
}
|
|
6891
|
+
field.pack(view, offset2 + field.offset, value, mappedObj, options);
|
|
6892
|
+
}
|
|
6893
|
+
},
|
|
6894
|
+
unpack(buf) {
|
|
6895
|
+
if (buf.byteLength < totalSize) {
|
|
6896
|
+
fatalError(`Buffer size (${buf.byteLength}) is smaller than struct size (${totalSize}) for unpacking.`);
|
|
6897
|
+
}
|
|
6898
|
+
const view = new DataView(buf);
|
|
6899
|
+
const result = structDefOptions?.default ? { ...structDefOptions.default } : {};
|
|
6900
|
+
for (const field of layout) {
|
|
6901
|
+
if (!field.unpack) {
|
|
6902
|
+
continue;
|
|
6903
|
+
}
|
|
6904
|
+
try {
|
|
6905
|
+
result[field.name] = field.unpack(view, field.offset);
|
|
6906
|
+
} catch (e) {
|
|
6907
|
+
console.error(`Error unpacking field '${field.name}' at offset ${field.offset}:`, e);
|
|
6908
|
+
throw e;
|
|
6909
|
+
}
|
|
6910
|
+
}
|
|
6911
|
+
if (structDefOptions?.reduceValue) {
|
|
6912
|
+
return structDefOptions.reduceValue(result);
|
|
6913
|
+
}
|
|
6914
|
+
return result;
|
|
6915
|
+
},
|
|
6916
|
+
packList(objects, options) {
|
|
6917
|
+
if (objects.length === 0) {
|
|
6918
|
+
return new ArrayBuffer(0);
|
|
6919
|
+
}
|
|
6920
|
+
const buffer = new ArrayBuffer(totalSize * objects.length);
|
|
6921
|
+
const view = new DataView(buffer);
|
|
6922
|
+
for (let i = 0;i < objects.length; i++) {
|
|
6923
|
+
let mappedObj = objects[i];
|
|
6924
|
+
if (structDefOptions?.mapValue) {
|
|
6925
|
+
mappedObj = structDefOptions.mapValue(objects[i]);
|
|
6926
|
+
}
|
|
6927
|
+
for (const field of layout) {
|
|
6928
|
+
const value = mappedObj[field.name] ?? field.default;
|
|
6929
|
+
if (!field.optional && value === undefined) {
|
|
6930
|
+
fatalError(`Packing non-optional field '${field.name}' at index ${i} but value is undefined (and no default provided)`);
|
|
6931
|
+
}
|
|
6932
|
+
if (field.validate) {
|
|
6933
|
+
for (const validateFn of field.validate) {
|
|
6934
|
+
validateFn(value, field.name, {
|
|
6935
|
+
hints: options?.validationHints,
|
|
6936
|
+
input: mappedObj
|
|
6937
|
+
});
|
|
6938
|
+
}
|
|
6939
|
+
}
|
|
6940
|
+
field.pack(view, i * totalSize + field.offset, value, mappedObj, options);
|
|
6941
|
+
}
|
|
6942
|
+
}
|
|
6943
|
+
return buffer;
|
|
6944
|
+
},
|
|
6945
|
+
unpackList(buf, count) {
|
|
6946
|
+
if (count === 0) {
|
|
6947
|
+
return [];
|
|
6948
|
+
}
|
|
6949
|
+
const expectedSize = totalSize * count;
|
|
6950
|
+
if (buf.byteLength < expectedSize) {
|
|
6951
|
+
fatalError(`Buffer size (${buf.byteLength}) is smaller than expected size (${expectedSize}) for unpacking ${count} structs.`);
|
|
6952
|
+
}
|
|
6953
|
+
const view = new DataView(buf);
|
|
6954
|
+
const results = [];
|
|
6955
|
+
for (let i = 0;i < count; i++) {
|
|
6956
|
+
const offset2 = i * totalSize;
|
|
6957
|
+
const result = structDefOptions?.default ? { ...structDefOptions.default } : {};
|
|
6958
|
+
for (const field of layout) {
|
|
6959
|
+
if (!field.unpack) {
|
|
6960
|
+
continue;
|
|
6961
|
+
}
|
|
6962
|
+
try {
|
|
6963
|
+
result[field.name] = field.unpack(view, offset2 + field.offset);
|
|
6964
|
+
} catch (e) {
|
|
6965
|
+
console.error(`Error unpacking field '${field.name}' at index ${i}, offset ${offset2 + field.offset}:`, e);
|
|
6966
|
+
throw e;
|
|
6967
|
+
}
|
|
6968
|
+
}
|
|
6969
|
+
if (structDefOptions?.reduceValue) {
|
|
6970
|
+
results.push(structDefOptions.reduceValue(result));
|
|
6971
|
+
} else {
|
|
6972
|
+
results.push(result);
|
|
6973
|
+
}
|
|
6974
|
+
}
|
|
6975
|
+
return results;
|
|
6976
|
+
},
|
|
6977
|
+
describe() {
|
|
6978
|
+
return description;
|
|
6979
|
+
}
|
|
6980
|
+
};
|
|
6981
|
+
}
|
|
6982
|
+
|
|
6983
|
+
// src/zig-structs.ts
|
|
6984
|
+
import { ptr as ptr2, toArrayBuffer as toArrayBuffer3 } from "bun:ffi";
|
|
6985
|
+
var rgbaPackTransform = (rgba) => rgba ? ptr2(rgba.buffer) : null;
|
|
6986
|
+
var rgbaUnpackTransform = (ptr3) => ptr3 ? RGBA.fromArray(new Float32Array(toArrayBuffer3(ptr3))) : undefined;
|
|
6987
|
+
var StyledChunkStruct = defineStruct([
|
|
6988
|
+
["text", "char*"],
|
|
6989
|
+
["text_len", "u64", { lengthOf: "text" }],
|
|
6990
|
+
[
|
|
6991
|
+
"fg",
|
|
6992
|
+
"pointer",
|
|
6993
|
+
{
|
|
6994
|
+
optional: true,
|
|
6995
|
+
packTransform: rgbaPackTransform,
|
|
6996
|
+
unpackTransform: rgbaUnpackTransform
|
|
6997
|
+
}
|
|
6998
|
+
],
|
|
6999
|
+
[
|
|
7000
|
+
"bg",
|
|
7001
|
+
"pointer",
|
|
7002
|
+
{
|
|
7003
|
+
optional: true,
|
|
7004
|
+
packTransform: rgbaPackTransform,
|
|
7005
|
+
unpackTransform: rgbaUnpackTransform
|
|
7006
|
+
}
|
|
7007
|
+
],
|
|
7008
|
+
["attributes", "u8", { optional: true }]
|
|
7009
|
+
]);
|
|
7010
|
+
var HighlightStruct = defineStruct([
|
|
7011
|
+
["start", "u32"],
|
|
7012
|
+
["end", "u32"],
|
|
7013
|
+
["styleId", "u32"],
|
|
7014
|
+
["priority", "u8", { default: 0 }],
|
|
7015
|
+
["hlRef", "u16", { default: 0 }]
|
|
7016
|
+
]);
|
|
7017
|
+
|
|
6456
7018
|
// src/zig.ts
|
|
6457
7019
|
var module = await import(`@opentui/core-${process.platform}-${process.arch}/index.ts`);
|
|
6458
7020
|
var targetLibPath = module.default;
|
|
@@ -6481,6 +7043,10 @@ function getOpenTUILib(libPath) {
|
|
|
6481
7043
|
args: ["ptr"],
|
|
6482
7044
|
returns: "void"
|
|
6483
7045
|
},
|
|
7046
|
+
setEventCallback: {
|
|
7047
|
+
args: ["ptr"],
|
|
7048
|
+
returns: "void"
|
|
7049
|
+
},
|
|
6484
7050
|
createRenderer: {
|
|
6485
7051
|
args: ["u32", "u32", "bool"],
|
|
6486
7052
|
returns: "ptr"
|
|
@@ -6709,15 +7275,15 @@ function getOpenTUILib(libPath) {
|
|
|
6709
7275
|
args: ["ptr"],
|
|
6710
7276
|
returns: "u32"
|
|
6711
7277
|
},
|
|
6712
|
-
|
|
7278
|
+
textBufferGetByteSize: {
|
|
6713
7279
|
args: ["ptr"],
|
|
6714
|
-
returns: "
|
|
7280
|
+
returns: "u32"
|
|
6715
7281
|
},
|
|
6716
|
-
|
|
6717
|
-
args: ["ptr"
|
|
7282
|
+
textBufferReset: {
|
|
7283
|
+
args: ["ptr"],
|
|
6718
7284
|
returns: "void"
|
|
6719
7285
|
},
|
|
6720
|
-
|
|
7286
|
+
textBufferClear: {
|
|
6721
7287
|
args: ["ptr"],
|
|
6722
7288
|
returns: "void"
|
|
6723
7289
|
},
|
|
@@ -6737,76 +7303,372 @@ function getOpenTUILib(libPath) {
|
|
|
6737
7303
|
args: ["ptr"],
|
|
6738
7304
|
returns: "void"
|
|
6739
7305
|
},
|
|
6740
|
-
|
|
6741
|
-
args: ["ptr", "ptr", "
|
|
6742
|
-
returns: "
|
|
7306
|
+
textBufferRegisterMemBuffer: {
|
|
7307
|
+
args: ["ptr", "ptr", "usize", "bool"],
|
|
7308
|
+
returns: "u16"
|
|
6743
7309
|
},
|
|
6744
|
-
|
|
6745
|
-
args: ["ptr"],
|
|
6746
|
-
returns: "
|
|
7310
|
+
textBufferReplaceMemBuffer: {
|
|
7311
|
+
args: ["ptr", "u8", "ptr", "usize", "bool"],
|
|
7312
|
+
returns: "bool"
|
|
6747
7313
|
},
|
|
6748
|
-
|
|
7314
|
+
textBufferClearMemRegistry: {
|
|
6749
7315
|
args: ["ptr"],
|
|
6750
|
-
returns: "
|
|
7316
|
+
returns: "void"
|
|
6751
7317
|
},
|
|
6752
|
-
|
|
6753
|
-
args: ["ptr", "
|
|
6754
|
-
returns: "
|
|
7318
|
+
textBufferSetTextFromMem: {
|
|
7319
|
+
args: ["ptr", "u8"],
|
|
7320
|
+
returns: "void"
|
|
6755
7321
|
},
|
|
6756
|
-
|
|
6757
|
-
args: ["ptr"],
|
|
6758
|
-
returns: "
|
|
7322
|
+
textBufferLoadFile: {
|
|
7323
|
+
args: ["ptr", "ptr", "usize"],
|
|
7324
|
+
returns: "bool"
|
|
6759
7325
|
},
|
|
6760
|
-
|
|
7326
|
+
textBufferSetStyledText: {
|
|
6761
7327
|
args: ["ptr", "ptr", "usize"],
|
|
6762
|
-
returns: "
|
|
7328
|
+
returns: "void"
|
|
7329
|
+
},
|
|
7330
|
+
textBufferGetLineCount: {
|
|
7331
|
+
args: ["ptr"],
|
|
7332
|
+
returns: "u32"
|
|
6763
7333
|
},
|
|
6764
7334
|
textBufferGetPlainText: {
|
|
6765
7335
|
args: ["ptr", "ptr", "usize"],
|
|
6766
7336
|
returns: "usize"
|
|
6767
7337
|
},
|
|
6768
|
-
|
|
6769
|
-
args: ["ptr", "
|
|
6770
|
-
returns: "
|
|
7338
|
+
textBufferAddHighlightByCharRange: {
|
|
7339
|
+
args: ["ptr", "ptr"],
|
|
7340
|
+
returns: "void"
|
|
7341
|
+
},
|
|
7342
|
+
textBufferAddHighlight: {
|
|
7343
|
+
args: ["ptr", "u32", "ptr"],
|
|
7344
|
+
returns: "void"
|
|
7345
|
+
},
|
|
7346
|
+
textBufferRemoveHighlightsByRef: {
|
|
7347
|
+
args: ["ptr", "u16"],
|
|
7348
|
+
returns: "void"
|
|
7349
|
+
},
|
|
7350
|
+
textBufferClearLineHighlights: {
|
|
7351
|
+
args: ["ptr", "u32"],
|
|
7352
|
+
returns: "void"
|
|
6771
7353
|
},
|
|
6772
|
-
|
|
7354
|
+
textBufferClearAllHighlights: {
|
|
6773
7355
|
args: ["ptr"],
|
|
6774
7356
|
returns: "void"
|
|
6775
7357
|
},
|
|
6776
|
-
|
|
6777
|
-
args: ["ptr", "
|
|
6778
|
-
returns: "
|
|
7358
|
+
textBufferSetSyntaxStyle: {
|
|
7359
|
+
args: ["ptr", "ptr"],
|
|
7360
|
+
returns: "void"
|
|
6779
7361
|
},
|
|
6780
|
-
|
|
7362
|
+
textBufferGetLineHighlightsPtr: {
|
|
7363
|
+
args: ["ptr", "u32", "ptr"],
|
|
7364
|
+
returns: "ptr"
|
|
7365
|
+
},
|
|
7366
|
+
textBufferFreeLineHighlights: {
|
|
6781
7367
|
args: ["ptr", "usize"],
|
|
6782
|
-
returns: "
|
|
7368
|
+
returns: "void"
|
|
6783
7369
|
},
|
|
6784
|
-
|
|
6785
|
-
args: ["ptr"
|
|
6786
|
-
returns: "
|
|
7370
|
+
createTextBufferView: {
|
|
7371
|
+
args: ["ptr"],
|
|
7372
|
+
returns: "ptr"
|
|
6787
7373
|
},
|
|
6788
|
-
|
|
7374
|
+
destroyTextBufferView: {
|
|
6789
7375
|
args: ["ptr"],
|
|
6790
|
-
returns: "
|
|
7376
|
+
returns: "void"
|
|
7377
|
+
},
|
|
7378
|
+
textBufferViewSetSelection: {
|
|
7379
|
+
args: ["ptr", "u32", "u32", "ptr", "ptr"],
|
|
7380
|
+
returns: "void"
|
|
6791
7381
|
},
|
|
6792
|
-
|
|
7382
|
+
textBufferViewResetSelection: {
|
|
7383
|
+
args: ["ptr"],
|
|
7384
|
+
returns: "void"
|
|
7385
|
+
},
|
|
7386
|
+
textBufferViewGetSelectionInfo: {
|
|
7387
|
+
args: ["ptr"],
|
|
7388
|
+
returns: "u64"
|
|
7389
|
+
},
|
|
7390
|
+
textBufferViewSetLocalSelection: {
|
|
7391
|
+
args: ["ptr", "i32", "i32", "i32", "i32", "ptr", "ptr"],
|
|
7392
|
+
returns: "bool"
|
|
7393
|
+
},
|
|
7394
|
+
textBufferViewResetLocalSelection: {
|
|
7395
|
+
args: ["ptr"],
|
|
7396
|
+
returns: "void"
|
|
7397
|
+
},
|
|
7398
|
+
textBufferViewSetWrapWidth: {
|
|
6793
7399
|
args: ["ptr", "u32"],
|
|
6794
7400
|
returns: "void"
|
|
6795
7401
|
},
|
|
6796
|
-
|
|
7402
|
+
textBufferViewSetWrapMode: {
|
|
6797
7403
|
args: ["ptr", "u8"],
|
|
6798
7404
|
returns: "void"
|
|
6799
7405
|
},
|
|
6800
|
-
|
|
6801
|
-
args: [],
|
|
7406
|
+
textBufferViewSetViewportSize: {
|
|
7407
|
+
args: ["ptr", "u32", "u32"],
|
|
7408
|
+
returns: "void"
|
|
7409
|
+
},
|
|
7410
|
+
textBufferViewGetVirtualLineCount: {
|
|
7411
|
+
args: ["ptr"],
|
|
7412
|
+
returns: "u32"
|
|
7413
|
+
},
|
|
7414
|
+
textBufferViewGetLineInfoDirect: {
|
|
7415
|
+
args: ["ptr", "ptr", "ptr"],
|
|
7416
|
+
returns: "u32"
|
|
7417
|
+
},
|
|
7418
|
+
textBufferViewGetLogicalLineInfoDirect: {
|
|
7419
|
+
args: ["ptr", "ptr", "ptr"],
|
|
7420
|
+
returns: "u32"
|
|
7421
|
+
},
|
|
7422
|
+
textBufferViewGetSelectedText: {
|
|
7423
|
+
args: ["ptr", "ptr", "usize"],
|
|
7424
|
+
returns: "usize"
|
|
7425
|
+
},
|
|
7426
|
+
textBufferViewGetPlainText: {
|
|
7427
|
+
args: ["ptr", "ptr", "usize"],
|
|
6802
7428
|
returns: "usize"
|
|
6803
7429
|
},
|
|
6804
|
-
|
|
6805
|
-
args: ["ptr", "ptr", "i32", "i32"
|
|
7430
|
+
bufferDrawTextBufferView: {
|
|
7431
|
+
args: ["ptr", "ptr", "i32", "i32"],
|
|
6806
7432
|
returns: "void"
|
|
6807
7433
|
},
|
|
6808
|
-
|
|
6809
|
-
args: ["ptr", "ptr"],
|
|
7434
|
+
bufferDrawEditorView: {
|
|
7435
|
+
args: ["ptr", "ptr", "i32", "i32"],
|
|
7436
|
+
returns: "void"
|
|
7437
|
+
},
|
|
7438
|
+
createEditorView: {
|
|
7439
|
+
args: ["ptr", "u32", "u32"],
|
|
7440
|
+
returns: "ptr"
|
|
7441
|
+
},
|
|
7442
|
+
destroyEditorView: {
|
|
7443
|
+
args: ["ptr"],
|
|
7444
|
+
returns: "void"
|
|
7445
|
+
},
|
|
7446
|
+
editorViewSetViewportSize: {
|
|
7447
|
+
args: ["ptr", "u32", "u32"],
|
|
7448
|
+
returns: "void"
|
|
7449
|
+
},
|
|
7450
|
+
editorViewGetViewport: {
|
|
7451
|
+
args: ["ptr", "ptr", "ptr", "ptr", "ptr"],
|
|
7452
|
+
returns: "void"
|
|
7453
|
+
},
|
|
7454
|
+
editorViewSetScrollMargin: {
|
|
7455
|
+
args: ["ptr", "f32"],
|
|
7456
|
+
returns: "void"
|
|
7457
|
+
},
|
|
7458
|
+
editorViewSetWrapMode: {
|
|
7459
|
+
args: ["ptr", "u8"],
|
|
7460
|
+
returns: "void"
|
|
7461
|
+
},
|
|
7462
|
+
editorViewGetVirtualLineCount: {
|
|
7463
|
+
args: ["ptr"],
|
|
7464
|
+
returns: "u32"
|
|
7465
|
+
},
|
|
7466
|
+
editorViewGetTotalVirtualLineCount: {
|
|
7467
|
+
args: ["ptr"],
|
|
7468
|
+
returns: "u32"
|
|
7469
|
+
},
|
|
7470
|
+
editorViewGetTextBufferView: {
|
|
7471
|
+
args: ["ptr"],
|
|
7472
|
+
returns: "ptr"
|
|
7473
|
+
},
|
|
7474
|
+
createEditBuffer: {
|
|
7475
|
+
args: ["u8"],
|
|
7476
|
+
returns: "ptr"
|
|
7477
|
+
},
|
|
7478
|
+
destroyEditBuffer: {
|
|
7479
|
+
args: ["ptr"],
|
|
7480
|
+
returns: "void"
|
|
7481
|
+
},
|
|
7482
|
+
editBufferSetText: {
|
|
7483
|
+
args: ["ptr", "ptr", "usize", "bool"],
|
|
7484
|
+
returns: "void"
|
|
7485
|
+
},
|
|
7486
|
+
editBufferSetTextFromMem: {
|
|
7487
|
+
args: ["ptr", "u8", "bool"],
|
|
7488
|
+
returns: "void"
|
|
7489
|
+
},
|
|
7490
|
+
editBufferGetText: {
|
|
7491
|
+
args: ["ptr", "ptr", "usize"],
|
|
7492
|
+
returns: "usize"
|
|
7493
|
+
},
|
|
7494
|
+
editBufferInsertChar: {
|
|
7495
|
+
args: ["ptr", "ptr", "usize"],
|
|
7496
|
+
returns: "void"
|
|
7497
|
+
},
|
|
7498
|
+
editBufferInsertText: {
|
|
7499
|
+
args: ["ptr", "ptr", "usize"],
|
|
7500
|
+
returns: "void"
|
|
7501
|
+
},
|
|
7502
|
+
editBufferDeleteChar: {
|
|
7503
|
+
args: ["ptr"],
|
|
7504
|
+
returns: "void"
|
|
7505
|
+
},
|
|
7506
|
+
editBufferDeleteCharBackward: {
|
|
7507
|
+
args: ["ptr"],
|
|
7508
|
+
returns: "void"
|
|
7509
|
+
},
|
|
7510
|
+
editBufferNewLine: {
|
|
7511
|
+
args: ["ptr"],
|
|
7512
|
+
returns: "void"
|
|
7513
|
+
},
|
|
7514
|
+
editBufferDeleteLine: {
|
|
7515
|
+
args: ["ptr"],
|
|
7516
|
+
returns: "void"
|
|
7517
|
+
},
|
|
7518
|
+
editBufferMoveCursorLeft: {
|
|
7519
|
+
args: ["ptr"],
|
|
7520
|
+
returns: "void"
|
|
7521
|
+
},
|
|
7522
|
+
editBufferMoveCursorRight: {
|
|
7523
|
+
args: ["ptr"],
|
|
7524
|
+
returns: "void"
|
|
7525
|
+
},
|
|
7526
|
+
editBufferMoveCursorUp: {
|
|
7527
|
+
args: ["ptr"],
|
|
7528
|
+
returns: "void"
|
|
7529
|
+
},
|
|
7530
|
+
editBufferMoveCursorDown: {
|
|
7531
|
+
args: ["ptr"],
|
|
7532
|
+
returns: "void"
|
|
7533
|
+
},
|
|
7534
|
+
editBufferGotoLine: {
|
|
7535
|
+
args: ["ptr", "u32"],
|
|
7536
|
+
returns: "void"
|
|
7537
|
+
},
|
|
7538
|
+
editBufferSetCursor: {
|
|
7539
|
+
args: ["ptr", "u32", "u32"],
|
|
7540
|
+
returns: "void"
|
|
7541
|
+
},
|
|
7542
|
+
editBufferSetCursorToLineCol: {
|
|
7543
|
+
args: ["ptr", "u32", "u32"],
|
|
7544
|
+
returns: "void"
|
|
7545
|
+
},
|
|
7546
|
+
editBufferSetCursorByOffset: {
|
|
7547
|
+
args: ["ptr", "u32"],
|
|
7548
|
+
returns: "void"
|
|
7549
|
+
},
|
|
7550
|
+
editBufferGetCursorPosition: {
|
|
7551
|
+
args: ["ptr", "ptr", "ptr", "ptr"],
|
|
7552
|
+
returns: "void"
|
|
7553
|
+
},
|
|
7554
|
+
editBufferGetId: {
|
|
7555
|
+
args: ["ptr"],
|
|
7556
|
+
returns: "u16"
|
|
7557
|
+
},
|
|
7558
|
+
editBufferGetTextBuffer: {
|
|
7559
|
+
args: ["ptr"],
|
|
7560
|
+
returns: "ptr"
|
|
7561
|
+
},
|
|
7562
|
+
editBufferDebugLogRope: {
|
|
7563
|
+
args: ["ptr"],
|
|
7564
|
+
returns: "void"
|
|
7565
|
+
},
|
|
7566
|
+
editBufferUndo: {
|
|
7567
|
+
args: ["ptr", "ptr", "usize"],
|
|
7568
|
+
returns: "usize"
|
|
7569
|
+
},
|
|
7570
|
+
editBufferRedo: {
|
|
7571
|
+
args: ["ptr", "ptr", "usize"],
|
|
7572
|
+
returns: "usize"
|
|
7573
|
+
},
|
|
7574
|
+
editBufferCanUndo: {
|
|
7575
|
+
args: ["ptr"],
|
|
7576
|
+
returns: "bool"
|
|
7577
|
+
},
|
|
7578
|
+
editBufferCanRedo: {
|
|
7579
|
+
args: ["ptr"],
|
|
7580
|
+
returns: "bool"
|
|
7581
|
+
},
|
|
7582
|
+
editBufferClearHistory: {
|
|
7583
|
+
args: ["ptr"],
|
|
7584
|
+
returns: "void"
|
|
7585
|
+
},
|
|
7586
|
+
editBufferSetPlaceholder: {
|
|
7587
|
+
args: ["ptr", "ptr", "usize"],
|
|
7588
|
+
returns: "void"
|
|
7589
|
+
},
|
|
7590
|
+
editBufferSetPlaceholderColor: {
|
|
7591
|
+
args: ["ptr", "ptr"],
|
|
7592
|
+
returns: "void"
|
|
7593
|
+
},
|
|
7594
|
+
editorViewSetSelection: {
|
|
7595
|
+
args: ["ptr", "u32", "u32", "ptr", "ptr"],
|
|
7596
|
+
returns: "void"
|
|
7597
|
+
},
|
|
7598
|
+
editorViewResetSelection: {
|
|
7599
|
+
args: ["ptr"],
|
|
7600
|
+
returns: "void"
|
|
7601
|
+
},
|
|
7602
|
+
editorViewGetSelection: {
|
|
7603
|
+
args: ["ptr"],
|
|
7604
|
+
returns: "u64"
|
|
7605
|
+
},
|
|
7606
|
+
editorViewSetLocalSelection: {
|
|
7607
|
+
args: ["ptr", "i32", "i32", "i32", "i32", "ptr", "ptr"],
|
|
7608
|
+
returns: "bool"
|
|
7609
|
+
},
|
|
7610
|
+
editorViewResetLocalSelection: {
|
|
7611
|
+
args: ["ptr"],
|
|
7612
|
+
returns: "void"
|
|
7613
|
+
},
|
|
7614
|
+
editorViewGetSelectedTextBytes: {
|
|
7615
|
+
args: ["ptr", "ptr", "usize"],
|
|
7616
|
+
returns: "usize"
|
|
7617
|
+
},
|
|
7618
|
+
editorViewGetCursor: {
|
|
7619
|
+
args: ["ptr", "ptr", "ptr"],
|
|
7620
|
+
returns: "void"
|
|
7621
|
+
},
|
|
7622
|
+
editorViewGetText: {
|
|
7623
|
+
args: ["ptr", "ptr", "usize"],
|
|
7624
|
+
returns: "usize"
|
|
7625
|
+
},
|
|
7626
|
+
editorViewGetVisualCursor: {
|
|
7627
|
+
args: ["ptr", "ptr", "ptr", "ptr", "ptr", "ptr"],
|
|
7628
|
+
returns: "bool"
|
|
7629
|
+
},
|
|
7630
|
+
editorViewMoveUpVisual: {
|
|
7631
|
+
args: ["ptr"],
|
|
7632
|
+
returns: "void"
|
|
7633
|
+
},
|
|
7634
|
+
editorViewMoveDownVisual: {
|
|
7635
|
+
args: ["ptr"],
|
|
7636
|
+
returns: "void"
|
|
7637
|
+
},
|
|
7638
|
+
editorViewDeleteSelectedText: {
|
|
7639
|
+
args: ["ptr"],
|
|
7640
|
+
returns: "void"
|
|
7641
|
+
},
|
|
7642
|
+
editorViewSetCursorByOffset: {
|
|
7643
|
+
args: ["ptr", "u32"],
|
|
7644
|
+
returns: "void"
|
|
7645
|
+
},
|
|
7646
|
+
getArenaAllocatedBytes: {
|
|
7647
|
+
args: [],
|
|
7648
|
+
returns: "usize"
|
|
7649
|
+
},
|
|
7650
|
+
createSyntaxStyle: {
|
|
7651
|
+
args: [],
|
|
7652
|
+
returns: "ptr"
|
|
7653
|
+
},
|
|
7654
|
+
destroySyntaxStyle: {
|
|
7655
|
+
args: ["ptr"],
|
|
7656
|
+
returns: "void"
|
|
7657
|
+
},
|
|
7658
|
+
syntaxStyleRegister: {
|
|
7659
|
+
args: ["ptr", "ptr", "usize", "ptr", "ptr", "u8"],
|
|
7660
|
+
returns: "u32"
|
|
7661
|
+
},
|
|
7662
|
+
syntaxStyleResolveByName: {
|
|
7663
|
+
args: ["ptr", "ptr", "usize"],
|
|
7664
|
+
returns: "u32"
|
|
7665
|
+
},
|
|
7666
|
+
syntaxStyleGetStyleCount: {
|
|
7667
|
+
args: ["ptr"],
|
|
7668
|
+
returns: "usize"
|
|
7669
|
+
},
|
|
7670
|
+
getTerminalCapabilities: {
|
|
7671
|
+
args: ["ptr", "ptr"],
|
|
6810
7672
|
returns: "void"
|
|
6811
7673
|
},
|
|
6812
7674
|
processCapabilityResponse: {
|
|
@@ -6937,9 +7799,13 @@ class FFIRenderLib {
|
|
|
6937
7799
|
encoder = new TextEncoder;
|
|
6938
7800
|
decoder = new TextDecoder;
|
|
6939
7801
|
logCallbackWrapper;
|
|
7802
|
+
eventCallbackWrapper;
|
|
7803
|
+
_nativeEvents = new EventEmitter4;
|
|
7804
|
+
_anyEventHandlers = [];
|
|
6940
7805
|
constructor(libPath) {
|
|
6941
7806
|
this.opentui = getOpenTUILib(libPath);
|
|
6942
7807
|
this.setupLogging();
|
|
7808
|
+
this.setupEventBus();
|
|
6943
7809
|
}
|
|
6944
7810
|
setupLogging() {
|
|
6945
7811
|
if (this.logCallbackWrapper) {
|
|
@@ -6951,7 +7817,7 @@ class FFIRenderLib {
|
|
|
6951
7817
|
if (msgLen === 0 || !msgPtr) {
|
|
6952
7818
|
return;
|
|
6953
7819
|
}
|
|
6954
|
-
const msgBuffer =
|
|
7820
|
+
const msgBuffer = toArrayBuffer4(msgPtr, 0, msgLen);
|
|
6955
7821
|
const msgBytes = new Uint8Array(msgBuffer);
|
|
6956
7822
|
const message = this.decoder.decode(msgBytes);
|
|
6957
7823
|
switch (level) {
|
|
@@ -6986,6 +7852,48 @@ class FFIRenderLib {
|
|
|
6986
7852
|
setLogCallback(callbackPtr) {
|
|
6987
7853
|
this.opentui.symbols.setLogCallback(callbackPtr);
|
|
6988
7854
|
}
|
|
7855
|
+
setupEventBus() {
|
|
7856
|
+
if (this.eventCallbackWrapper) {
|
|
7857
|
+
return;
|
|
7858
|
+
}
|
|
7859
|
+
const eventCallback = new JSCallback((namePtr, nameLenBigInt, dataPtr, dataLenBigInt) => {
|
|
7860
|
+
try {
|
|
7861
|
+
const nameLen = typeof nameLenBigInt === "bigint" ? Number(nameLenBigInt) : nameLenBigInt;
|
|
7862
|
+
const dataLen = typeof dataLenBigInt === "bigint" ? Number(dataLenBigInt) : dataLenBigInt;
|
|
7863
|
+
if (nameLen === 0 || !namePtr) {
|
|
7864
|
+
return;
|
|
7865
|
+
}
|
|
7866
|
+
const nameBuffer = toArrayBuffer4(namePtr, 0, nameLen);
|
|
7867
|
+
const nameBytes = new Uint8Array(nameBuffer);
|
|
7868
|
+
const eventName = this.decoder.decode(nameBytes);
|
|
7869
|
+
let eventData;
|
|
7870
|
+
if (dataLen > 0 && dataPtr) {
|
|
7871
|
+
eventData = toArrayBuffer4(dataPtr, 0, dataLen).slice();
|
|
7872
|
+
} else {
|
|
7873
|
+
eventData = new ArrayBuffer(0);
|
|
7874
|
+
}
|
|
7875
|
+
queueMicrotask(() => {
|
|
7876
|
+
this._nativeEvents.emit(eventName, eventData);
|
|
7877
|
+
for (const handler of this._anyEventHandlers) {
|
|
7878
|
+
handler(eventName, eventData);
|
|
7879
|
+
}
|
|
7880
|
+
});
|
|
7881
|
+
} catch (error) {
|
|
7882
|
+
console.error("Error in native event callback:", error);
|
|
7883
|
+
}
|
|
7884
|
+
}, {
|
|
7885
|
+
args: ["ptr", "usize", "ptr", "usize"],
|
|
7886
|
+
returns: "void"
|
|
7887
|
+
});
|
|
7888
|
+
this.eventCallbackWrapper = eventCallback;
|
|
7889
|
+
if (!eventCallback.ptr) {
|
|
7890
|
+
throw new Error("Failed to create event callback");
|
|
7891
|
+
}
|
|
7892
|
+
this.setEventCallback(eventCallback.ptr);
|
|
7893
|
+
}
|
|
7894
|
+
setEventCallback(callbackPtr) {
|
|
7895
|
+
this.opentui.symbols.setEventCallback(callbackPtr);
|
|
7896
|
+
}
|
|
6989
7897
|
createRenderer(width, height, options = { testing: false }) {
|
|
6990
7898
|
return this.opentui.symbols.createRenderer(width, height, options.testing);
|
|
6991
7899
|
}
|
|
@@ -7026,32 +7934,32 @@ class FFIRenderLib {
|
|
|
7026
7934
|
return new OptimizedBuffer(this, bufferPtr, width, height, { id: "current buffer" });
|
|
7027
7935
|
}
|
|
7028
7936
|
bufferGetCharPtr(buffer) {
|
|
7029
|
-
const
|
|
7030
|
-
if (!
|
|
7937
|
+
const ptr4 = this.opentui.symbols.bufferGetCharPtr(buffer);
|
|
7938
|
+
if (!ptr4) {
|
|
7031
7939
|
throw new Error("Failed to get char pointer");
|
|
7032
7940
|
}
|
|
7033
|
-
return
|
|
7941
|
+
return ptr4;
|
|
7034
7942
|
}
|
|
7035
7943
|
bufferGetFgPtr(buffer) {
|
|
7036
|
-
const
|
|
7037
|
-
if (!
|
|
7944
|
+
const ptr4 = this.opentui.symbols.bufferGetFgPtr(buffer);
|
|
7945
|
+
if (!ptr4) {
|
|
7038
7946
|
throw new Error("Failed to get fg pointer");
|
|
7039
7947
|
}
|
|
7040
|
-
return
|
|
7948
|
+
return ptr4;
|
|
7041
7949
|
}
|
|
7042
7950
|
bufferGetBgPtr(buffer) {
|
|
7043
|
-
const
|
|
7044
|
-
if (!
|
|
7951
|
+
const ptr4 = this.opentui.symbols.bufferGetBgPtr(buffer);
|
|
7952
|
+
if (!ptr4) {
|
|
7045
7953
|
throw new Error("Failed to get bg pointer");
|
|
7046
7954
|
}
|
|
7047
|
-
return
|
|
7955
|
+
return ptr4;
|
|
7048
7956
|
}
|
|
7049
7957
|
bufferGetAttributesPtr(buffer) {
|
|
7050
|
-
const
|
|
7051
|
-
if (!
|
|
7958
|
+
const ptr4 = this.opentui.symbols.bufferGetAttributesPtr(buffer);
|
|
7959
|
+
if (!ptr4) {
|
|
7052
7960
|
throw new Error("Failed to get attributes pointer");
|
|
7053
7961
|
}
|
|
7054
|
-
return
|
|
7962
|
+
return ptr4;
|
|
7055
7963
|
}
|
|
7056
7964
|
bufferGetRespectAlpha(buffer) {
|
|
7057
7965
|
return this.opentui.symbols.bufferGetRespectAlpha(buffer);
|
|
@@ -7219,16 +8127,14 @@ class FFIRenderLib {
|
|
|
7219
8127
|
textBufferGetLength(buffer) {
|
|
7220
8128
|
return this.opentui.symbols.textBufferGetLength(buffer);
|
|
7221
8129
|
}
|
|
8130
|
+
textBufferGetByteSize(buffer) {
|
|
8131
|
+
return this.opentui.symbols.textBufferGetByteSize(buffer);
|
|
8132
|
+
}
|
|
7222
8133
|
textBufferReset(buffer) {
|
|
7223
8134
|
this.opentui.symbols.textBufferReset(buffer);
|
|
7224
8135
|
}
|
|
7225
|
-
|
|
7226
|
-
|
|
7227
|
-
const fg2 = fgColor ? fgColor.buffer : null;
|
|
7228
|
-
this.opentui.symbols.textBufferSetSelection(buffer, start, end, bg2, fg2);
|
|
7229
|
-
}
|
|
7230
|
-
textBufferResetSelection(buffer) {
|
|
7231
|
-
this.opentui.symbols.textBufferResetSelection(buffer);
|
|
8136
|
+
textBufferClear(buffer) {
|
|
8137
|
+
this.opentui.symbols.textBufferClear(buffer);
|
|
7232
8138
|
}
|
|
7233
8139
|
textBufferSetDefaultFg(buffer, fg2) {
|
|
7234
8140
|
const fgPtr = fg2 ? fg2.buffer : null;
|
|
@@ -7245,21 +8151,70 @@ class FFIRenderLib {
|
|
|
7245
8151
|
textBufferResetDefaults(buffer) {
|
|
7246
8152
|
this.opentui.symbols.textBufferResetDefaults(buffer);
|
|
7247
8153
|
}
|
|
7248
|
-
|
|
7249
|
-
const
|
|
7250
|
-
|
|
8154
|
+
textBufferRegisterMemBuffer(buffer, bytes, owned = false) {
|
|
8155
|
+
const result = this.opentui.symbols.textBufferRegisterMemBuffer(buffer, bytes, bytes.length, owned);
|
|
8156
|
+
if (result === 65535) {
|
|
8157
|
+
throw new Error("Failed to register memory buffer");
|
|
8158
|
+
}
|
|
8159
|
+
return result;
|
|
8160
|
+
}
|
|
8161
|
+
textBufferReplaceMemBuffer(buffer, memId, bytes, owned = false) {
|
|
8162
|
+
return this.opentui.symbols.textBufferReplaceMemBuffer(buffer, memId, bytes, bytes.length, owned);
|
|
8163
|
+
}
|
|
8164
|
+
textBufferClearMemRegistry(buffer) {
|
|
8165
|
+
this.opentui.symbols.textBufferClearMemRegistry(buffer);
|
|
7251
8166
|
}
|
|
7252
|
-
|
|
7253
|
-
this.opentui.symbols.
|
|
8167
|
+
textBufferSetTextFromMem(buffer, memId) {
|
|
8168
|
+
this.opentui.symbols.textBufferSetTextFromMem(buffer, memId);
|
|
8169
|
+
}
|
|
8170
|
+
textBufferLoadFile(buffer, path4) {
|
|
8171
|
+
const pathBytes = this.encoder.encode(path4);
|
|
8172
|
+
return this.opentui.symbols.textBufferLoadFile(buffer, pathBytes, pathBytes.length);
|
|
8173
|
+
}
|
|
8174
|
+
textBufferSetStyledText(buffer, chunks) {
|
|
8175
|
+
const nonEmptyChunks = chunks.filter((c) => c.text.length > 0);
|
|
8176
|
+
if (nonEmptyChunks.length === 0) {
|
|
8177
|
+
this.textBufferClear(buffer);
|
|
8178
|
+
return;
|
|
8179
|
+
}
|
|
8180
|
+
const chunksBuffer = StyledChunkStruct.packList(nonEmptyChunks);
|
|
8181
|
+
this.opentui.symbols.textBufferSetStyledText(buffer, ptr3(chunksBuffer), nonEmptyChunks.length);
|
|
7254
8182
|
}
|
|
7255
8183
|
textBufferGetLineCount(buffer) {
|
|
7256
8184
|
return this.opentui.symbols.textBufferGetLineCount(buffer);
|
|
7257
8185
|
}
|
|
7258
|
-
|
|
7259
|
-
|
|
8186
|
+
textBufferGetPlainText(buffer, outPtr, maxLen) {
|
|
8187
|
+
const result = this.opentui.symbols.textBufferGetPlainText(buffer, outPtr, maxLen);
|
|
8188
|
+
return typeof result === "bigint" ? Number(result) : result;
|
|
8189
|
+
}
|
|
8190
|
+
getPlainTextBytes(buffer, maxLength) {
|
|
8191
|
+
const outBuffer = new Uint8Array(maxLength);
|
|
8192
|
+
const actualLen = this.textBufferGetPlainText(buffer, ptr3(outBuffer), maxLength);
|
|
8193
|
+
if (actualLen === 0) {
|
|
8194
|
+
return null;
|
|
8195
|
+
}
|
|
8196
|
+
return outBuffer.slice(0, actualLen);
|
|
8197
|
+
}
|
|
8198
|
+
createTextBufferView(textBuffer) {
|
|
8199
|
+
const viewPtr = this.opentui.symbols.createTextBufferView(textBuffer);
|
|
8200
|
+
if (!viewPtr) {
|
|
8201
|
+
throw new Error("Failed to create TextBufferView");
|
|
8202
|
+
}
|
|
8203
|
+
return viewPtr;
|
|
8204
|
+
}
|
|
8205
|
+
destroyTextBufferView(view) {
|
|
8206
|
+
this.opentui.symbols.destroyTextBufferView(view);
|
|
8207
|
+
}
|
|
8208
|
+
textBufferViewSetSelection(view, start, end, bgColor, fgColor) {
|
|
8209
|
+
const bg2 = bgColor ? bgColor.buffer : null;
|
|
8210
|
+
const fg2 = fgColor ? fgColor.buffer : null;
|
|
8211
|
+
this.opentui.symbols.textBufferViewSetSelection(view, start, end, bg2, fg2);
|
|
7260
8212
|
}
|
|
7261
|
-
|
|
7262
|
-
|
|
8213
|
+
textBufferViewResetSelection(view) {
|
|
8214
|
+
this.opentui.symbols.textBufferViewResetSelection(view);
|
|
8215
|
+
}
|
|
8216
|
+
textBufferViewGetSelection(view) {
|
|
8217
|
+
const packedInfo = this.textBufferViewGetSelectionInfo(view);
|
|
7263
8218
|
if (packedInfo === 0xffff_ffff_ffff_ffffn) {
|
|
7264
8219
|
return null;
|
|
7265
8220
|
}
|
|
@@ -7267,92 +8222,381 @@ class FFIRenderLib {
|
|
|
7267
8222
|
const end = Number(packedInfo & 0xffff_ffffn);
|
|
7268
8223
|
return { start, end };
|
|
7269
8224
|
}
|
|
7270
|
-
|
|
7271
|
-
return this.opentui.symbols.
|
|
8225
|
+
textBufferViewGetSelectionInfo(view) {
|
|
8226
|
+
return this.opentui.symbols.textBufferViewGetSelectionInfo(view);
|
|
8227
|
+
}
|
|
8228
|
+
textBufferViewSetLocalSelection(view, anchorX, anchorY, focusX, focusY, bgColor, fgColor) {
|
|
8229
|
+
const bg2 = bgColor ? bgColor.buffer : null;
|
|
8230
|
+
const fg2 = fgColor ? fgColor.buffer : null;
|
|
8231
|
+
return this.opentui.symbols.textBufferViewSetLocalSelection(view, anchorX, anchorY, focusX, focusY, bg2, fg2);
|
|
8232
|
+
}
|
|
8233
|
+
textBufferViewResetLocalSelection(view) {
|
|
8234
|
+
this.opentui.symbols.textBufferViewResetLocalSelection(view);
|
|
8235
|
+
}
|
|
8236
|
+
textBufferViewSetWrapWidth(view, width) {
|
|
8237
|
+
this.opentui.symbols.textBufferViewSetWrapWidth(view, width);
|
|
8238
|
+
}
|
|
8239
|
+
textBufferViewSetWrapMode(view, mode) {
|
|
8240
|
+
const modeValue = mode === "none" ? 0 : mode === "char" ? 1 : 2;
|
|
8241
|
+
this.opentui.symbols.textBufferViewSetWrapMode(view, modeValue);
|
|
8242
|
+
}
|
|
8243
|
+
textBufferViewSetViewportSize(view, width, height) {
|
|
8244
|
+
this.opentui.symbols.textBufferViewSetViewportSize(view, width, height);
|
|
8245
|
+
}
|
|
8246
|
+
textBufferViewGetLineInfo(view) {
|
|
8247
|
+
const lineCount = this.textBufferViewGetLineCount(view);
|
|
8248
|
+
if (lineCount === 0) {
|
|
8249
|
+
return { lineStarts: [], lineWidths: [], maxLineWidth: 0 };
|
|
8250
|
+
}
|
|
8251
|
+
const lineStarts = new Uint32Array(lineCount);
|
|
8252
|
+
const lineWidths = new Uint32Array(lineCount);
|
|
8253
|
+
const maxLineWidth = this.textBufferViewGetLineInfoDirect(view, ptr3(lineStarts), ptr3(lineWidths));
|
|
8254
|
+
return {
|
|
8255
|
+
maxLineWidth,
|
|
8256
|
+
lineStarts: Array.from(lineStarts),
|
|
8257
|
+
lineWidths: Array.from(lineWidths)
|
|
8258
|
+
};
|
|
8259
|
+
}
|
|
8260
|
+
textBufferViewGetLogicalLineInfo(view) {
|
|
8261
|
+
const lineCount = this.textBufferViewGetLineCount(view);
|
|
8262
|
+
if (lineCount === 0) {
|
|
8263
|
+
return { lineStarts: [], lineWidths: [], maxLineWidth: 0 };
|
|
8264
|
+
}
|
|
8265
|
+
const lineStarts = new Uint32Array(lineCount);
|
|
8266
|
+
const lineWidths = new Uint32Array(lineCount);
|
|
8267
|
+
const maxLineWidth = this.textBufferViewGetLogicalLineInfoDirect(view, ptr3(lineStarts), ptr3(lineWidths));
|
|
8268
|
+
return {
|
|
8269
|
+
maxLineWidth,
|
|
8270
|
+
lineStarts: Array.from(lineStarts),
|
|
8271
|
+
lineWidths: Array.from(lineWidths)
|
|
8272
|
+
};
|
|
8273
|
+
}
|
|
8274
|
+
textBufferViewGetLineCount(view) {
|
|
8275
|
+
return this.opentui.symbols.textBufferViewGetVirtualLineCount(view);
|
|
7272
8276
|
}
|
|
7273
|
-
|
|
7274
|
-
|
|
8277
|
+
textBufferViewGetLineInfoDirect(view, lineStartsPtr, lineWidthsPtr) {
|
|
8278
|
+
return this.opentui.symbols.textBufferViewGetLineInfoDirect(view, lineStartsPtr, lineWidthsPtr);
|
|
8279
|
+
}
|
|
8280
|
+
textBufferViewGetLogicalLineInfoDirect(view, lineStartsPtr, lineWidthsPtr) {
|
|
8281
|
+
return this.opentui.symbols.textBufferViewGetLogicalLineInfoDirect(view, lineStartsPtr, lineWidthsPtr);
|
|
8282
|
+
}
|
|
8283
|
+
textBufferViewGetSelectedText(view, outPtr, maxLen) {
|
|
8284
|
+
const result = this.opentui.symbols.textBufferViewGetSelectedText(view, outPtr, maxLen);
|
|
7275
8285
|
return typeof result === "bigint" ? Number(result) : result;
|
|
7276
8286
|
}
|
|
7277
|
-
|
|
7278
|
-
const result = this.opentui.symbols.
|
|
8287
|
+
textBufferViewGetPlainText(view, outPtr, maxLen) {
|
|
8288
|
+
const result = this.opentui.symbols.textBufferViewGetPlainText(view, outPtr, maxLen);
|
|
7279
8289
|
return typeof result === "bigint" ? Number(result) : result;
|
|
7280
8290
|
}
|
|
7281
|
-
|
|
8291
|
+
textBufferViewGetSelectedTextBytes(view, maxLength) {
|
|
7282
8292
|
const outBuffer = new Uint8Array(maxLength);
|
|
7283
|
-
const actualLen = this.
|
|
8293
|
+
const actualLen = this.textBufferViewGetSelectedText(view, ptr3(outBuffer), maxLength);
|
|
7284
8294
|
if (actualLen === 0) {
|
|
7285
8295
|
return null;
|
|
7286
8296
|
}
|
|
7287
8297
|
return outBuffer.slice(0, actualLen);
|
|
7288
8298
|
}
|
|
7289
|
-
|
|
8299
|
+
textBufferViewGetPlainTextBytes(view, maxLength) {
|
|
7290
8300
|
const outBuffer = new Uint8Array(maxLength);
|
|
7291
|
-
const actualLen = this.
|
|
8301
|
+
const actualLen = this.textBufferViewGetPlainText(view, ptr3(outBuffer), maxLength);
|
|
7292
8302
|
if (actualLen === 0) {
|
|
7293
8303
|
return null;
|
|
7294
8304
|
}
|
|
7295
8305
|
return outBuffer.slice(0, actualLen);
|
|
7296
8306
|
}
|
|
7297
|
-
|
|
7298
|
-
const
|
|
7299
|
-
|
|
7300
|
-
return this.opentui.symbols.textBufferSetLocalSelection(buffer, anchorX, anchorY, focusX, focusY, bg2, fg2);
|
|
8307
|
+
textBufferAddHighlightByCharRange(buffer, highlight) {
|
|
8308
|
+
const packedHighlight = HighlightStruct.pack(highlight);
|
|
8309
|
+
this.opentui.symbols.textBufferAddHighlightByCharRange(buffer, ptr3(packedHighlight));
|
|
7301
8310
|
}
|
|
7302
|
-
|
|
7303
|
-
|
|
8311
|
+
textBufferAddHighlight(buffer, lineIdx, highlight) {
|
|
8312
|
+
const packedHighlight = HighlightStruct.pack(highlight);
|
|
8313
|
+
this.opentui.symbols.textBufferAddHighlight(buffer, lineIdx, ptr3(packedHighlight));
|
|
7304
8314
|
}
|
|
7305
|
-
|
|
7306
|
-
|
|
7307
|
-
const bgPtr = bg2 ? bg2.buffer : null;
|
|
7308
|
-
const attr = attributes ?? 255;
|
|
7309
|
-
return this.opentui.symbols.textBufferInsertChunkGroup(buffer, index, textBytes, textBytes.length, fgPtr, bgPtr, attr);
|
|
8315
|
+
textBufferRemoveHighlightsByRef(buffer, hlRef) {
|
|
8316
|
+
this.opentui.symbols.textBufferRemoveHighlightsByRef(buffer, hlRef);
|
|
7310
8317
|
}
|
|
7311
|
-
|
|
7312
|
-
|
|
8318
|
+
textBufferClearLineHighlights(buffer, lineIdx) {
|
|
8319
|
+
this.opentui.symbols.textBufferClearLineHighlights(buffer, lineIdx);
|
|
7313
8320
|
}
|
|
7314
|
-
|
|
7315
|
-
|
|
7316
|
-
const bgPtr = bg2 ? bg2.buffer : null;
|
|
7317
|
-
const attr = attributes ?? 255;
|
|
7318
|
-
return this.opentui.symbols.textBufferReplaceChunkGroup(buffer, index, textBytes, textBytes.length, fgPtr, bgPtr, attr);
|
|
7319
|
-
}
|
|
7320
|
-
textBufferGetChunkGroupCount(buffer) {
|
|
7321
|
-
const result = this.opentui.symbols.textBufferGetChunkGroupCount(buffer);
|
|
7322
|
-
return typeof result === "bigint" ? Number(result) : result;
|
|
8321
|
+
textBufferClearAllHighlights(buffer) {
|
|
8322
|
+
this.opentui.symbols.textBufferClearAllHighlights(buffer);
|
|
7323
8323
|
}
|
|
7324
|
-
|
|
7325
|
-
this.opentui.symbols.
|
|
8324
|
+
textBufferSetSyntaxStyle(buffer, style) {
|
|
8325
|
+
this.opentui.symbols.textBufferSetSyntaxStyle(buffer, style);
|
|
7326
8326
|
}
|
|
7327
|
-
|
|
7328
|
-
const
|
|
7329
|
-
this.opentui.symbols.
|
|
8327
|
+
textBufferGetLineHighlights(buffer, lineIdx) {
|
|
8328
|
+
const outCountBuf = new BigUint64Array(1);
|
|
8329
|
+
const nativePtr = this.opentui.symbols.textBufferGetLineHighlightsPtr(buffer, lineIdx, ptr3(outCountBuf));
|
|
8330
|
+
if (!nativePtr)
|
|
8331
|
+
return [];
|
|
8332
|
+
const count = Number(outCountBuf[0]);
|
|
8333
|
+
const byteLen = count * HighlightStruct.size;
|
|
8334
|
+
const raw = toArrayBuffer4(nativePtr, 0, byteLen);
|
|
8335
|
+
const results = HighlightStruct.unpackList(raw, count);
|
|
8336
|
+
this.opentui.symbols.textBufferFreeLineHighlights(nativePtr, count);
|
|
8337
|
+
return results;
|
|
7330
8338
|
}
|
|
7331
8339
|
getArenaAllocatedBytes() {
|
|
7332
8340
|
const result = this.opentui.symbols.getArenaAllocatedBytes();
|
|
7333
8341
|
return typeof result === "bigint" ? Number(result) : result;
|
|
7334
8342
|
}
|
|
7335
|
-
|
|
7336
|
-
|
|
7337
|
-
|
|
7338
|
-
|
|
8343
|
+
bufferDrawTextBufferView(buffer, view, x, y) {
|
|
8344
|
+
this.opentui.symbols.bufferDrawTextBufferView(buffer, view, x, y);
|
|
8345
|
+
}
|
|
8346
|
+
bufferDrawEditorView(buffer, view, x, y) {
|
|
8347
|
+
this.opentui.symbols.bufferDrawEditorView(buffer, view, x, y);
|
|
8348
|
+
}
|
|
8349
|
+
createEditorView(editBufferPtr, viewportWidth, viewportHeight) {
|
|
8350
|
+
const viewPtr = this.opentui.symbols.createEditorView(editBufferPtr, viewportWidth, viewportHeight);
|
|
8351
|
+
if (!viewPtr) {
|
|
8352
|
+
throw new Error("Failed to create EditorView");
|
|
7339
8353
|
}
|
|
7340
|
-
|
|
7341
|
-
|
|
7342
|
-
|
|
8354
|
+
return viewPtr;
|
|
8355
|
+
}
|
|
8356
|
+
destroyEditorView(view) {
|
|
8357
|
+
this.opentui.symbols.destroyEditorView(view);
|
|
8358
|
+
}
|
|
8359
|
+
editorViewSetViewportSize(view, width, height) {
|
|
8360
|
+
this.opentui.symbols.editorViewSetViewportSize(view, width, height);
|
|
8361
|
+
}
|
|
8362
|
+
editorViewGetViewport(view) {
|
|
8363
|
+
const x = new Uint32Array(1);
|
|
8364
|
+
const y = new Uint32Array(1);
|
|
8365
|
+
const width = new Uint32Array(1);
|
|
8366
|
+
const height = new Uint32Array(1);
|
|
8367
|
+
this.opentui.symbols.editorViewGetViewport(view, ptr3(x), ptr3(y), ptr3(width), ptr3(height));
|
|
7343
8368
|
return {
|
|
7344
|
-
|
|
7345
|
-
|
|
7346
|
-
|
|
8369
|
+
offsetX: x[0],
|
|
8370
|
+
offsetY: y[0],
|
|
8371
|
+
width: width[0],
|
|
8372
|
+
height: height[0]
|
|
8373
|
+
};
|
|
8374
|
+
}
|
|
8375
|
+
editorViewSetScrollMargin(view, margin) {
|
|
8376
|
+
this.opentui.symbols.editorViewSetScrollMargin(view, margin);
|
|
8377
|
+
}
|
|
8378
|
+
editorViewSetWrapMode(view, mode) {
|
|
8379
|
+
const modeValue = mode === "none" ? 0 : mode === "char" ? 1 : 2;
|
|
8380
|
+
this.opentui.symbols.editorViewSetWrapMode(view, modeValue);
|
|
8381
|
+
}
|
|
8382
|
+
editorViewGetVirtualLineCount(view) {
|
|
8383
|
+
return this.opentui.symbols.editorViewGetVirtualLineCount(view);
|
|
8384
|
+
}
|
|
8385
|
+
editorViewGetTotalVirtualLineCount(view) {
|
|
8386
|
+
return this.opentui.symbols.editorViewGetTotalVirtualLineCount(view);
|
|
8387
|
+
}
|
|
8388
|
+
editorViewGetTextBufferView(view) {
|
|
8389
|
+
const result = this.opentui.symbols.editorViewGetTextBufferView(view);
|
|
8390
|
+
if (!result) {
|
|
8391
|
+
throw new Error("Failed to get TextBufferView from EditorView");
|
|
8392
|
+
}
|
|
8393
|
+
return result;
|
|
8394
|
+
}
|
|
8395
|
+
createEditBuffer(widthMethod) {
|
|
8396
|
+
const widthMethodCode = widthMethod === "wcwidth" ? 0 : 1;
|
|
8397
|
+
const bufferPtr = this.opentui.symbols.createEditBuffer(widthMethodCode);
|
|
8398
|
+
if (!bufferPtr) {
|
|
8399
|
+
throw new Error("Failed to create EditBuffer");
|
|
8400
|
+
}
|
|
8401
|
+
return bufferPtr;
|
|
8402
|
+
}
|
|
8403
|
+
destroyEditBuffer(buffer) {
|
|
8404
|
+
this.opentui.symbols.destroyEditBuffer(buffer);
|
|
8405
|
+
}
|
|
8406
|
+
editBufferSetText(buffer, textBytes, retainHistory = true) {
|
|
8407
|
+
this.opentui.symbols.editBufferSetText(buffer, textBytes, textBytes.length, retainHistory);
|
|
8408
|
+
}
|
|
8409
|
+
editBufferSetTextFromMem(buffer, memId, retainHistory = true) {
|
|
8410
|
+
this.opentui.symbols.editBufferSetTextFromMem(buffer, memId, retainHistory);
|
|
8411
|
+
}
|
|
8412
|
+
editBufferGetText(buffer, maxLength) {
|
|
8413
|
+
const outBuffer = new Uint8Array(maxLength);
|
|
8414
|
+
const actualLen = this.opentui.symbols.editBufferGetText(buffer, ptr3(outBuffer), maxLength);
|
|
8415
|
+
const len = typeof actualLen === "bigint" ? Number(actualLen) : actualLen;
|
|
8416
|
+
if (len === 0)
|
|
8417
|
+
return null;
|
|
8418
|
+
return outBuffer.slice(0, len);
|
|
8419
|
+
}
|
|
8420
|
+
editBufferInsertChar(buffer, char) {
|
|
8421
|
+
const charBytes = this.encoder.encode(char);
|
|
8422
|
+
this.opentui.symbols.editBufferInsertChar(buffer, charBytes, charBytes.length);
|
|
8423
|
+
}
|
|
8424
|
+
editBufferInsertText(buffer, text) {
|
|
8425
|
+
const textBytes = this.encoder.encode(text);
|
|
8426
|
+
this.opentui.symbols.editBufferInsertText(buffer, textBytes, textBytes.length);
|
|
8427
|
+
}
|
|
8428
|
+
editBufferDeleteChar(buffer) {
|
|
8429
|
+
this.opentui.symbols.editBufferDeleteChar(buffer);
|
|
8430
|
+
}
|
|
8431
|
+
editBufferDeleteCharBackward(buffer) {
|
|
8432
|
+
this.opentui.symbols.editBufferDeleteCharBackward(buffer);
|
|
8433
|
+
}
|
|
8434
|
+
editBufferNewLine(buffer) {
|
|
8435
|
+
this.opentui.symbols.editBufferNewLine(buffer);
|
|
8436
|
+
}
|
|
8437
|
+
editBufferDeleteLine(buffer) {
|
|
8438
|
+
this.opentui.symbols.editBufferDeleteLine(buffer);
|
|
8439
|
+
}
|
|
8440
|
+
editBufferMoveCursorLeft(buffer) {
|
|
8441
|
+
this.opentui.symbols.editBufferMoveCursorLeft(buffer);
|
|
8442
|
+
}
|
|
8443
|
+
editBufferMoveCursorRight(buffer) {
|
|
8444
|
+
this.opentui.symbols.editBufferMoveCursorRight(buffer);
|
|
8445
|
+
}
|
|
8446
|
+
editBufferMoveCursorUp(buffer) {
|
|
8447
|
+
this.opentui.symbols.editBufferMoveCursorUp(buffer);
|
|
8448
|
+
}
|
|
8449
|
+
editBufferMoveCursorDown(buffer) {
|
|
8450
|
+
this.opentui.symbols.editBufferMoveCursorDown(buffer);
|
|
8451
|
+
}
|
|
8452
|
+
editBufferGotoLine(buffer, line) {
|
|
8453
|
+
this.opentui.symbols.editBufferGotoLine(buffer, line);
|
|
8454
|
+
}
|
|
8455
|
+
editBufferSetCursor(buffer, line, byteOffset) {
|
|
8456
|
+
this.opentui.symbols.editBufferSetCursor(buffer, line, byteOffset);
|
|
8457
|
+
}
|
|
8458
|
+
editBufferSetCursorToLineCol(buffer, line, col) {
|
|
8459
|
+
this.opentui.symbols.editBufferSetCursorToLineCol(buffer, line, col);
|
|
8460
|
+
}
|
|
8461
|
+
editBufferSetCursorByOffset(buffer, offset) {
|
|
8462
|
+
this.opentui.symbols.editBufferSetCursorByOffset(buffer, offset);
|
|
8463
|
+
}
|
|
8464
|
+
editBufferGetCursorPosition(buffer) {
|
|
8465
|
+
const line = new Uint32Array(1);
|
|
8466
|
+
const visualColumn = new Uint32Array(1);
|
|
8467
|
+
const offset = new Uint32Array(1);
|
|
8468
|
+
this.opentui.symbols.editBufferGetCursorPosition(buffer, ptr3(line), ptr3(visualColumn), ptr3(offset));
|
|
8469
|
+
return {
|
|
8470
|
+
line: line[0],
|
|
8471
|
+
visualColumn: visualColumn[0],
|
|
8472
|
+
offset: offset[0]
|
|
8473
|
+
};
|
|
8474
|
+
}
|
|
8475
|
+
editBufferGetId(buffer) {
|
|
8476
|
+
return this.opentui.symbols.editBufferGetId(buffer);
|
|
8477
|
+
}
|
|
8478
|
+
editBufferGetTextBuffer(buffer) {
|
|
8479
|
+
const result = this.opentui.symbols.editBufferGetTextBuffer(buffer);
|
|
8480
|
+
if (!result) {
|
|
8481
|
+
throw new Error("Failed to get TextBuffer from EditBuffer");
|
|
8482
|
+
}
|
|
8483
|
+
return result;
|
|
8484
|
+
}
|
|
8485
|
+
editBufferDebugLogRope(buffer) {
|
|
8486
|
+
this.opentui.symbols.editBufferDebugLogRope(buffer);
|
|
8487
|
+
}
|
|
8488
|
+
editBufferUndo(buffer, maxLength) {
|
|
8489
|
+
const outBuffer = new Uint8Array(maxLength);
|
|
8490
|
+
const actualLen = this.opentui.symbols.editBufferUndo(buffer, ptr3(outBuffer), maxLength);
|
|
8491
|
+
const len = typeof actualLen === "bigint" ? Number(actualLen) : actualLen;
|
|
8492
|
+
if (len === 0)
|
|
8493
|
+
return null;
|
|
8494
|
+
return outBuffer.slice(0, len);
|
|
8495
|
+
}
|
|
8496
|
+
editBufferRedo(buffer, maxLength) {
|
|
8497
|
+
const outBuffer = new Uint8Array(maxLength);
|
|
8498
|
+
const actualLen = this.opentui.symbols.editBufferRedo(buffer, ptr3(outBuffer), maxLength);
|
|
8499
|
+
const len = typeof actualLen === "bigint" ? Number(actualLen) : actualLen;
|
|
8500
|
+
if (len === 0)
|
|
8501
|
+
return null;
|
|
8502
|
+
return outBuffer.slice(0, len);
|
|
8503
|
+
}
|
|
8504
|
+
editBufferCanUndo(buffer) {
|
|
8505
|
+
return this.opentui.symbols.editBufferCanUndo(buffer);
|
|
8506
|
+
}
|
|
8507
|
+
editBufferCanRedo(buffer) {
|
|
8508
|
+
return this.opentui.symbols.editBufferCanRedo(buffer);
|
|
8509
|
+
}
|
|
8510
|
+
editBufferClearHistory(buffer) {
|
|
8511
|
+
this.opentui.symbols.editBufferClearHistory(buffer);
|
|
8512
|
+
}
|
|
8513
|
+
editBufferSetPlaceholder(buffer, text) {
|
|
8514
|
+
if (text === null) {
|
|
8515
|
+
this.opentui.symbols.editBufferSetPlaceholder(buffer, null, 0);
|
|
8516
|
+
} else {
|
|
8517
|
+
const textBytes = this.encoder.encode(text);
|
|
8518
|
+
this.opentui.symbols.editBufferSetPlaceholder(buffer, textBytes, textBytes.length);
|
|
8519
|
+
}
|
|
8520
|
+
}
|
|
8521
|
+
editBufferSetPlaceholderColor(buffer, color) {
|
|
8522
|
+
this.opentui.symbols.editBufferSetPlaceholderColor(buffer, color.buffer);
|
|
8523
|
+
}
|
|
8524
|
+
editorViewSetSelection(view, start, end, bgColor, fgColor) {
|
|
8525
|
+
const bg2 = bgColor ? bgColor.buffer : null;
|
|
8526
|
+
const fg2 = fgColor ? fgColor.buffer : null;
|
|
8527
|
+
this.opentui.symbols.editorViewSetSelection(view, start, end, bg2, fg2);
|
|
8528
|
+
}
|
|
8529
|
+
editorViewResetSelection(view) {
|
|
8530
|
+
this.opentui.symbols.editorViewResetSelection(view);
|
|
8531
|
+
}
|
|
8532
|
+
editorViewGetSelection(view) {
|
|
8533
|
+
const packedInfo = this.opentui.symbols.editorViewGetSelection(view);
|
|
8534
|
+
if (packedInfo === 0xffff_ffff_ffff_ffffn) {
|
|
8535
|
+
return null;
|
|
8536
|
+
}
|
|
8537
|
+
const start = Number(packedInfo >> 32n);
|
|
8538
|
+
const end = Number(packedInfo & 0xffff_ffffn);
|
|
8539
|
+
return { start, end };
|
|
8540
|
+
}
|
|
8541
|
+
editorViewSetLocalSelection(view, anchorX, anchorY, focusX, focusY, bgColor, fgColor) {
|
|
8542
|
+
const bg2 = bgColor ? bgColor.buffer : null;
|
|
8543
|
+
const fg2 = fgColor ? fgColor.buffer : null;
|
|
8544
|
+
return this.opentui.symbols.editorViewSetLocalSelection(view, anchorX, anchorY, focusX, focusY, bg2, fg2);
|
|
8545
|
+
}
|
|
8546
|
+
editorViewResetLocalSelection(view) {
|
|
8547
|
+
this.opentui.symbols.editorViewResetLocalSelection(view);
|
|
8548
|
+
}
|
|
8549
|
+
editorViewGetSelectedTextBytes(view, maxLength) {
|
|
8550
|
+
const outBuffer = new Uint8Array(maxLength);
|
|
8551
|
+
const actualLen = this.opentui.symbols.editorViewGetSelectedTextBytes(view, ptr3(outBuffer), maxLength);
|
|
8552
|
+
const len = typeof actualLen === "bigint" ? Number(actualLen) : actualLen;
|
|
8553
|
+
if (len === 0)
|
|
8554
|
+
return null;
|
|
8555
|
+
return outBuffer.slice(0, len);
|
|
8556
|
+
}
|
|
8557
|
+
editorViewGetCursor(view) {
|
|
8558
|
+
const row = new Uint32Array(1);
|
|
8559
|
+
const col = new Uint32Array(1);
|
|
8560
|
+
this.opentui.symbols.editorViewGetCursor(view, ptr3(row), ptr3(col));
|
|
8561
|
+
return { row: row[0], col: col[0] };
|
|
8562
|
+
}
|
|
8563
|
+
editorViewGetText(view, maxLength) {
|
|
8564
|
+
const outBuffer = new Uint8Array(maxLength);
|
|
8565
|
+
const actualLen = this.opentui.symbols.editorViewGetText(view, ptr3(outBuffer), maxLength);
|
|
8566
|
+
const len = typeof actualLen === "bigint" ? Number(actualLen) : actualLen;
|
|
8567
|
+
if (len === 0)
|
|
8568
|
+
return null;
|
|
8569
|
+
return outBuffer.slice(0, len);
|
|
8570
|
+
}
|
|
8571
|
+
editorViewGetVisualCursor(view) {
|
|
8572
|
+
const visualRow = new Uint32Array(1);
|
|
8573
|
+
const visualCol = new Uint32Array(1);
|
|
8574
|
+
const logicalRow = new Uint32Array(1);
|
|
8575
|
+
const logicalCol = new Uint32Array(1);
|
|
8576
|
+
const offset = new Uint32Array(1);
|
|
8577
|
+
const success = this.opentui.symbols.editorViewGetVisualCursor(view, ptr3(visualRow), ptr3(visualCol), ptr3(logicalRow), ptr3(logicalCol), ptr3(offset));
|
|
8578
|
+
if (!success) {
|
|
8579
|
+
return { visualRow: 0, visualCol: 0, logicalRow: 0, logicalCol: 0, offset: 0 };
|
|
8580
|
+
}
|
|
8581
|
+
return {
|
|
8582
|
+
visualRow: visualRow[0],
|
|
8583
|
+
visualCol: visualCol[0],
|
|
8584
|
+
logicalRow: logicalRow[0],
|
|
8585
|
+
logicalCol: logicalCol[0],
|
|
8586
|
+
offset: offset[0]
|
|
7347
8587
|
};
|
|
7348
8588
|
}
|
|
7349
|
-
|
|
7350
|
-
|
|
7351
|
-
|
|
7352
|
-
|
|
7353
|
-
|
|
7354
|
-
|
|
7355
|
-
|
|
8589
|
+
editorViewMoveUpVisual(view) {
|
|
8590
|
+
this.opentui.symbols.editorViewMoveUpVisual(view);
|
|
8591
|
+
}
|
|
8592
|
+
editorViewMoveDownVisual(view) {
|
|
8593
|
+
this.opentui.symbols.editorViewMoveDownVisual(view);
|
|
8594
|
+
}
|
|
8595
|
+
editorViewDeleteSelectedText(view) {
|
|
8596
|
+
this.opentui.symbols.editorViewDeleteSelectedText(view);
|
|
8597
|
+
}
|
|
8598
|
+
editorViewSetCursorByOffset(view, offset) {
|
|
8599
|
+
this.opentui.symbols.editorViewSetCursorByOffset(view, offset);
|
|
7356
8600
|
}
|
|
7357
8601
|
bufferPushScissorRect(buffer, x, y, width, height) {
|
|
7358
8602
|
this.opentui.symbols.bufferPushScissorRect(buffer, x, y, width, height);
|
|
@@ -7388,6 +8632,43 @@ class FFIRenderLib {
|
|
|
7388
8632
|
const responseBytes = this.encoder.encode(response);
|
|
7389
8633
|
this.opentui.symbols.processCapabilityResponse(renderer, responseBytes, responseBytes.length);
|
|
7390
8634
|
}
|
|
8635
|
+
createSyntaxStyle() {
|
|
8636
|
+
const stylePtr = this.opentui.symbols.createSyntaxStyle();
|
|
8637
|
+
if (!stylePtr) {
|
|
8638
|
+
throw new Error("Failed to create SyntaxStyle");
|
|
8639
|
+
}
|
|
8640
|
+
return stylePtr;
|
|
8641
|
+
}
|
|
8642
|
+
destroySyntaxStyle(style) {
|
|
8643
|
+
this.opentui.symbols.destroySyntaxStyle(style);
|
|
8644
|
+
}
|
|
8645
|
+
syntaxStyleRegister(style, name, fg2, bg2, attributes) {
|
|
8646
|
+
const nameBytes = this.encoder.encode(name);
|
|
8647
|
+
const fgPtr = fg2 ? fg2.buffer : null;
|
|
8648
|
+
const bgPtr = bg2 ? bg2.buffer : null;
|
|
8649
|
+
return this.opentui.symbols.syntaxStyleRegister(style, nameBytes, nameBytes.length, fgPtr, bgPtr, attributes);
|
|
8650
|
+
}
|
|
8651
|
+
syntaxStyleResolveByName(style, name) {
|
|
8652
|
+
const nameBytes = this.encoder.encode(name);
|
|
8653
|
+
const id = this.opentui.symbols.syntaxStyleResolveByName(style, nameBytes, nameBytes.length);
|
|
8654
|
+
return id === 0 ? null : id;
|
|
8655
|
+
}
|
|
8656
|
+
syntaxStyleGetStyleCount(style) {
|
|
8657
|
+
const result = this.opentui.symbols.syntaxStyleGetStyleCount(style);
|
|
8658
|
+
return typeof result === "bigint" ? Number(result) : result;
|
|
8659
|
+
}
|
|
8660
|
+
onNativeEvent(name, handler) {
|
|
8661
|
+
this._nativeEvents.on(name, handler);
|
|
8662
|
+
}
|
|
8663
|
+
onceNativeEvent(name, handler) {
|
|
8664
|
+
this._nativeEvents.once(name, handler);
|
|
8665
|
+
}
|
|
8666
|
+
offNativeEvent(name, handler) {
|
|
8667
|
+
this._nativeEvents.off(name, handler);
|
|
8668
|
+
}
|
|
8669
|
+
onAnyNativeEvent(handler) {
|
|
8670
|
+
this._anyEventHandlers.push(handler);
|
|
8671
|
+
}
|
|
7391
8672
|
}
|
|
7392
8673
|
var opentuiLibPath;
|
|
7393
8674
|
var opentuiLib;
|
|
@@ -7416,11 +8697,15 @@ class TextBuffer {
|
|
|
7416
8697
|
lib;
|
|
7417
8698
|
bufferPtr;
|
|
7418
8699
|
_length = 0;
|
|
8700
|
+
_byteSize = 0;
|
|
7419
8701
|
_lineInfo;
|
|
7420
8702
|
_destroyed = false;
|
|
7421
|
-
|
|
8703
|
+
_syntaxStyle;
|
|
8704
|
+
_textBytes;
|
|
8705
|
+
_memId;
|
|
8706
|
+
constructor(lib, ptr4) {
|
|
7422
8707
|
this.lib = lib;
|
|
7423
|
-
this.bufferPtr =
|
|
8708
|
+
this.bufferPtr = ptr4;
|
|
7424
8709
|
}
|
|
7425
8710
|
static create(widthMethod) {
|
|
7426
8711
|
const lib = resolveRenderLib();
|
|
@@ -7430,17 +8715,42 @@ class TextBuffer {
|
|
|
7430
8715
|
if (this._destroyed)
|
|
7431
8716
|
throw new Error("TextBuffer is destroyed");
|
|
7432
8717
|
}
|
|
7433
|
-
|
|
8718
|
+
setText(text) {
|
|
7434
8719
|
this.guard();
|
|
7435
|
-
this.lib.
|
|
7436
|
-
this.
|
|
8720
|
+
this._textBytes = this.lib.encoder.encode(text);
|
|
8721
|
+
if (this._memId === undefined) {
|
|
8722
|
+
this._memId = this.lib.textBufferRegisterMemBuffer(this.bufferPtr, this._textBytes, false);
|
|
8723
|
+
} else {
|
|
8724
|
+
this.lib.textBufferReplaceMemBuffer(this.bufferPtr, this._memId, this._textBytes, false);
|
|
8725
|
+
}
|
|
8726
|
+
this.lib.textBufferSetTextFromMem(this.bufferPtr, this._memId);
|
|
8727
|
+
this._length = this.lib.textBufferGetLength(this.bufferPtr);
|
|
8728
|
+
this._byteSize = this.lib.textBufferGetByteSize(this.bufferPtr);
|
|
7437
8729
|
this._lineInfo = undefined;
|
|
7438
|
-
|
|
7439
|
-
|
|
7440
|
-
|
|
8730
|
+
}
|
|
8731
|
+
loadFile(path4) {
|
|
8732
|
+
this.guard();
|
|
8733
|
+
const success = this.lib.textBufferLoadFile(this.bufferPtr, path4);
|
|
8734
|
+
if (!success) {
|
|
8735
|
+
throw new Error(`Failed to load file: ${path4}`);
|
|
7441
8736
|
}
|
|
7442
|
-
this.lib.textBufferFinalizeLineInfo(this.bufferPtr);
|
|
7443
8737
|
this._length = this.lib.textBufferGetLength(this.bufferPtr);
|
|
8738
|
+
this._byteSize = this.lib.textBufferGetByteSize(this.bufferPtr);
|
|
8739
|
+
this._lineInfo = undefined;
|
|
8740
|
+
this._textBytes = undefined;
|
|
8741
|
+
}
|
|
8742
|
+
setStyledText(text) {
|
|
8743
|
+
this.guard();
|
|
8744
|
+
const chunks = text.chunks.map((chunk) => ({
|
|
8745
|
+
text: chunk.text,
|
|
8746
|
+
fg: chunk.fg || null,
|
|
8747
|
+
bg: chunk.bg || null,
|
|
8748
|
+
attributes: chunk.attributes ?? 0
|
|
8749
|
+
}));
|
|
8750
|
+
this.lib.textBufferSetStyledText(this.bufferPtr, chunks);
|
|
8751
|
+
this._length = this.lib.textBufferGetLength(this.bufferPtr);
|
|
8752
|
+
this._byteSize = this.lib.textBufferGetByteSize(this.bufferPtr);
|
|
8753
|
+
this._lineInfo = undefined;
|
|
7444
8754
|
}
|
|
7445
8755
|
setDefaultFg(fg2) {
|
|
7446
8756
|
this.guard();
|
|
@@ -7462,97 +8772,72 @@ class TextBuffer {
|
|
|
7462
8772
|
this.guard();
|
|
7463
8773
|
return this._length;
|
|
7464
8774
|
}
|
|
7465
|
-
get
|
|
8775
|
+
get byteSize() {
|
|
7466
8776
|
this.guard();
|
|
7467
|
-
return this.
|
|
8777
|
+
return this._byteSize;
|
|
7468
8778
|
}
|
|
7469
|
-
|
|
8779
|
+
get ptr() {
|
|
7470
8780
|
this.guard();
|
|
7471
|
-
|
|
7472
|
-
return "";
|
|
7473
|
-
const selectedBytes = this.lib.getSelectedTextBytes(this.bufferPtr, this.length * 4);
|
|
7474
|
-
if (!selectedBytes)
|
|
7475
|
-
return "";
|
|
7476
|
-
return this.lib.decoder.decode(selectedBytes);
|
|
8781
|
+
return this.bufferPtr;
|
|
7477
8782
|
}
|
|
7478
8783
|
getPlainText() {
|
|
7479
8784
|
this.guard();
|
|
7480
|
-
if (this.
|
|
8785
|
+
if (this._byteSize === 0)
|
|
7481
8786
|
return "";
|
|
7482
|
-
const plainBytes = this.lib.getPlainTextBytes(this.bufferPtr, this.
|
|
8787
|
+
const plainBytes = this.lib.getPlainTextBytes(this.bufferPtr, this._byteSize);
|
|
7483
8788
|
if (!plainBytes)
|
|
7484
8789
|
return "";
|
|
7485
8790
|
return this.lib.decoder.decode(plainBytes);
|
|
7486
8791
|
}
|
|
7487
|
-
|
|
8792
|
+
addHighlightByCharRange(highlight) {
|
|
7488
8793
|
this.guard();
|
|
7489
|
-
|
|
7490
|
-
this._lineInfo = this.lib.textBufferGetLineInfo(this.bufferPtr);
|
|
7491
|
-
}
|
|
7492
|
-
return this._lineInfo;
|
|
8794
|
+
this.lib.textBufferAddHighlightByCharRange(this.bufferPtr, highlight);
|
|
7493
8795
|
}
|
|
7494
|
-
|
|
8796
|
+
addHighlight(lineIdx, highlight) {
|
|
7495
8797
|
this.guard();
|
|
7496
|
-
this.lib.
|
|
8798
|
+
this.lib.textBufferAddHighlight(this.bufferPtr, lineIdx, highlight);
|
|
7497
8799
|
}
|
|
7498
|
-
|
|
8800
|
+
removeHighlightsByRef(hlRef) {
|
|
7499
8801
|
this.guard();
|
|
7500
|
-
this.lib.
|
|
8802
|
+
this.lib.textBufferRemoveHighlightsByRef(this.bufferPtr, hlRef);
|
|
7501
8803
|
}
|
|
7502
|
-
|
|
8804
|
+
clearLineHighlights(lineIdx) {
|
|
7503
8805
|
this.guard();
|
|
7504
|
-
|
|
8806
|
+
this.lib.textBufferClearLineHighlights(this.bufferPtr, lineIdx);
|
|
7505
8807
|
}
|
|
7506
|
-
|
|
8808
|
+
clearAllHighlights() {
|
|
7507
8809
|
this.guard();
|
|
7508
|
-
this.lib.
|
|
7509
|
-
}
|
|
7510
|
-
getSelection() {
|
|
7511
|
-
this.guard();
|
|
7512
|
-
return this.lib.textBufferGetSelection(this.bufferPtr);
|
|
7513
|
-
}
|
|
7514
|
-
hasSelection() {
|
|
7515
|
-
this.guard();
|
|
7516
|
-
return this.getSelection() !== null;
|
|
7517
|
-
}
|
|
7518
|
-
insertChunkGroup(index, text, fg2, bg2, attributes) {
|
|
7519
|
-
this.guard();
|
|
7520
|
-
const textBytes = this.lib.encoder.encode(text);
|
|
7521
|
-
this.insertEncodedChunkGroup(index, textBytes, fg2, bg2, attributes);
|
|
7522
|
-
}
|
|
7523
|
-
insertEncodedChunkGroup(index, textBytes, fg2, bg2, attributes) {
|
|
7524
|
-
this.guard();
|
|
7525
|
-
this._length = this.lib.textBufferInsertChunkGroup(this.bufferPtr, index, textBytes, fg2 || null, bg2 || null, attributes ?? null);
|
|
7526
|
-
this._lineInfo = undefined;
|
|
7527
|
-
}
|
|
7528
|
-
removeChunkGroup(index) {
|
|
7529
|
-
this.guard();
|
|
7530
|
-
this._length = this.lib.textBufferRemoveChunkGroup(this.bufferPtr, index);
|
|
7531
|
-
this._lineInfo = undefined;
|
|
8810
|
+
this.lib.textBufferClearAllHighlights(this.bufferPtr);
|
|
7532
8811
|
}
|
|
7533
|
-
|
|
8812
|
+
getLineHighlights(lineIdx) {
|
|
7534
8813
|
this.guard();
|
|
7535
|
-
|
|
7536
|
-
this.replaceEncodedChunkGroup(index, textBytes, fg2, bg2, attributes);
|
|
8814
|
+
return this.lib.textBufferGetLineHighlights(this.bufferPtr, lineIdx);
|
|
7537
8815
|
}
|
|
7538
|
-
|
|
8816
|
+
setSyntaxStyle(style) {
|
|
7539
8817
|
this.guard();
|
|
7540
|
-
this.
|
|
7541
|
-
this.
|
|
8818
|
+
this._syntaxStyle = style ?? undefined;
|
|
8819
|
+
this.lib.textBufferSetSyntaxStyle(this.bufferPtr, style?.ptr ?? null);
|
|
7542
8820
|
}
|
|
7543
|
-
|
|
8821
|
+
getSyntaxStyle() {
|
|
7544
8822
|
this.guard();
|
|
7545
|
-
return this.
|
|
8823
|
+
return this._syntaxStyle ?? null;
|
|
7546
8824
|
}
|
|
7547
|
-
|
|
8825
|
+
clear() {
|
|
7548
8826
|
this.guard();
|
|
7549
|
-
this.lib.
|
|
8827
|
+
this.lib.textBufferClear(this.bufferPtr);
|
|
8828
|
+
this._length = 0;
|
|
8829
|
+
this._byteSize = 0;
|
|
7550
8830
|
this._lineInfo = undefined;
|
|
8831
|
+
this._textBytes = undefined;
|
|
7551
8832
|
}
|
|
7552
|
-
|
|
8833
|
+
reset() {
|
|
7553
8834
|
this.guard();
|
|
7554
|
-
this.lib.
|
|
8835
|
+
this.lib.textBufferReset(this.bufferPtr);
|
|
8836
|
+
this._length = 0;
|
|
8837
|
+
this._byteSize = 0;
|
|
7555
8838
|
this._lineInfo = undefined;
|
|
8839
|
+
this._textBytes = undefined;
|
|
8840
|
+
this._memId = undefined;
|
|
7556
8841
|
}
|
|
7557
8842
|
destroy() {
|
|
7558
8843
|
if (this._destroyed)
|
|
@@ -7563,7 +8848,7 @@ class TextBuffer {
|
|
|
7563
8848
|
}
|
|
7564
8849
|
|
|
7565
8850
|
// src/Renderable.ts
|
|
7566
|
-
import { EventEmitter as
|
|
8851
|
+
import { EventEmitter as EventEmitter5 } from "events";
|
|
7567
8852
|
|
|
7568
8853
|
// src/lib/renderable.validations.ts
|
|
7569
8854
|
function validateOptions(id, options) {
|
|
@@ -7656,7 +8941,7 @@ function isRenderable(obj) {
|
|
|
7656
8941
|
return !!obj?.[BrandedRenderable];
|
|
7657
8942
|
}
|
|
7658
8943
|
|
|
7659
|
-
class BaseRenderable extends
|
|
8944
|
+
class BaseRenderable extends EventEmitter5 {
|
|
7660
8945
|
[BrandedRenderable] = true;
|
|
7661
8946
|
static renderableNumber = 1;
|
|
7662
8947
|
_id;
|
|
@@ -7728,6 +9013,7 @@ class Renderable extends BaseRenderable {
|
|
|
7728
9013
|
_positionType = "relative";
|
|
7729
9014
|
_overflow = "visible";
|
|
7730
9015
|
_position = {};
|
|
9016
|
+
_flexShrink = 1;
|
|
7731
9017
|
renderableMapById = new Map;
|
|
7732
9018
|
_childrenInLayoutOrder = [];
|
|
7733
9019
|
_childrenInZIndexOrder = [];
|
|
@@ -7974,6 +9260,10 @@ class Renderable extends BaseRenderable {
|
|
|
7974
9260
|
if (isDimensionType(value)) {
|
|
7975
9261
|
this._width = value;
|
|
7976
9262
|
this.yogaNode.setWidth(value);
|
|
9263
|
+
if (typeof value === "number" && this._flexShrink === 1) {
|
|
9264
|
+
this._flexShrink = 0;
|
|
9265
|
+
this.yogaNode.setFlexShrink(0);
|
|
9266
|
+
}
|
|
7977
9267
|
this.requestRender();
|
|
7978
9268
|
}
|
|
7979
9269
|
}
|
|
@@ -7984,6 +9274,10 @@ class Renderable extends BaseRenderable {
|
|
|
7984
9274
|
if (isDimensionType(value)) {
|
|
7985
9275
|
this._height = value;
|
|
7986
9276
|
this.yogaNode.setHeight(value);
|
|
9277
|
+
if (typeof value === "number" && this._flexShrink === 1) {
|
|
9278
|
+
this._flexShrink = 0;
|
|
9279
|
+
this.yogaNode.setFlexShrink(0);
|
|
9280
|
+
}
|
|
7987
9281
|
this.requestRender();
|
|
7988
9282
|
}
|
|
7989
9283
|
}
|
|
@@ -8038,9 +9332,13 @@ class Renderable extends BaseRenderable {
|
|
|
8038
9332
|
node.setFlexGrow(0);
|
|
8039
9333
|
}
|
|
8040
9334
|
if (options.flexShrink !== undefined) {
|
|
9335
|
+
this._flexShrink = options.flexShrink;
|
|
8041
9336
|
node.setFlexShrink(options.flexShrink);
|
|
8042
9337
|
} else {
|
|
8043
|
-
|
|
9338
|
+
const hasExplicitWidth = typeof options.width === "number";
|
|
9339
|
+
const hasExplicitHeight = typeof options.height === "number";
|
|
9340
|
+
this._flexShrink = hasExplicitWidth || hasExplicitHeight ? 0 : 1;
|
|
9341
|
+
node.setFlexShrink(this._flexShrink);
|
|
8044
9342
|
}
|
|
8045
9343
|
if (options.flexDirection !== undefined) {
|
|
8046
9344
|
node.setFlexDirection(parseFlexDirection(options.flexDirection));
|
|
@@ -8185,11 +9483,17 @@ class Renderable extends BaseRenderable {
|
|
|
8185
9483
|
this.requestRender();
|
|
8186
9484
|
}
|
|
8187
9485
|
set flexGrow(grow) {
|
|
8188
|
-
|
|
9486
|
+
if (grow == null) {
|
|
9487
|
+
this.yogaNode.setFlexGrow(0);
|
|
9488
|
+
} else {
|
|
9489
|
+
this.yogaNode.setFlexGrow(grow);
|
|
9490
|
+
}
|
|
8189
9491
|
this.requestRender();
|
|
8190
9492
|
}
|
|
8191
9493
|
set flexShrink(shrink) {
|
|
8192
|
-
|
|
9494
|
+
const value = shrink == null ? 1 : shrink;
|
|
9495
|
+
this._flexShrink = value;
|
|
9496
|
+
this.yogaNode.setFlexShrink(value);
|
|
8193
9497
|
this.requestRender();
|
|
8194
9498
|
}
|
|
8195
9499
|
set flexDirection(direction) {
|
|
@@ -8958,7 +10262,7 @@ function delegate(mapping, vnode) {
|
|
|
8958
10262
|
}
|
|
8959
10263
|
|
|
8960
10264
|
// src/console.ts
|
|
8961
|
-
import { EventEmitter as
|
|
10265
|
+
import { EventEmitter as EventEmitter7 } from "events";
|
|
8962
10266
|
import { Console } from "console";
|
|
8963
10267
|
import fs from "fs";
|
|
8964
10268
|
import path4 from "path";
|
|
@@ -8966,9 +10270,9 @@ import util2 from "util";
|
|
|
8966
10270
|
|
|
8967
10271
|
// src/lib/output.capture.ts
|
|
8968
10272
|
import { Writable } from "stream";
|
|
8969
|
-
import { EventEmitter as
|
|
10273
|
+
import { EventEmitter as EventEmitter6 } from "events";
|
|
8970
10274
|
|
|
8971
|
-
class Capture extends
|
|
10275
|
+
class Capture extends EventEmitter6 {
|
|
8972
10276
|
output = [];
|
|
8973
10277
|
constructor() {
|
|
8974
10278
|
super();
|
|
@@ -9044,11 +10348,12 @@ registerEnvVar({
|
|
|
9044
10348
|
default: false
|
|
9045
10349
|
});
|
|
9046
10350
|
|
|
9047
|
-
class TerminalConsoleCache extends
|
|
10351
|
+
class TerminalConsoleCache extends EventEmitter7 {
|
|
9048
10352
|
_cachedLogs = [];
|
|
9049
10353
|
MAX_CACHE_SIZE = 1000;
|
|
9050
10354
|
_collectCallerInfo = false;
|
|
9051
10355
|
_cachingEnabled = true;
|
|
10356
|
+
_originalConsole = null;
|
|
9052
10357
|
get cachedLogs() {
|
|
9053
10358
|
return this._cachedLogs;
|
|
9054
10359
|
}
|
|
@@ -9056,6 +10361,9 @@ class TerminalConsoleCache extends EventEmitter6 {
|
|
|
9056
10361
|
super();
|
|
9057
10362
|
}
|
|
9058
10363
|
activate() {
|
|
10364
|
+
if (!this._originalConsole) {
|
|
10365
|
+
this._originalConsole = global.console;
|
|
10366
|
+
}
|
|
9059
10367
|
this.setupConsoleCapture();
|
|
9060
10368
|
this.overrideConsoleMethods();
|
|
9061
10369
|
}
|
|
@@ -9105,8 +10413,9 @@ class TerminalConsoleCache extends EventEmitter6 {
|
|
|
9105
10413
|
this.restoreOriginalConsole();
|
|
9106
10414
|
}
|
|
9107
10415
|
restoreOriginalConsole() {
|
|
9108
|
-
|
|
9109
|
-
|
|
10416
|
+
if (this._originalConsole) {
|
|
10417
|
+
global.console = this._originalConsole;
|
|
10418
|
+
}
|
|
9110
10419
|
this.setupConsoleCapture();
|
|
9111
10420
|
}
|
|
9112
10421
|
addLogEntry(level, ...args) {
|
|
@@ -9165,7 +10474,7 @@ var DEFAULT_CONSOLE_OPTIONS = {
|
|
|
9165
10474
|
};
|
|
9166
10475
|
var INDENT_WIDTH = 2;
|
|
9167
10476
|
|
|
9168
|
-
class TerminalConsole extends
|
|
10477
|
+
class TerminalConsole extends EventEmitter7 {
|
|
9169
10478
|
isVisible = false;
|
|
9170
10479
|
isFocused = false;
|
|
9171
10480
|
renderer;
|
|
@@ -9625,7 +10934,7 @@ class TerminalConsole extends EventEmitter6 {
|
|
|
9625
10934
|
}
|
|
9626
10935
|
|
|
9627
10936
|
// src/renderer.ts
|
|
9628
|
-
import { EventEmitter as
|
|
10937
|
+
import { EventEmitter as EventEmitter8 } from "events";
|
|
9629
10938
|
|
|
9630
10939
|
// src/lib/objects-in-viewport.ts
|
|
9631
10940
|
function getObjectsInViewport(viewport, objects, direction = "column", padding = 10, minTriggerSize = 16) {
|
|
@@ -9661,24 +10970,39 @@ function getObjectsInViewport(viewport, objects, direction = "column", padding =
|
|
|
9661
10970
|
}
|
|
9662
10971
|
const visibleChildren = [];
|
|
9663
10972
|
if (candidate === -1) {
|
|
9664
|
-
|
|
10973
|
+
candidate = lo > 0 ? lo - 1 : 0;
|
|
9665
10974
|
}
|
|
10975
|
+
const maxLookBehind = 50;
|
|
9666
10976
|
let left = candidate;
|
|
10977
|
+
let gapCount = 0;
|
|
9667
10978
|
while (left - 1 >= 0) {
|
|
9668
10979
|
const prev = children[left - 1];
|
|
9669
|
-
|
|
9670
|
-
|
|
10980
|
+
const prevEnd = isRow ? prev.x + prev.width : prev.y + prev.height;
|
|
10981
|
+
if (prevEnd <= vpStart) {
|
|
10982
|
+
gapCount++;
|
|
10983
|
+
if (gapCount >= maxLookBehind) {
|
|
10984
|
+
break;
|
|
10985
|
+
}
|
|
10986
|
+
} else {
|
|
10987
|
+
gapCount = 0;
|
|
10988
|
+
}
|
|
9671
10989
|
left--;
|
|
9672
10990
|
}
|
|
9673
10991
|
let right = candidate + 1;
|
|
9674
10992
|
while (right < totalChildren) {
|
|
9675
10993
|
const next = children[right];
|
|
9676
|
-
if ((isRow ? next.x : next.y)
|
|
10994
|
+
if ((isRow ? next.x : next.y) >= vpEnd)
|
|
9677
10995
|
break;
|
|
9678
10996
|
right++;
|
|
9679
10997
|
}
|
|
9680
10998
|
for (let i = left;i < right; i++) {
|
|
9681
10999
|
const child = children[i];
|
|
11000
|
+
const start = isRow ? child.x : child.y;
|
|
11001
|
+
const end = isRow ? child.x + child.width : child.y + child.height;
|
|
11002
|
+
if (end <= vpStart)
|
|
11003
|
+
continue;
|
|
11004
|
+
if (start >= vpEnd)
|
|
11005
|
+
break;
|
|
9682
11006
|
if (isRow) {
|
|
9683
11007
|
const childBottom = child.y + child.height;
|
|
9684
11008
|
if (childBottom < viewportTop)
|
|
@@ -9836,7 +11160,7 @@ var RendererControlState;
|
|
|
9836
11160
|
RendererControlState2["EXPLICIT_STOPPED"] = "explicit_stopped";
|
|
9837
11161
|
})(RendererControlState ||= {});
|
|
9838
11162
|
|
|
9839
|
-
class CliRenderer extends
|
|
11163
|
+
class CliRenderer extends EventEmitter8 {
|
|
9840
11164
|
static animationFrameId = 0;
|
|
9841
11165
|
lib;
|
|
9842
11166
|
rendererPtr;
|
|
@@ -10086,7 +11410,7 @@ Captured output:
|
|
|
10086
11410
|
}
|
|
10087
11411
|
get widthMethod() {
|
|
10088
11412
|
const caps = this.capabilities;
|
|
10089
|
-
return caps?.unicode === "
|
|
11413
|
+
return caps?.unicode === "wcwidth" ? "wcwidth" : "unicode";
|
|
10090
11414
|
}
|
|
10091
11415
|
writeOut(chunk, encoding, callback) {
|
|
10092
11416
|
return this.realStdoutWrite.call(this.stdout, chunk, encoding, callback);
|
|
@@ -10852,10 +12176,12 @@ Captured output:
|
|
|
10852
12176
|
}
|
|
10853
12177
|
this.selectionContainers = [];
|
|
10854
12178
|
}
|
|
10855
|
-
startSelection(
|
|
12179
|
+
startSelection(renderable, x, y) {
|
|
12180
|
+
if (!renderable.selectable)
|
|
12181
|
+
return;
|
|
10856
12182
|
this.clearSelection();
|
|
10857
|
-
this.selectionContainers.push(
|
|
10858
|
-
this.currentSelection = new Selection(
|
|
12183
|
+
this.selectionContainers.push(renderable.parent || this.root);
|
|
12184
|
+
this.currentSelection = new Selection(renderable, { x, y }, { x, y });
|
|
10859
12185
|
this.notifySelectablesOfSelectionChange();
|
|
10860
12186
|
}
|
|
10861
12187
|
updateSelection(currentRenderable, x, y) {
|
|
@@ -10935,7 +12261,7 @@ Captured output:
|
|
|
10935
12261
|
}
|
|
10936
12262
|
}
|
|
10937
12263
|
|
|
10938
|
-
export { __toESM, __commonJS, __export, __require, Edge, Gutter, exports_src, BorderChars, getBorderFromSides, getBorderSides, borderCharsToArray, BorderCharArrays, nonAlphanumericKeys, parseKeypress, ANSI, KeyEvent, PasteEvent, KeyHandler, InternalKeyHandler, RGBA, hexToRgb, rgbToHex, hsvToRgb, parseColor, fonts, measureText, getCharacterPositions, coordinateToCharacterIndex, renderFontToFrameBuffer, TextAttributes, DebugOverlayCorner, createTextAttributes, visualizeRenderableTree, isStyledText, StyledText, stringToStyledText, black, red, green, yellow, blue, magenta, cyan, white, brightBlack, brightRed, brightGreen, brightYellow, brightBlue, brightMagenta, brightCyan, brightWhite, bgBlack, bgRed, bgGreen, bgYellow, bgBlue, bgMagenta, bgCyan, bgWhite, bold, italic, underline, strikethrough, dim, reverse, blink, fg, bg, t,
|
|
12264
|
+
export { __toESM, __commonJS, __export, __require, Edge, Gutter, exports_src, BorderChars, getBorderFromSides, getBorderSides, borderCharsToArray, BorderCharArrays, nonAlphanumericKeys, parseKeypress, ANSI, KeyEvent, PasteEvent, KeyHandler, InternalKeyHandler, RGBA, hexToRgb, rgbToHex, hsvToRgb, parseColor, fonts, measureText, getCharacterPositions, coordinateToCharacterIndex, renderFontToFrameBuffer, TextAttributes, DebugOverlayCorner, createTextAttributes, visualizeRenderableTree, isStyledText, StyledText, stringToStyledText, black, red, green, yellow, blue, magenta, cyan, white, brightBlack, brightRed, brightGreen, brightYellow, brightBlue, brightMagenta, brightCyan, brightWhite, bgBlack, bgRed, bgGreen, bgYellow, bgBlue, bgMagenta, bgCyan, bgWhite, bold, italic, underline, strikethrough, dim, reverse, blink, fg, bg, t, hastToStyledText, LinearScrollAccel, MacOSScrollAccel, parseAlign, parseBoxSizing, parseDimension, parseDirection, parseDisplay, parseEdge, parseFlexDirection, parseGutter, parseJustify, parseLogLevel, parseMeasureMode, parseOverflow, parsePositionType, parseUnit, parseWrap, MouseParser, Selection, convertGlobalToLocalSelection, ASCIIFontSelectionHelper, envRegistry, registerEnvVar, clearEnvCache, generateEnvMarkdown, generateEnvColored, env, treeSitterToTextChunks, treeSitterToStyledText, addDefaultParsers, TreeSitterClient, DataPathsManager, getDataPaths, extToFiletype, pathToFiletype, main, getTreeSitterClient, TextBuffer, LogLevel2 as LogLevel, setRenderLibPath, resolveRenderLib, OptimizedBuffer, h, isVNode, maybeMakeRenderable, wrapWithDelegates, instantiate, delegate, isValidPercentage, LayoutEvents, RenderableEvents, isRenderable, BaseRenderable, Renderable, RootRenderable, capture, ConsolePosition, TerminalConsole, getObjectsInViewport, MouseEvent, MouseButton, createCliRenderer, CliRenderEvents, RendererControlState, CliRenderer };
|
|
10939
12265
|
|
|
10940
|
-
//# debugId=
|
|
10941
|
-
//# sourceMappingURL=index-
|
|
12266
|
+
//# debugId=13370E63AB96DC2264756E2164756E21
|
|
12267
|
+
//# sourceMappingURL=index-bztetjc3.js.map
|