@opentui/core 0.2.0 → 0.2.2
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/NativeSpanFeed.d.ts +2 -2
- package/README.md +2 -1
- package/buffer.d.ts +3 -3
- package/edit-buffer.d.ts +1 -1
- package/editor-view.d.ts +1 -1
- package/{index-mch6dv67.js → index-d07rkqtc.js} +252 -37
- package/{index-mch6dv67.js.map → index-d07rkqtc.js.map} +5 -5
- package/{index-mw2x3082.js → index-jv9g79dk.js} +694 -237
- package/{index-mw2x3082.js.map → index-jv9g79dk.js.map} +16 -15
- package/index-p147fdyc.js +44 -0
- package/index-p147fdyc.js.map +10 -0
- package/{index-epp5y71w.js → index-yedf4bn5.js} +3 -3
- package/index.js +2 -2
- package/lib/clipboard.d.ts +1 -1
- package/lib/terminal-palette.d.ts +12 -5
- package/package.json +14 -20
- package/platform/ffi.d.ts +64 -2
- package/renderer.d.ts +10 -4
- package/runtime-plugin-support-configure.d.ts +4 -0
- package/runtime-plugin-support-configure.js +18 -0
- package/runtime-plugin-support-configure.js.map +9 -0
- package/runtime-plugin-support.d.ts +3 -3
- package/runtime-plugin-support.js +7 -16
- package/runtime-plugin-support.js.map +3 -3
- package/runtime-plugin.js +3 -3
- package/syntax-style.d.ts +1 -1
- package/testing.js +1 -1
- package/text-buffer-view.d.ts +1 -1
- package/text-buffer.d.ts +1 -1
- package/zig-structs.d.ts +2 -2
- package/zig.d.ts +1 -1
- package/3d/SpriteResourceManager.d.ts +0 -74
- package/3d/SpriteUtils.d.ts +0 -13
- package/3d/TextureUtils.d.ts +0 -24
- package/3d/ThreeRenderable.d.ts +0 -40
- package/3d/WGPURenderer.d.ts +0 -61
- package/3d/animation/ExplodingSpriteEffect.d.ts +0 -71
- package/3d/animation/PhysicsExplodingSpriteEffect.d.ts +0 -76
- package/3d/animation/SpriteAnimator.d.ts +0 -124
- package/3d/animation/SpriteParticleGenerator.d.ts +0 -62
- package/3d/canvas.d.ts +0 -44
- package/3d/index.d.ts +0 -12
- package/3d/physics/PlanckPhysicsAdapter.d.ts +0 -19
- package/3d/physics/RapierPhysicsAdapter.d.ts +0 -19
- package/3d/physics/physics-interface.d.ts +0 -27
- package/3d.d.ts +0 -2
- package/3d.js +0 -34041
- package/3d.js.map +0 -155
- /package/{index-epp5y71w.js.map → index-yedf4bn5.js.map} +0 -0
|
@@ -1,35 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
4
2
|
var __defProp = Object.defineProperty;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
function __accessProp(key) {
|
|
8
|
-
return this[key];
|
|
9
|
-
}
|
|
10
|
-
var __toESMCache_node;
|
|
11
|
-
var __toESMCache_esm;
|
|
12
|
-
var __toESM = (mod, isNodeMode, target) => {
|
|
13
|
-
var canCache = mod != null && typeof mod === "object";
|
|
14
|
-
if (canCache) {
|
|
15
|
-
var cache = isNodeMode ? __toESMCache_node ??= new WeakMap : __toESMCache_esm ??= new WeakMap;
|
|
16
|
-
var cached = cache.get(mod);
|
|
17
|
-
if (cached)
|
|
18
|
-
return cached;
|
|
19
|
-
}
|
|
20
|
-
target = mod != null ? __create(__getProtoOf(mod)) : {};
|
|
21
|
-
const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
|
|
22
|
-
for (let key of __getOwnPropNames(mod))
|
|
23
|
-
if (!__hasOwnProp.call(to, key))
|
|
24
|
-
__defProp(to, key, {
|
|
25
|
-
get: __accessProp.bind(mod, key),
|
|
26
|
-
enumerable: true
|
|
27
|
-
});
|
|
28
|
-
if (canCache)
|
|
29
|
-
cache.set(mod, to);
|
|
30
|
-
return to;
|
|
31
|
-
};
|
|
32
|
-
var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
33
3
|
var __returnValue = (v) => v;
|
|
34
4
|
function __exportSetter(name, newValue) {
|
|
35
5
|
this[name] = __returnValue.bind(null, newValue);
|
|
@@ -10492,6 +10462,12 @@ function createExtmarksController(editBuffer, editorView) {
|
|
|
10492
10462
|
|
|
10493
10463
|
// src/lib/terminal-palette.ts
|
|
10494
10464
|
var SYSTEM_CLOCK2 = new SystemClock;
|
|
10465
|
+
registerEnvVar({
|
|
10466
|
+
name: "OTUI_PALETTE_IDLE_TIMEOUT_MS",
|
|
10467
|
+
description: "Milliseconds of silence after palette queries before using fallback colors.",
|
|
10468
|
+
type: "number",
|
|
10469
|
+
default: 300
|
|
10470
|
+
});
|
|
10495
10471
|
var OSC4_RESPONSE = /\x1b]4;(\d+);(?:(?:rgb:)([0-9a-fA-F]+)\/([0-9a-fA-F]+)\/([0-9a-fA-F]+)|#([0-9a-fA-F]{6}))(?:\x07|\x1b\\)/g;
|
|
10496
10472
|
var OSC_SPECIAL_RESPONSE = /\x1b](\d+);(?:(?:rgb:)([0-9a-fA-F]+)\/([0-9a-fA-F]+)\/([0-9a-fA-F]+)|#([0-9a-fA-F]{6}))(?:\x07|\x1b\\)/g;
|
|
10497
10473
|
function scaleComponent(comp) {
|
|
@@ -10517,18 +10493,21 @@ class TerminalPalette {
|
|
|
10517
10493
|
writeFn;
|
|
10518
10494
|
activeQuerySessions = [];
|
|
10519
10495
|
inLegacyTmux;
|
|
10496
|
+
inTmux;
|
|
10520
10497
|
oscSource;
|
|
10521
10498
|
clock;
|
|
10522
|
-
constructor(
|
|
10499
|
+
constructor(options) {
|
|
10500
|
+
const { stdin, stdout, writeFn, isLegacyTmux, isTmux, oscSource, clock } = options;
|
|
10523
10501
|
this.stdin = stdin;
|
|
10524
10502
|
this.stdout = stdout;
|
|
10525
10503
|
this.writeFn = writeFn || ((data) => stdout.write(data));
|
|
10526
10504
|
this.inLegacyTmux = isLegacyTmux ?? false;
|
|
10505
|
+
this.inTmux = isTmux ?? this.inLegacyTmux;
|
|
10527
10506
|
this.oscSource = oscSource;
|
|
10528
10507
|
this.clock = clock ?? SYSTEM_CLOCK2;
|
|
10529
10508
|
}
|
|
10530
|
-
writeOsc(osc) {
|
|
10531
|
-
const data = this.inLegacyTmux ? wrapForTmux(osc) : osc;
|
|
10509
|
+
writeOsc(osc, wrapForLegacyTmux = false) {
|
|
10510
|
+
const data = wrapForLegacyTmux && this.inLegacyTmux ? wrapForTmux(osc) : osc;
|
|
10532
10511
|
return this.writeFn(data);
|
|
10533
10512
|
}
|
|
10534
10513
|
cleanup() {
|
|
@@ -10623,10 +10602,10 @@ class TerminalPalette {
|
|
|
10623
10602
|
finish(false);
|
|
10624
10603
|
}, timeoutMs);
|
|
10625
10604
|
session.subscribeInput(onData);
|
|
10626
|
-
this.writeOsc("\x1B]4;0;?\x07");
|
|
10605
|
+
this.writeOsc("\x1B]4;0;?\x07", true);
|
|
10627
10606
|
});
|
|
10628
10607
|
}
|
|
10629
|
-
async queryPalette(indices, timeoutMs = 1200) {
|
|
10608
|
+
async queryPalette(indices, timeoutMs = 1200, idleTimeoutMs = env.OTUI_PALETTE_IDLE_TIMEOUT_MS) {
|
|
10630
10609
|
const out = this.stdout;
|
|
10631
10610
|
const results = new Map;
|
|
10632
10611
|
indices.forEach((i) => results.set(i, null));
|
|
@@ -10661,14 +10640,15 @@ class TerminalPalette {
|
|
|
10661
10640
|
finish();
|
|
10662
10641
|
return;
|
|
10663
10642
|
}
|
|
10664
|
-
idleTimer = session.resetTimer(idleTimer, finish,
|
|
10643
|
+
idleTimer = session.resetTimer(idleTimer, finish, idleTimeoutMs);
|
|
10665
10644
|
};
|
|
10666
10645
|
session.setTimer(finish, timeoutMs);
|
|
10667
10646
|
session.subscribeInput(onData);
|
|
10668
|
-
this.writeOsc(indices.map((i) => `\x1B]4;${i};?\x07`).join(""));
|
|
10647
|
+
this.writeOsc(indices.map((i) => `\x1B]4;${i};?\x07`).join(""), true);
|
|
10648
|
+
idleTimer = session.resetTimer(idleTimer, finish, idleTimeoutMs);
|
|
10669
10649
|
});
|
|
10670
10650
|
}
|
|
10671
|
-
async querySpecialColors(timeoutMs = 1200) {
|
|
10651
|
+
async querySpecialColors(timeoutMs = 1200, idleTimeoutMs = env.OTUI_PALETTE_IDLE_TIMEOUT_MS) {
|
|
10672
10652
|
const out = this.stdout;
|
|
10673
10653
|
const results = {
|
|
10674
10654
|
10: null,
|
|
@@ -10681,6 +10661,7 @@ class TerminalPalette {
|
|
|
10681
10661
|
17: null,
|
|
10682
10662
|
19: null
|
|
10683
10663
|
};
|
|
10664
|
+
const queries = this.inTmux ? [10, 11, 12] : [10, 11, 12, 13, 14, 15, 16, 17, 19];
|
|
10684
10665
|
if (!out.isTTY || !this.stdin.isTTY) {
|
|
10685
10666
|
return results;
|
|
10686
10667
|
}
|
|
@@ -10710,28 +10691,18 @@ class TerminalPalette {
|
|
|
10710
10691
|
}
|
|
10711
10692
|
if (buffer.length > 8192)
|
|
10712
10693
|
buffer = buffer.slice(-4096);
|
|
10713
|
-
|
|
10714
|
-
if (done === Object.keys(results).length) {
|
|
10694
|
+
if (queries.every((idx) => results[idx] !== null)) {
|
|
10715
10695
|
finish();
|
|
10716
10696
|
return;
|
|
10717
10697
|
}
|
|
10718
10698
|
if (!updated)
|
|
10719
10699
|
return;
|
|
10720
|
-
idleTimer = session.resetTimer(idleTimer, finish,
|
|
10700
|
+
idleTimer = session.resetTimer(idleTimer, finish, idleTimeoutMs);
|
|
10721
10701
|
};
|
|
10722
10702
|
session.setTimer(finish, timeoutMs);
|
|
10723
10703
|
session.subscribeInput(onData);
|
|
10724
|
-
this.writeOsc(
|
|
10725
|
-
|
|
10726
|
-
"\x1B]11;?\x07",
|
|
10727
|
-
"\x1B]12;?\x07",
|
|
10728
|
-
"\x1B]13;?\x07",
|
|
10729
|
-
"\x1B]14;?\x07",
|
|
10730
|
-
"\x1B]15;?\x07",
|
|
10731
|
-
"\x1B]16;?\x07",
|
|
10732
|
-
"\x1B]17;?\x07",
|
|
10733
|
-
"\x1B]19;?\x07"
|
|
10734
|
-
].join(""));
|
|
10704
|
+
this.writeOsc(queries.map((idx) => `\x1B]${idx};?\x07`).join(""));
|
|
10705
|
+
idleTimer = session.resetTimer(idleTimer, finish, idleTimeoutMs);
|
|
10735
10706
|
});
|
|
10736
10707
|
}
|
|
10737
10708
|
async detect(options) {
|
|
@@ -10752,9 +10723,10 @@ class TerminalPalette {
|
|
|
10752
10723
|
};
|
|
10753
10724
|
}
|
|
10754
10725
|
const indicesToQuery = [...Array(size).keys()];
|
|
10726
|
+
const idleTimeout = env.OTUI_PALETTE_IDLE_TIMEOUT_MS;
|
|
10755
10727
|
const [paletteResults, specialColors] = await Promise.all([
|
|
10756
|
-
this.queryPalette(indicesToQuery, timeout),
|
|
10757
|
-
this.querySpecialColors(timeout)
|
|
10728
|
+
this.queryPalette(indicesToQuery, timeout, idleTimeout),
|
|
10729
|
+
this.querySpecialColors(timeout, idleTimeout)
|
|
10758
10730
|
]);
|
|
10759
10731
|
return {
|
|
10760
10732
|
palette: [...Array(size).keys()].map((i) => paletteResults.get(i) ?? null),
|
|
@@ -10770,8 +10742,8 @@ class TerminalPalette {
|
|
|
10770
10742
|
};
|
|
10771
10743
|
}
|
|
10772
10744
|
}
|
|
10773
|
-
function createTerminalPalette(
|
|
10774
|
-
return new TerminalPalette(
|
|
10745
|
+
function createTerminalPalette(options) {
|
|
10746
|
+
return new TerminalPalette(options);
|
|
10775
10747
|
}
|
|
10776
10748
|
var DEFAULT_FOREGROUND_FALLBACK = RGBA.fromInts(...DEFAULT_FOREGROUND_RGB);
|
|
10777
10749
|
var DEFAULT_BACKGROUND_FALLBACK = RGBA.fromInts(...DEFAULT_BACKGROUND_RGB);
|
|
@@ -10856,13 +10828,351 @@ function detectLinks(chunks, context) {
|
|
|
10856
10828
|
}
|
|
10857
10829
|
return chunks;
|
|
10858
10830
|
}
|
|
10831
|
+
// src/platform/ffi.ts
|
|
10832
|
+
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
10833
|
+
var FFIType = {
|
|
10834
|
+
char: "char",
|
|
10835
|
+
int8_t: "int8_t",
|
|
10836
|
+
i8: "i8",
|
|
10837
|
+
uint8_t: "uint8_t",
|
|
10838
|
+
u8: "u8",
|
|
10839
|
+
int16_t: "int16_t",
|
|
10840
|
+
i16: "i16",
|
|
10841
|
+
uint16_t: "uint16_t",
|
|
10842
|
+
u16: "u16",
|
|
10843
|
+
int32_t: "int32_t",
|
|
10844
|
+
i32: "i32",
|
|
10845
|
+
int: "int",
|
|
10846
|
+
uint32_t: "uint32_t",
|
|
10847
|
+
u32: "u32",
|
|
10848
|
+
int64_t: "int64_t",
|
|
10849
|
+
i64: "i64",
|
|
10850
|
+
uint64_t: "uint64_t",
|
|
10851
|
+
u64: "u64",
|
|
10852
|
+
double: "double",
|
|
10853
|
+
f64: "f64",
|
|
10854
|
+
float: "float",
|
|
10855
|
+
f32: "f32",
|
|
10856
|
+
bool: "bool",
|
|
10857
|
+
ptr: "ptr",
|
|
10858
|
+
pointer: "pointer",
|
|
10859
|
+
void: "void",
|
|
10860
|
+
cstring: "cstring",
|
|
10861
|
+
function: "function",
|
|
10862
|
+
usize: "usize",
|
|
10863
|
+
callback: "callback",
|
|
10864
|
+
napi_env: "napi_env",
|
|
10865
|
+
napi_value: "napi_value",
|
|
10866
|
+
buffer: "buffer"
|
|
10867
|
+
};
|
|
10868
|
+
var FFI_UNAVAILABLE = "OpenTUI native FFI is not available for this runtime yet";
|
|
10869
|
+
var BUN_DLOPEN_NULL = "Bun FFI backend does not support dlopen(null)";
|
|
10870
|
+
var LIBRARY_CLOSED = "Cannot create FFI callback after library.close() has been called";
|
|
10871
|
+
var NODE_CALLBACK_THREADSAFE = "Node FFI callbacks are same-thread only and do not support threadsafe callbacks";
|
|
10872
|
+
var NODE_NAPI_UNSUPPORTED = "Node FFI backend does not support Bun N-API FFI types";
|
|
10873
|
+
var NODE_POINTER_OVERRIDE = "Node FFI backend does not support FFIFunction.ptr overrides";
|
|
10874
|
+
var NODE_PTR_VALUE = "node:ffi ptr() only supports ArrayBuffer and ArrayBufferView values backed by ArrayBuffer";
|
|
10875
|
+
var NODE_STRING_RETURN = "Node FFI backend does not normalize string return values (yet)";
|
|
10876
|
+
var NODE_USIZE_UNSUPPORTED = "Node FFI backend does not support usize until (yet)";
|
|
10877
|
+
var POINTER_NEGATIVE = "Pointer must be non-negative";
|
|
10878
|
+
var POINTER_UNSAFE = "Pointer exceeds safe integer range";
|
|
10879
|
+
function unavailable(cause) {
|
|
10880
|
+
throw new Error(FFI_UNAVAILABLE, { cause });
|
|
10881
|
+
}
|
|
10882
|
+
function createUnsupportedBackend(cause) {
|
|
10883
|
+
return {
|
|
10884
|
+
dlopen() {
|
|
10885
|
+
return unavailable(cause);
|
|
10886
|
+
},
|
|
10887
|
+
ptr() {
|
|
10888
|
+
return unavailable(cause);
|
|
10889
|
+
},
|
|
10890
|
+
suffix: "",
|
|
10891
|
+
toArrayBuffer() {
|
|
10892
|
+
return unavailable(cause);
|
|
10893
|
+
}
|
|
10894
|
+
};
|
|
10895
|
+
}
|
|
10896
|
+
var isBun = typeof process !== "undefined" && typeof process.versions === "object" && process.versions !== null && typeof process.versions.bun === "string";
|
|
10897
|
+
var backend = await loadBackend();
|
|
10898
|
+
function importModule(specifier) {
|
|
10899
|
+
return import(specifier);
|
|
10900
|
+
}
|
|
10901
|
+
async function loadBackend() {
|
|
10902
|
+
if (isBun) {
|
|
10903
|
+
return createBunBackend(await importModule("bun:ffi"));
|
|
10904
|
+
}
|
|
10905
|
+
try {
|
|
10906
|
+
const nodeFfi = await importModule("node:ffi");
|
|
10907
|
+
return createNodeBackend(nodeFfi.default ?? nodeFfi);
|
|
10908
|
+
} catch (error) {
|
|
10909
|
+
return createUnsupportedBackend(error);
|
|
10910
|
+
}
|
|
10911
|
+
}
|
|
10912
|
+
function toPointer(value) {
|
|
10913
|
+
if (isBun && typeof value === "bigint") {
|
|
10914
|
+
return toSafeNumberPointer(value);
|
|
10915
|
+
}
|
|
10916
|
+
if (!isBun && typeof value === "number") {
|
|
10917
|
+
return toSafeBigIntPointer(value);
|
|
10918
|
+
}
|
|
10919
|
+
return value;
|
|
10920
|
+
}
|
|
10921
|
+
function ffiBool(value) {
|
|
10922
|
+
return value ? 1 : 0;
|
|
10923
|
+
}
|
|
10924
|
+
function toSafeNumberPointer(pointer) {
|
|
10925
|
+
if (pointer < 0n) {
|
|
10926
|
+
throw new Error(POINTER_NEGATIVE);
|
|
10927
|
+
}
|
|
10928
|
+
if (pointer > BigInt(Number.MAX_SAFE_INTEGER)) {
|
|
10929
|
+
throw new Error(POINTER_UNSAFE);
|
|
10930
|
+
}
|
|
10931
|
+
return Number(pointer);
|
|
10932
|
+
}
|
|
10933
|
+
function toSafeBigIntPointer(pointer) {
|
|
10934
|
+
if (pointer < 0) {
|
|
10935
|
+
throw new Error(POINTER_NEGATIVE);
|
|
10936
|
+
}
|
|
10937
|
+
if (!Number.isSafeInteger(pointer)) {
|
|
10938
|
+
throw new Error(POINTER_UNSAFE);
|
|
10939
|
+
}
|
|
10940
|
+
return BigInt(pointer);
|
|
10941
|
+
}
|
|
10942
|
+
function createManagedCallback(raw, callbacks) {
|
|
10943
|
+
let ptr = raw.ptr;
|
|
10944
|
+
let closed = false;
|
|
10945
|
+
const instance = {
|
|
10946
|
+
get ptr() {
|
|
10947
|
+
return ptr;
|
|
10948
|
+
},
|
|
10949
|
+
get threadsafe() {
|
|
10950
|
+
return raw.threadsafe;
|
|
10951
|
+
},
|
|
10952
|
+
close() {
|
|
10953
|
+
if (closed) {
|
|
10954
|
+
return;
|
|
10955
|
+
}
|
|
10956
|
+
closed = true;
|
|
10957
|
+
callbacks.delete(instance);
|
|
10958
|
+
try {
|
|
10959
|
+
raw.close();
|
|
10960
|
+
} finally {
|
|
10961
|
+
ptr = null;
|
|
10962
|
+
}
|
|
10963
|
+
}
|
|
10964
|
+
};
|
|
10965
|
+
callbacks.add(instance);
|
|
10966
|
+
return instance;
|
|
10967
|
+
}
|
|
10968
|
+
function normalizeBunDefinitions(definitions) {
|
|
10969
|
+
return Object.fromEntries(Object.entries(definitions).map(([name, definition]) => [name, normalizeBunDefinition(definition)]));
|
|
10970
|
+
}
|
|
10971
|
+
function normalizeBunDefinition(definition) {
|
|
10972
|
+
return {
|
|
10973
|
+
args: definition.args,
|
|
10974
|
+
returns: definition.returns,
|
|
10975
|
+
ptr: definition.ptr == null ? undefined : toBunPointer(definition.ptr),
|
|
10976
|
+
threadsafe: definition.threadsafe
|
|
10977
|
+
};
|
|
10978
|
+
}
|
|
10979
|
+
function toBunPointer(pointer) {
|
|
10980
|
+
return typeof pointer === "bigint" ? toSafeNumberPointer(pointer) : pointer;
|
|
10981
|
+
}
|
|
10982
|
+
function createBunBackend(bun) {
|
|
10983
|
+
return {
|
|
10984
|
+
dlopen(path5, symbols) {
|
|
10985
|
+
if (path5 === null) {
|
|
10986
|
+
throw new Error(BUN_DLOPEN_NULL);
|
|
10987
|
+
}
|
|
10988
|
+
const library = bun.dlopen(path5, normalizeBunDefinitions(symbols));
|
|
10989
|
+
const callbacks = new Set;
|
|
10990
|
+
let closed = false;
|
|
10991
|
+
return {
|
|
10992
|
+
symbols: library.symbols,
|
|
10993
|
+
createCallback(callback, definition) {
|
|
10994
|
+
if (closed) {
|
|
10995
|
+
throw new Error(LIBRARY_CLOSED);
|
|
10996
|
+
}
|
|
10997
|
+
const raw = new bun.JSCallback(callback, normalizeBunDefinition(definition));
|
|
10998
|
+
return createManagedCallback(raw, callbacks);
|
|
10999
|
+
},
|
|
11000
|
+
close() {
|
|
11001
|
+
if (closed) {
|
|
11002
|
+
return;
|
|
11003
|
+
}
|
|
11004
|
+
closed = true;
|
|
11005
|
+
try {
|
|
11006
|
+
library.close();
|
|
11007
|
+
} finally {
|
|
11008
|
+
for (const callback of [...callbacks]) {
|
|
11009
|
+
callback.close();
|
|
11010
|
+
}
|
|
11011
|
+
}
|
|
11012
|
+
}
|
|
11013
|
+
};
|
|
11014
|
+
},
|
|
11015
|
+
ptr: bun.ptr,
|
|
11016
|
+
suffix: bun.suffix,
|
|
11017
|
+
toArrayBuffer(pointer, offset, length) {
|
|
11018
|
+
return bun.toArrayBuffer(toBunPointer(pointer), offset, length);
|
|
11019
|
+
}
|
|
11020
|
+
};
|
|
11021
|
+
}
|
|
11022
|
+
function createNodeBackend(nodeFfi) {
|
|
11023
|
+
return {
|
|
11024
|
+
dlopen(path5, symbols) {
|
|
11025
|
+
const { lib, functions } = nodeFfi.dlopen(toNodeLibraryPath(path5), normalizeNodeDefinitions(symbols));
|
|
11026
|
+
const callbacks = new Set;
|
|
11027
|
+
let closed = false;
|
|
11028
|
+
let libraryClosed = false;
|
|
11029
|
+
return {
|
|
11030
|
+
symbols: functions,
|
|
11031
|
+
createCallback(callback, definition) {
|
|
11032
|
+
if (closed) {
|
|
11033
|
+
throw new Error(LIBRARY_CLOSED);
|
|
11034
|
+
}
|
|
11035
|
+
if (definition.threadsafe) {
|
|
11036
|
+
throw new Error(NODE_CALLBACK_THREADSAFE);
|
|
11037
|
+
}
|
|
11038
|
+
const callbackPointer = lib.registerCallback(normalizeNodeDefinition(definition), callback);
|
|
11039
|
+
const raw = {
|
|
11040
|
+
ptr: callbackPointer,
|
|
11041
|
+
threadsafe: false,
|
|
11042
|
+
close() {
|
|
11043
|
+
if (!libraryClosed) {
|
|
11044
|
+
lib.unregisterCallback(callbackPointer);
|
|
11045
|
+
}
|
|
11046
|
+
}
|
|
11047
|
+
};
|
|
11048
|
+
return createManagedCallback(raw, callbacks);
|
|
11049
|
+
},
|
|
11050
|
+
close() {
|
|
11051
|
+
if (closed) {
|
|
11052
|
+
return;
|
|
11053
|
+
}
|
|
11054
|
+
closed = true;
|
|
11055
|
+
try {
|
|
11056
|
+
libraryClosed = true;
|
|
11057
|
+
lib.close();
|
|
11058
|
+
} finally {
|
|
11059
|
+
for (const callback of [...callbacks]) {
|
|
11060
|
+
callback.close();
|
|
11061
|
+
}
|
|
11062
|
+
}
|
|
11063
|
+
}
|
|
11064
|
+
};
|
|
11065
|
+
},
|
|
11066
|
+
ptr(value) {
|
|
11067
|
+
if (ArrayBuffer.isView(value)) {
|
|
11068
|
+
if (!(value.buffer instanceof ArrayBuffer)) {
|
|
11069
|
+
throw new TypeError(NODE_PTR_VALUE);
|
|
11070
|
+
}
|
|
11071
|
+
return nodeFfi.getRawPointer(value.buffer) + BigInt(value.byteOffset);
|
|
11072
|
+
}
|
|
11073
|
+
if (value instanceof ArrayBuffer) {
|
|
11074
|
+
return nodeFfi.getRawPointer(value);
|
|
11075
|
+
}
|
|
11076
|
+
throw new TypeError(NODE_PTR_VALUE);
|
|
11077
|
+
},
|
|
11078
|
+
suffix: nodeFfi.suffix,
|
|
11079
|
+
toArrayBuffer(pointer, offset, length) {
|
|
11080
|
+
return nodeFfi.toArrayBuffer(toBigIntPointer(pointer) + BigInt(offset ?? 0), length, false);
|
|
11081
|
+
}
|
|
11082
|
+
};
|
|
11083
|
+
}
|
|
11084
|
+
function toNodeLibraryPath(path5) {
|
|
11085
|
+
return path5 instanceof URL ? fileURLToPath2(path5) : path5;
|
|
11086
|
+
}
|
|
11087
|
+
function normalizeNodeDefinitions(definitions) {
|
|
11088
|
+
return Object.fromEntries(Object.entries(definitions).map(([name, definition]) => [name, normalizeNodeDefinition(definition)]));
|
|
11089
|
+
}
|
|
11090
|
+
function normalizeNodeDefinition(definition) {
|
|
11091
|
+
if (definition.ptr != null) {
|
|
11092
|
+
throw new Error(NODE_POINTER_OVERRIDE);
|
|
11093
|
+
}
|
|
11094
|
+
return {
|
|
11095
|
+
parameters: (definition.args ?? []).map((type) => toNodeFFIType(type, "parameter")),
|
|
11096
|
+
result: toNodeFFIType(definition.returns ?? FFIType.void, "result")
|
|
11097
|
+
};
|
|
11098
|
+
}
|
|
11099
|
+
function toNodeFFIType(type, position) {
|
|
11100
|
+
switch (type) {
|
|
11101
|
+
case FFIType.char:
|
|
11102
|
+
return "char";
|
|
11103
|
+
case FFIType.int8_t:
|
|
11104
|
+
case FFIType.i8:
|
|
11105
|
+
return "i8";
|
|
11106
|
+
case FFIType.uint8_t:
|
|
11107
|
+
case FFIType.u8:
|
|
11108
|
+
return "u8";
|
|
11109
|
+
case FFIType.int16_t:
|
|
11110
|
+
case FFIType.i16:
|
|
11111
|
+
return "i16";
|
|
11112
|
+
case FFIType.uint16_t:
|
|
11113
|
+
case FFIType.u16:
|
|
11114
|
+
return "u16";
|
|
11115
|
+
case FFIType.int32_t:
|
|
11116
|
+
case FFIType.int:
|
|
11117
|
+
case FFIType.i32:
|
|
11118
|
+
return "i32";
|
|
11119
|
+
case FFIType.uint32_t:
|
|
11120
|
+
case FFIType.u32:
|
|
11121
|
+
return "u32";
|
|
11122
|
+
case FFIType.int64_t:
|
|
11123
|
+
case FFIType.i64:
|
|
11124
|
+
return "i64";
|
|
11125
|
+
case FFIType.uint64_t:
|
|
11126
|
+
case FFIType.u64:
|
|
11127
|
+
return "u64";
|
|
11128
|
+
case FFIType.double:
|
|
11129
|
+
case FFIType.f64:
|
|
11130
|
+
return "f64";
|
|
11131
|
+
case FFIType.float:
|
|
11132
|
+
case FFIType.f32:
|
|
11133
|
+
return "f32";
|
|
11134
|
+
case FFIType.bool:
|
|
11135
|
+
return "bool";
|
|
11136
|
+
case FFIType.ptr:
|
|
11137
|
+
case FFIType.pointer:
|
|
11138
|
+
return "pointer";
|
|
11139
|
+
case FFIType.void:
|
|
11140
|
+
return "void";
|
|
11141
|
+
case FFIType.cstring:
|
|
11142
|
+
if (position === "result") {
|
|
11143
|
+
throw new Error(NODE_STRING_RETURN);
|
|
11144
|
+
}
|
|
11145
|
+
return "string";
|
|
11146
|
+
case FFIType.function:
|
|
11147
|
+
case FFIType.callback:
|
|
11148
|
+
return "pointer";
|
|
11149
|
+
case FFIType.usize:
|
|
11150
|
+
throw new Error(NODE_USIZE_UNSUPPORTED);
|
|
11151
|
+
case FFIType.napi_env:
|
|
11152
|
+
case FFIType.napi_value:
|
|
11153
|
+
throw new Error(NODE_NAPI_UNSUPPORTED);
|
|
11154
|
+
case FFIType.buffer:
|
|
11155
|
+
return "buffer";
|
|
11156
|
+
default:
|
|
11157
|
+
return unsupportedNodeFFIType(type);
|
|
11158
|
+
}
|
|
11159
|
+
}
|
|
11160
|
+
function unsupportedNodeFFIType(type) {
|
|
11161
|
+
throw new Error(`Unsupported FFIType for node:ffi: ${String(type)}`);
|
|
11162
|
+
}
|
|
11163
|
+
function toBigIntPointer(pointer) {
|
|
11164
|
+
return typeof pointer === "bigint" ? pointer : BigInt(pointer);
|
|
11165
|
+
}
|
|
11166
|
+
var dlopen = backend.dlopen;
|
|
11167
|
+
var ptr = backend.ptr;
|
|
11168
|
+
var suffix = backend.suffix;
|
|
11169
|
+
var toArrayBuffer = backend.toArrayBuffer;
|
|
11170
|
+
|
|
10859
11171
|
// src/zig.ts
|
|
10860
|
-
import { dlopen, toArrayBuffer as toArrayBuffer4, JSCallback, ptr as ptr4 } from "bun:ffi";
|
|
10861
11172
|
import { existsSync as existsSync2, writeFileSync } from "fs";
|
|
10862
11173
|
import { EventEmitter as EventEmitter4 } from "events";
|
|
10863
11174
|
|
|
10864
11175
|
// src/buffer.ts
|
|
10865
|
-
import { toArrayBuffer, ptr } from "bun:ffi";
|
|
10866
11176
|
function packDrawOptions(border2, shouldFill, titleAlignment, bottomTitleAlignment) {
|
|
10867
11177
|
let packed = 0;
|
|
10868
11178
|
if (border2 === true) {
|
|
@@ -11097,11 +11407,11 @@ class OptimizedBuffer {
|
|
|
11097
11407
|
}
|
|
11098
11408
|
drawSuperSampleBuffer(x, y, pixelDataPtr, pixelDataLength, format, alignedBytesPerRow) {
|
|
11099
11409
|
this.guard();
|
|
11100
|
-
this.lib.bufferDrawSuperSampleBuffer(this.bufferPtr, x, y, pixelDataPtr, pixelDataLength, format, alignedBytesPerRow);
|
|
11410
|
+
this.lib.bufferDrawSuperSampleBuffer(this.bufferPtr, x, y, toPointer(pixelDataPtr), pixelDataLength, format, alignedBytesPerRow);
|
|
11101
11411
|
}
|
|
11102
11412
|
drawPackedBuffer(dataPtr, dataLen, posX, posY, terminalWidthCells, terminalHeightCells) {
|
|
11103
11413
|
this.guard();
|
|
11104
|
-
this.lib.bufferDrawPackedBuffer(this.bufferPtr, dataPtr, dataLen, posX, posY, terminalWidthCells, terminalHeightCells);
|
|
11414
|
+
this.lib.bufferDrawPackedBuffer(this.bufferPtr, toPointer(dataPtr), dataLen, posX, posY, terminalWidthCells, terminalHeightCells);
|
|
11105
11415
|
}
|
|
11106
11416
|
drawGrayscaleBuffer(posX, posY, intensities, srcWidth, srcHeight, fg2 = null, bg2 = null) {
|
|
11107
11417
|
this.guard();
|
|
@@ -11178,14 +11488,63 @@ class OptimizedBuffer {
|
|
|
11178
11488
|
}
|
|
11179
11489
|
}
|
|
11180
11490
|
|
|
11181
|
-
// ../../node_modules/.bun/bun-ffi-structs@0.
|
|
11182
|
-
|
|
11491
|
+
// ../../node_modules/.bun/bun-ffi-structs@0.2.2+1fb4c65d43e298b9/node_modules/bun-ffi-structs/dist/index.js
|
|
11492
|
+
var FFI_LOAD_ERROR = "bun-ffi-structs requires Bun or Node.js with node:ffi enabled (--experimental-ffi --allow-ffi).";
|
|
11493
|
+
var backend2 = await loadBackend2();
|
|
11494
|
+
async function loadBackend2() {
|
|
11495
|
+
if (typeof process !== "undefined" && "bun" in process.versions) {
|
|
11496
|
+
return createBunBackend2(await importModule2("bun:ffi"));
|
|
11497
|
+
}
|
|
11498
|
+
try {
|
|
11499
|
+
return createNodeBackend2(await importModule2("node:ffi"));
|
|
11500
|
+
} catch (error) {
|
|
11501
|
+
throw new Error(FFI_LOAD_ERROR, {
|
|
11502
|
+
cause: error instanceof Error ? error : undefined
|
|
11503
|
+
});
|
|
11504
|
+
}
|
|
11505
|
+
}
|
|
11506
|
+
function importModule2(specifier) {
|
|
11507
|
+
return import(specifier).then((module) => module.default ?? module);
|
|
11508
|
+
}
|
|
11509
|
+
function createBunBackend2(bun) {
|
|
11510
|
+
return {
|
|
11511
|
+
ptr: bun.ptr,
|
|
11512
|
+
toArrayBuffer(pointer, offset, length) {
|
|
11513
|
+
return bun.toArrayBuffer(toBunPointer2(pointer), offset, length);
|
|
11514
|
+
}
|
|
11515
|
+
};
|
|
11516
|
+
}
|
|
11517
|
+
function createNodeBackend2(nodeFfi) {
|
|
11518
|
+
return {
|
|
11519
|
+
ptr(value) {
|
|
11520
|
+
if (ArrayBuffer.isView(value)) {
|
|
11521
|
+
return nodeFfi.getRawPointer(value.buffer) + BigInt(value.byteOffset);
|
|
11522
|
+
}
|
|
11523
|
+
if (value instanceof ArrayBuffer) {
|
|
11524
|
+
return nodeFfi.getRawPointer(value);
|
|
11525
|
+
}
|
|
11526
|
+
throw new TypeError("node:ffi ptr() only supports ArrayBuffer and ArrayBufferView values.");
|
|
11527
|
+
},
|
|
11528
|
+
toArrayBuffer(pointer, offset, length) {
|
|
11529
|
+
return nodeFfi.toArrayBuffer(toBigIntPointer2(pointer) + BigInt(offset ?? 0), length, false);
|
|
11530
|
+
}
|
|
11531
|
+
};
|
|
11532
|
+
}
|
|
11533
|
+
function toBigIntPointer2(pointer) {
|
|
11534
|
+
return typeof pointer === "bigint" ? pointer : BigInt(pointer);
|
|
11535
|
+
}
|
|
11536
|
+
function toBunPointer2(pointer) {
|
|
11537
|
+
return typeof pointer === "bigint" ? Number(pointer) : pointer;
|
|
11538
|
+
}
|
|
11539
|
+
var ptr2 = backend2.ptr;
|
|
11540
|
+
var toArrayBuffer2 = backend2.toArrayBuffer;
|
|
11183
11541
|
function fatalError(...args) {
|
|
11184
11542
|
const message = args.join(" ");
|
|
11185
11543
|
console.error("FATAL ERROR:", message);
|
|
11186
11544
|
throw new Error(message);
|
|
11187
11545
|
}
|
|
11188
11546
|
var pointerSize = process.arch === "x64" || process.arch === "arm64" ? 8 : 4;
|
|
11547
|
+
var isBun2 = typeof process !== "undefined" && "bun" in process.versions;
|
|
11189
11548
|
var typeSizes = {
|
|
11190
11549
|
u8: 1,
|
|
11191
11550
|
bool_u8: 1,
|
|
@@ -11197,7 +11556,8 @@ var typeSizes = {
|
|
|
11197
11556
|
f32: 4,
|
|
11198
11557
|
f64: 8,
|
|
11199
11558
|
pointer: pointerSize,
|
|
11200
|
-
i32: 4
|
|
11559
|
+
i32: 4,
|
|
11560
|
+
i64: 8
|
|
11201
11561
|
};
|
|
11202
11562
|
var primitiveKeys = Object.keys(typeSizes);
|
|
11203
11563
|
function isPrimitiveType(type) {
|
|
@@ -11215,6 +11575,7 @@ var typeGetters = {
|
|
|
11215
11575
|
f32: (view, offset) => view.getFloat32(offset, true),
|
|
11216
11576
|
f64: (view, offset) => view.getFloat64(offset, true),
|
|
11217
11577
|
i32: (view, offset) => view.getInt32(offset, true),
|
|
11578
|
+
i64: (view, offset) => view.getBigInt64(offset, true),
|
|
11218
11579
|
pointer: (view, offset) => pointerSize === 8 ? view.getBigUint64(offset, true) : BigInt(view.getUint32(offset, true))
|
|
11219
11580
|
};
|
|
11220
11581
|
function isObjectPointerDef(type) {
|
|
@@ -11278,6 +11639,10 @@ function primitivePackers(type) {
|
|
|
11278
11639
|
pack = (view, off, val) => view.setInt32(off, val, true);
|
|
11279
11640
|
unpack = (view, off) => view.getInt32(off, true);
|
|
11280
11641
|
break;
|
|
11642
|
+
case "i64":
|
|
11643
|
+
pack = (view, off, val) => view.setBigInt64(off, BigInt(val), true);
|
|
11644
|
+
unpack = (view, off) => view.getBigInt64(off, true);
|
|
11645
|
+
break;
|
|
11281
11646
|
case "u64":
|
|
11282
11647
|
pack = (view, off, val) => view.setBigUint64(off, BigInt(val), true);
|
|
11283
11648
|
unpack = (view, off) => view.getBigUint64(off, true);
|
|
@@ -11295,8 +11660,11 @@ function primitivePackers(type) {
|
|
|
11295
11660
|
pointerSize === 8 ? view.setBigUint64(off, val ? BigInt(val) : 0n, true) : view.setUint32(off, val ? Number(val) : 0, true);
|
|
11296
11661
|
};
|
|
11297
11662
|
unpack = (view, off) => {
|
|
11298
|
-
|
|
11299
|
-
|
|
11663
|
+
if (pointerSize === 8) {
|
|
11664
|
+
const value = view.getBigUint64(off, true);
|
|
11665
|
+
return isBun2 ? Number(value) : value;
|
|
11666
|
+
}
|
|
11667
|
+
return view.getUint32(off, true);
|
|
11300
11668
|
};
|
|
11301
11669
|
break;
|
|
11302
11670
|
default:
|
|
@@ -11305,6 +11673,26 @@ function primitivePackers(type) {
|
|
|
11305
11673
|
return { pack, unpack };
|
|
11306
11674
|
}
|
|
11307
11675
|
var { pack: pointerPacker, unpack: pointerUnpacker } = primitivePackers("pointer");
|
|
11676
|
+
var retainedPointerTargets = new WeakMap;
|
|
11677
|
+
function retainPointerTarget(owner, target) {
|
|
11678
|
+
const retained = retainedPointerTargets.get(owner);
|
|
11679
|
+
if (retained) {
|
|
11680
|
+
retained.push(target);
|
|
11681
|
+
} else {
|
|
11682
|
+
retainedPointerTargets.set(owner, [target]);
|
|
11683
|
+
}
|
|
11684
|
+
}
|
|
11685
|
+
function retainIfPointerTargets(owner, target) {
|
|
11686
|
+
if (retainedPointerTargets.has(target)) {
|
|
11687
|
+
retainPointerTarget(owner, target);
|
|
11688
|
+
}
|
|
11689
|
+
}
|
|
11690
|
+
function isNullPointer(pointer) {
|
|
11691
|
+
return pointer == null || pointer === 0 || pointer === 0n;
|
|
11692
|
+
}
|
|
11693
|
+
function toItemCount(length) {
|
|
11694
|
+
return typeof length === "bigint" ? Number(length) : length;
|
|
11695
|
+
}
|
|
11308
11696
|
function packObjectArray(val) {
|
|
11309
11697
|
const buffer = new ArrayBuffer(val.length * pointerSize);
|
|
11310
11698
|
const bufferView = new DataView(buffer);
|
|
@@ -11341,8 +11729,14 @@ function defineStruct(fields, structDefOptions) {
|
|
|
11341
11729
|
size = pointerSize;
|
|
11342
11730
|
align = pointerSize;
|
|
11343
11731
|
pack = (view, off, val) => {
|
|
11344
|
-
|
|
11732
|
+
if (!val) {
|
|
11733
|
+
pointerPacker(view, off, null);
|
|
11734
|
+
return;
|
|
11735
|
+
}
|
|
11736
|
+
const bytes = encoder.encode(val + "\x00");
|
|
11737
|
+
const bufPtr = ptr2(bytes);
|
|
11345
11738
|
pointerPacker(view, off, bufPtr);
|
|
11739
|
+
retainPointerTarget(view.buffer, bytes);
|
|
11346
11740
|
};
|
|
11347
11741
|
unpack = (view, off) => {
|
|
11348
11742
|
const ptrVal = pointerUnpacker(view, off);
|
|
@@ -11352,8 +11746,14 @@ function defineStruct(fields, structDefOptions) {
|
|
|
11352
11746
|
size = pointerSize;
|
|
11353
11747
|
align = pointerSize;
|
|
11354
11748
|
pack = (view, off, val) => {
|
|
11355
|
-
|
|
11749
|
+
if (!val) {
|
|
11750
|
+
pointerPacker(view, off, null);
|
|
11751
|
+
return;
|
|
11752
|
+
}
|
|
11753
|
+
const bytes = encoder.encode(val);
|
|
11754
|
+
const bufPtr = ptr2(bytes);
|
|
11356
11755
|
pointerPacker(view, off, bufPtr);
|
|
11756
|
+
retainPointerTarget(view.buffer, bytes);
|
|
11357
11757
|
};
|
|
11358
11758
|
unpack = (view, off) => {
|
|
11359
11759
|
const ptrVal = pointerUnpacker(view, off);
|
|
@@ -11384,6 +11784,7 @@ function defineStruct(fields, structDefOptions) {
|
|
|
11384
11784
|
}
|
|
11385
11785
|
const nestedBuf = typeOrStruct.pack(val, options2);
|
|
11386
11786
|
pointerPacker(view, off, ptr2(nestedBuf));
|
|
11787
|
+
retainPointerTarget(view.buffer, nestedBuf);
|
|
11387
11788
|
};
|
|
11388
11789
|
unpack = (view, off) => {
|
|
11389
11790
|
throw new Error("Not implemented yet");
|
|
@@ -11396,6 +11797,7 @@ function defineStruct(fields, structDefOptions) {
|
|
|
11396
11797
|
const nestedView = new Uint8Array(nestedBuf);
|
|
11397
11798
|
const dView = new Uint8Array(view.buffer);
|
|
11398
11799
|
dView.set(nestedView, off);
|
|
11800
|
+
retainIfPointerTargets(view.buffer, nestedBuf);
|
|
11399
11801
|
};
|
|
11400
11802
|
unpack = (view, off) => {
|
|
11401
11803
|
const slice = view.buffer.slice(off, off + size);
|
|
@@ -11436,6 +11838,7 @@ function defineStruct(fields, structDefOptions) {
|
|
|
11436
11838
|
bufferView.setUint32(i * arrayElementSize, num, true);
|
|
11437
11839
|
}
|
|
11438
11840
|
pointerPacker(view, off, ptr2(buffer));
|
|
11841
|
+
retainPointerTarget(view.buffer, buffer);
|
|
11439
11842
|
};
|
|
11440
11843
|
unpack = null;
|
|
11441
11844
|
needsLengthOf = true;
|
|
@@ -11453,6 +11856,7 @@ function defineStruct(fields, structDefOptions) {
|
|
|
11453
11856
|
def.packInto(val[i], bufferView, i * arrayElementSize, options2);
|
|
11454
11857
|
}
|
|
11455
11858
|
pointerPacker(view, off, ptr2(buffer));
|
|
11859
|
+
retainPointerTarget(view.buffer, buffer);
|
|
11456
11860
|
};
|
|
11457
11861
|
unpack = (view, off) => {
|
|
11458
11862
|
throw new Error("Not implemented yet");
|
|
@@ -11471,6 +11875,7 @@ function defineStruct(fields, structDefOptions) {
|
|
|
11471
11875
|
primitivePack(bufferView, i * arrayElementSize, val[i]);
|
|
11472
11876
|
}
|
|
11473
11877
|
pointerPacker(view, off, ptr2(buffer));
|
|
11878
|
+
retainPointerTarget(view.buffer, buffer);
|
|
11474
11879
|
};
|
|
11475
11880
|
unpack = null;
|
|
11476
11881
|
needsLengthOf = true;
|
|
@@ -11484,6 +11889,7 @@ function defineStruct(fields, structDefOptions) {
|
|
|
11484
11889
|
}
|
|
11485
11890
|
const packedView = packObjectArray(val);
|
|
11486
11891
|
pointerPacker(view, off, ptr2(packedView.buffer));
|
|
11892
|
+
retainPointerTarget(view.buffer, packedView.buffer);
|
|
11487
11893
|
};
|
|
11488
11894
|
unpack = () => {
|
|
11489
11895
|
throw new Error("not implemented yet");
|
|
@@ -11579,13 +11985,14 @@ function defineStruct(fields, structDefOptions) {
|
|
|
11579
11985
|
throw new Error(`lengthOf field not found for array field ${requester.name}`);
|
|
11580
11986
|
}
|
|
11581
11987
|
if (def === "char*") {
|
|
11988
|
+
const relativeOffset = lengthOfField.offset - requester.offset;
|
|
11582
11989
|
requester.unpack = (view, off) => {
|
|
11583
11990
|
const ptrAddress = pointerUnpacker(view, off);
|
|
11584
|
-
const length = lengthOfField.unpack(view,
|
|
11585
|
-
if (ptrAddress
|
|
11991
|
+
const length = lengthOfField.unpack(view, off + relativeOffset);
|
|
11992
|
+
if (isNullPointer(ptrAddress)) {
|
|
11586
11993
|
return null;
|
|
11587
11994
|
}
|
|
11588
|
-
const byteLength =
|
|
11995
|
+
const byteLength = toItemCount(length);
|
|
11589
11996
|
if (byteLength === 0) {
|
|
11590
11997
|
return "";
|
|
11591
11998
|
}
|
|
@@ -11595,38 +12002,42 @@ function defineStruct(fields, structDefOptions) {
|
|
|
11595
12002
|
} else if (isPrimitiveType(def)) {
|
|
11596
12003
|
const elemSize = typeSizes[def];
|
|
11597
12004
|
const { unpack: primitiveUnpack } = primitivePackers(def);
|
|
12005
|
+
const relativeOffset = lengthOfField.offset - requester.offset;
|
|
11598
12006
|
requester.unpack = (view, off) => {
|
|
11599
12007
|
const result = [];
|
|
11600
|
-
const length = lengthOfField.unpack(view,
|
|
12008
|
+
const length = lengthOfField.unpack(view, off + relativeOffset);
|
|
12009
|
+
const itemCount = toItemCount(length);
|
|
11601
12010
|
const ptrAddress = pointerUnpacker(view, off);
|
|
11602
|
-
if (ptrAddress
|
|
12011
|
+
if (isNullPointer(ptrAddress) && itemCount > 0) {
|
|
11603
12012
|
throw new Error(`Array field ${requester.name} has null pointer but length ${length}.`);
|
|
11604
12013
|
}
|
|
11605
|
-
if (ptrAddress
|
|
12014
|
+
if (isNullPointer(ptrAddress) || itemCount === 0) {
|
|
11606
12015
|
return [];
|
|
11607
12016
|
}
|
|
11608
|
-
const buffer = toArrayBuffer2(ptrAddress, 0,
|
|
12017
|
+
const buffer = toArrayBuffer2(ptrAddress, 0, itemCount * elemSize);
|
|
11609
12018
|
const bufferView = new DataView(buffer);
|
|
11610
|
-
for (let i = 0;i <
|
|
12019
|
+
for (let i = 0;i < itemCount; i++) {
|
|
11611
12020
|
result.push(primitiveUnpack(bufferView, i * elemSize));
|
|
11612
12021
|
}
|
|
11613
12022
|
return result;
|
|
11614
12023
|
};
|
|
11615
12024
|
} else {
|
|
11616
12025
|
const elemSize = def.type === "u32" ? 4 : 8;
|
|
12026
|
+
const relativeOffset = lengthOfField.offset - requester.offset;
|
|
11617
12027
|
requester.unpack = (view, off) => {
|
|
11618
12028
|
const result = [];
|
|
11619
|
-
const length = lengthOfField.unpack(view,
|
|
12029
|
+
const length = lengthOfField.unpack(view, off + relativeOffset);
|
|
12030
|
+
const itemCount = toItemCount(length);
|
|
11620
12031
|
const ptrAddress = pointerUnpacker(view, off);
|
|
11621
|
-
if (ptrAddress
|
|
12032
|
+
if (isNullPointer(ptrAddress) && itemCount > 0) {
|
|
11622
12033
|
throw new Error(`Array field ${requester.name} has null pointer but length ${length}.`);
|
|
11623
12034
|
}
|
|
11624
|
-
if (ptrAddress
|
|
12035
|
+
if (isNullPointer(ptrAddress) || itemCount === 0) {
|
|
11625
12036
|
return [];
|
|
11626
12037
|
}
|
|
11627
|
-
const buffer = toArrayBuffer2(ptrAddress, 0,
|
|
12038
|
+
const buffer = toArrayBuffer2(ptrAddress, 0, itemCount * elemSize);
|
|
11628
12039
|
const bufferView = new DataView(buffer);
|
|
11629
|
-
for (let i = 0;i <
|
|
12040
|
+
for (let i = 0;i < itemCount; i++) {
|
|
11630
12041
|
result.push(def.from(bufferView.getUint32(i * elemSize, true)));
|
|
11631
12042
|
}
|
|
11632
12043
|
return result;
|
|
@@ -11787,9 +12198,8 @@ function defineStruct(fields, structDefOptions) {
|
|
|
11787
12198
|
}
|
|
11788
12199
|
|
|
11789
12200
|
// src/zig-structs.ts
|
|
11790
|
-
|
|
11791
|
-
var
|
|
11792
|
-
var rgbaUnpackTransform = (ptr4) => ptr4 ? RGBA.fromArray(new Uint16Array(toArrayBuffer3(ptr4, 0, 8))) : undefined;
|
|
12201
|
+
var rgbaPackTransform = (rgba) => rgba ? ptr(rgba.buffer) : null;
|
|
12202
|
+
var rgbaUnpackTransform = (ptr3) => ptr3 ? RGBA.fromArray(new Uint16Array(toArrayBuffer(ptr3, 0, 8))) : undefined;
|
|
11793
12203
|
var StyledChunkStruct = defineStruct([
|
|
11794
12204
|
["text", "char*"],
|
|
11795
12205
|
["text_len", "u64", { lengthOf: "text" }],
|
|
@@ -11870,6 +12280,7 @@ var TerminalCapabilitiesStruct = defineStruct([
|
|
|
11870
12280
|
["hyperlinks", "bool_u8"],
|
|
11871
12281
|
["osc52", "bool_u8"],
|
|
11872
12282
|
["explicit_cursor_positioning", "bool_u8"],
|
|
12283
|
+
["in_tmux", "bool_u8"],
|
|
11873
12284
|
["term_name", "char*"],
|
|
11874
12285
|
["term_name_len", "u64", { lengthOf: "term_name" }],
|
|
11875
12286
|
["term_version", "char*"],
|
|
@@ -12026,20 +12437,11 @@ var MOUSE_STYLE_TO_ID = { default: 0, pointer: 1, text: 2, crosshair: 3, move: 4
|
|
|
12026
12437
|
var globalTraceSymbols = null;
|
|
12027
12438
|
var globalFFILogPath = null;
|
|
12028
12439
|
var exitHandlerRegistered = false;
|
|
12029
|
-
function toPointer(value) {
|
|
12030
|
-
if (typeof value === "bigint") {
|
|
12031
|
-
if (value > BigInt(Number.MAX_SAFE_INTEGER)) {
|
|
12032
|
-
throw new Error("Pointer exceeds safe integer range");
|
|
12033
|
-
}
|
|
12034
|
-
return Number(value);
|
|
12035
|
-
}
|
|
12036
|
-
return value;
|
|
12037
|
-
}
|
|
12038
12440
|
function toNumber(value) {
|
|
12039
12441
|
return typeof value === "bigint" ? Number(value) : value;
|
|
12040
12442
|
}
|
|
12041
12443
|
function rgbaPtr(value) {
|
|
12042
|
-
return
|
|
12444
|
+
return ptr(value.buffer);
|
|
12043
12445
|
}
|
|
12044
12446
|
function optionalRgbaPtr(value) {
|
|
12045
12447
|
return value ? rgbaPtr(value) : null;
|
|
@@ -13058,6 +13460,7 @@ function getOpenTUILib(libPath) {
|
|
|
13058
13460
|
});
|
|
13059
13461
|
if (env.OTUI_DEBUG_FFI || env.OTUI_TRACE_FFI) {
|
|
13060
13462
|
return {
|
|
13463
|
+
...rawSymbols,
|
|
13061
13464
|
symbols: convertToDebugSymbols(rawSymbols.symbols)
|
|
13062
13465
|
};
|
|
13063
13466
|
}
|
|
@@ -13207,8 +13610,8 @@ class FFIRenderLib {
|
|
|
13207
13610
|
opentui;
|
|
13208
13611
|
encoder = new TextEncoder;
|
|
13209
13612
|
decoder = new TextDecoder;
|
|
13210
|
-
logCallbackWrapper;
|
|
13211
|
-
eventCallbackWrapper;
|
|
13613
|
+
logCallbackWrapper = null;
|
|
13614
|
+
eventCallbackWrapper = null;
|
|
13212
13615
|
_nativeEvents = new EventEmitter4;
|
|
13213
13616
|
_anyEventHandlers = [];
|
|
13214
13617
|
nativeSpanFeedCallbackWrapper = null;
|
|
@@ -13222,13 +13625,13 @@ class FFIRenderLib {
|
|
|
13222
13625
|
if (this.logCallbackWrapper) {
|
|
13223
13626
|
return;
|
|
13224
13627
|
}
|
|
13225
|
-
const logCallback =
|
|
13628
|
+
const logCallback = this.opentui.createCallback((level, msgPtr, msgLenBigInt) => {
|
|
13226
13629
|
try {
|
|
13227
13630
|
const msgLen = typeof msgLenBigInt === "bigint" ? Number(msgLenBigInt) : msgLenBigInt;
|
|
13228
13631
|
if (msgLen === 0 || !msgPtr) {
|
|
13229
13632
|
return;
|
|
13230
13633
|
}
|
|
13231
|
-
const msgBuffer =
|
|
13634
|
+
const msgBuffer = toArrayBuffer(msgPtr, 0, msgLen);
|
|
13232
13635
|
const msgBytes = new Uint8Array(msgBuffer);
|
|
13233
13636
|
const message = this.decoder.decode(msgBytes);
|
|
13234
13637
|
switch (level) {
|
|
@@ -13267,19 +13670,19 @@ class FFIRenderLib {
|
|
|
13267
13670
|
if (this.eventCallbackWrapper) {
|
|
13268
13671
|
return;
|
|
13269
13672
|
}
|
|
13270
|
-
const eventCallback =
|
|
13673
|
+
const eventCallback = this.opentui.createCallback((namePtr, nameLenBigInt, dataPtr, dataLenBigInt) => {
|
|
13271
13674
|
try {
|
|
13272
13675
|
const nameLen = typeof nameLenBigInt === "bigint" ? Number(nameLenBigInt) : nameLenBigInt;
|
|
13273
13676
|
const dataLen = typeof dataLenBigInt === "bigint" ? Number(dataLenBigInt) : dataLenBigInt;
|
|
13274
13677
|
if (nameLen === 0 || !namePtr) {
|
|
13275
13678
|
return;
|
|
13276
13679
|
}
|
|
13277
|
-
const nameBuffer =
|
|
13680
|
+
const nameBuffer = toArrayBuffer(namePtr, 0, nameLen);
|
|
13278
13681
|
const nameBytes = new Uint8Array(nameBuffer);
|
|
13279
13682
|
const eventName = this.decoder.decode(nameBytes);
|
|
13280
13683
|
let eventData;
|
|
13281
13684
|
if (dataLen > 0 && dataPtr) {
|
|
13282
|
-
eventData =
|
|
13685
|
+
eventData = toArrayBuffer(dataPtr, 0, dataLen).slice();
|
|
13283
13686
|
} else {
|
|
13284
13687
|
eventData = new ArrayBuffer(0);
|
|
13285
13688
|
}
|
|
@@ -13306,8 +13709,8 @@ class FFIRenderLib {
|
|
|
13306
13709
|
if (this.nativeSpanFeedCallbackWrapper) {
|
|
13307
13710
|
return this.nativeSpanFeedCallbackWrapper;
|
|
13308
13711
|
}
|
|
13309
|
-
const callback =
|
|
13310
|
-
const handler = this.nativeSpanFeedHandlers.get(
|
|
13712
|
+
const callback = this.opentui.createCallback((streamPtr, eventId, arg0, arg1) => {
|
|
13713
|
+
const handler = this.nativeSpanFeedHandlers.get(streamPtr);
|
|
13311
13714
|
if (handler) {
|
|
13312
13715
|
handler(eventId, arg0, arg1);
|
|
13313
13716
|
}
|
|
@@ -13327,7 +13730,7 @@ class FFIRenderLib {
|
|
|
13327
13730
|
createRenderer(width, height, options = {}) {
|
|
13328
13731
|
const testing = options.testing ?? false;
|
|
13329
13732
|
const remote = options.remote ?? false;
|
|
13330
|
-
return this.opentui.symbols.createRenderer(width, height, testing, remote);
|
|
13733
|
+
return this.opentui.symbols.createRenderer(width, height, ffiBool(testing), ffiBool(remote));
|
|
13331
13734
|
}
|
|
13332
13735
|
setTerminalEnvVar(renderer, key, value) {
|
|
13333
13736
|
const keyBytes = this.encoder.encode(key);
|
|
@@ -13338,10 +13741,10 @@ class FFIRenderLib {
|
|
|
13338
13741
|
this.opentui.symbols.destroyRenderer(renderer);
|
|
13339
13742
|
}
|
|
13340
13743
|
setUseThread(renderer, useThread) {
|
|
13341
|
-
this.opentui.symbols.setUseThread(renderer, useThread);
|
|
13744
|
+
this.opentui.symbols.setUseThread(renderer, ffiBool(useThread));
|
|
13342
13745
|
}
|
|
13343
13746
|
setClearOnShutdown(renderer, clear) {
|
|
13344
|
-
this.opentui.symbols.setClearOnShutdown(renderer, clear);
|
|
13747
|
+
this.opentui.symbols.setClearOnShutdown(renderer, ffiBool(clear));
|
|
13345
13748
|
}
|
|
13346
13749
|
setBackgroundColor(renderer, color) {
|
|
13347
13750
|
this.opentui.symbols.setBackgroundColor(renderer, rgbaPtr(color));
|
|
@@ -13390,41 +13793,41 @@ class FFIRenderLib {
|
|
|
13390
13793
|
for (let index = 0;index < palette.length; index++) {
|
|
13391
13794
|
paletteBuffer.set(palette[index].buffer, index * 4);
|
|
13392
13795
|
}
|
|
13393
|
-
this.opentui.symbols.rendererSetPaletteState(renderer,
|
|
13796
|
+
this.opentui.symbols.rendererSetPaletteState(renderer, ptr(paletteBuffer), palette.length, rgbaPtr(defaultForeground), rgbaPtr(defaultBackground), paletteEpoch >>> 0);
|
|
13394
13797
|
}
|
|
13395
13798
|
bufferGetCharPtr(buffer) {
|
|
13396
|
-
const
|
|
13397
|
-
if (!
|
|
13799
|
+
const ptr3 = this.opentui.symbols.bufferGetCharPtr(buffer);
|
|
13800
|
+
if (!ptr3) {
|
|
13398
13801
|
throw new Error("Failed to get char pointer");
|
|
13399
13802
|
}
|
|
13400
|
-
return
|
|
13803
|
+
return ptr3;
|
|
13401
13804
|
}
|
|
13402
13805
|
bufferGetFgPtr(buffer) {
|
|
13403
|
-
const
|
|
13404
|
-
if (!
|
|
13806
|
+
const ptr3 = this.opentui.symbols.bufferGetFgPtr(buffer);
|
|
13807
|
+
if (!ptr3) {
|
|
13405
13808
|
throw new Error("Failed to get fg pointer");
|
|
13406
13809
|
}
|
|
13407
|
-
return
|
|
13810
|
+
return ptr3;
|
|
13408
13811
|
}
|
|
13409
13812
|
bufferGetBgPtr(buffer) {
|
|
13410
|
-
const
|
|
13411
|
-
if (!
|
|
13813
|
+
const ptr3 = this.opentui.symbols.bufferGetBgPtr(buffer);
|
|
13814
|
+
if (!ptr3) {
|
|
13412
13815
|
throw new Error("Failed to get bg pointer");
|
|
13413
13816
|
}
|
|
13414
|
-
return
|
|
13817
|
+
return ptr3;
|
|
13415
13818
|
}
|
|
13416
13819
|
bufferGetAttributesPtr(buffer) {
|
|
13417
|
-
const
|
|
13418
|
-
if (!
|
|
13820
|
+
const ptr3 = this.opentui.symbols.bufferGetAttributesPtr(buffer);
|
|
13821
|
+
if (!ptr3) {
|
|
13419
13822
|
throw new Error("Failed to get attributes pointer");
|
|
13420
13823
|
}
|
|
13421
|
-
return
|
|
13824
|
+
return ptr3;
|
|
13422
13825
|
}
|
|
13423
13826
|
bufferGetRespectAlpha(buffer) {
|
|
13424
13827
|
return this.opentui.symbols.bufferGetRespectAlpha(buffer);
|
|
13425
13828
|
}
|
|
13426
13829
|
bufferSetRespectAlpha(buffer, respectAlpha) {
|
|
13427
|
-
this.opentui.symbols.bufferSetRespectAlpha(buffer, respectAlpha);
|
|
13830
|
+
this.opentui.symbols.bufferSetRespectAlpha(buffer, ffiBool(respectAlpha));
|
|
13428
13831
|
}
|
|
13429
13832
|
bufferGetId(buffer) {
|
|
13430
13833
|
const maxLen = 256;
|
|
@@ -13437,7 +13840,7 @@ class FFIRenderLib {
|
|
|
13437
13840
|
return this.opentui.symbols.bufferGetRealCharSize(buffer);
|
|
13438
13841
|
}
|
|
13439
13842
|
bufferWriteResolvedChars(buffer, outputBuffer, addLineBreaks) {
|
|
13440
|
-
const bytesWritten = this.opentui.symbols.bufferWriteResolvedChars(buffer, outputBuffer, outputBuffer.length, addLineBreaks);
|
|
13843
|
+
const bytesWritten = this.opentui.symbols.bufferWriteResolvedChars(buffer, outputBuffer, outputBuffer.length, ffiBool(addLineBreaks));
|
|
13441
13844
|
return typeof bytesWritten === "bigint" ? Number(bytesWritten) : bytesWritten;
|
|
13442
13845
|
}
|
|
13443
13846
|
getBufferWidth(buffer) {
|
|
@@ -13496,7 +13899,7 @@ class FFIRenderLib {
|
|
|
13496
13899
|
drawInner: options.drawInner,
|
|
13497
13900
|
drawOuter: options.drawOuter
|
|
13498
13901
|
});
|
|
13499
|
-
this.opentui.symbols.bufferDrawGrid(buffer, borderChars, rgbaPtr(borderFg), rgbaPtr(borderBg), columnOffsets, columnCount, rowOffsets, rowCount,
|
|
13902
|
+
this.opentui.symbols.bufferDrawGrid(buffer, borderChars, rgbaPtr(borderFg), rgbaPtr(borderBg), columnOffsets, columnCount, rowOffsets, rowCount, ptr(optionsBuffer));
|
|
13500
13903
|
}
|
|
13501
13904
|
bufferDrawBox(buffer, x, y, width, height, borderChars, packedOptions, borderColor, backgroundColor, title, bottomTitle) {
|
|
13502
13905
|
const titleBytes = title ? this.encoder.encode(title) : null;
|
|
@@ -13529,14 +13932,14 @@ class FFIRenderLib {
|
|
|
13529
13932
|
this.opentui.symbols.resizeRenderer(renderer, width, height);
|
|
13530
13933
|
}
|
|
13531
13934
|
setCursorPosition(renderer, x, y, visible) {
|
|
13532
|
-
this.opentui.symbols.setCursorPosition(renderer, x, y, visible);
|
|
13935
|
+
this.opentui.symbols.setCursorPosition(renderer, x, y, ffiBool(visible));
|
|
13533
13936
|
}
|
|
13534
13937
|
setCursorColor(renderer, color) {
|
|
13535
13938
|
this.opentui.symbols.setCursorColor(renderer, rgbaPtr(color));
|
|
13536
13939
|
}
|
|
13537
13940
|
getCursorState(renderer) {
|
|
13538
13941
|
const cursorBuffer = new ArrayBuffer(CursorStateStruct.size);
|
|
13539
|
-
this.opentui.symbols.getCursorState(renderer,
|
|
13942
|
+
this.opentui.symbols.getCursorState(renderer, ptr(cursorBuffer));
|
|
13540
13943
|
const struct = CursorStateStruct.unpack(cursorBuffer);
|
|
13541
13944
|
return {
|
|
13542
13945
|
x: struct.x,
|
|
@@ -13552,16 +13955,16 @@ class FFIRenderLib {
|
|
|
13552
13955
|
const blinking = options.blinking != null ? options.blinking ? 1 : 0 : 255;
|
|
13553
13956
|
const cursor = options.cursor != null ? MOUSE_STYLE_TO_ID[options.cursor] : 255;
|
|
13554
13957
|
const buffer = CursorStyleOptionsStruct.pack({ style, blinking, color: options.color, cursor });
|
|
13555
|
-
this.opentui.symbols.setCursorStyleOptions(renderer,
|
|
13958
|
+
this.opentui.symbols.setCursorStyleOptions(renderer, ptr(buffer));
|
|
13556
13959
|
}
|
|
13557
13960
|
render(renderer, force) {
|
|
13558
|
-
this.opentui.symbols.render(renderer, force);
|
|
13961
|
+
this.opentui.symbols.render(renderer, ffiBool(force));
|
|
13559
13962
|
}
|
|
13560
13963
|
repaintSplitFooter(renderer, pinnedRenderOffset, force) {
|
|
13561
|
-
return this.opentui.symbols.repaintSplitFooter(renderer, pinnedRenderOffset, force);
|
|
13964
|
+
return this.opentui.symbols.repaintSplitFooter(renderer, pinnedRenderOffset, ffiBool(force));
|
|
13562
13965
|
}
|
|
13563
13966
|
commitSplitFooterSnapshot(renderer, snapshot, rowColumns, startOnNewLine, trailingNewline, pinnedRenderOffset, force, beginFrame = true, finalizeFrame = true) {
|
|
13564
|
-
return this.opentui.symbols.commitSplitFooterSnapshot(renderer, snapshot.ptr, rowColumns, startOnNewLine, trailingNewline, pinnedRenderOffset, force, beginFrame, finalizeFrame);
|
|
13967
|
+
return this.opentui.symbols.commitSplitFooterSnapshot(renderer, snapshot.ptr, rowColumns, ffiBool(startOnNewLine), ffiBool(trailingNewline), pinnedRenderOffset, ffiBool(force), ffiBool(beginFrame), ffiBool(finalizeFrame));
|
|
13565
13968
|
}
|
|
13566
13969
|
createOptimizedBuffer(width, height, widthMethod, respectAlpha = false, id) {
|
|
13567
13970
|
if (Number.isNaN(width) || Number.isNaN(height)) {
|
|
@@ -13570,7 +13973,7 @@ class FFIRenderLib {
|
|
|
13570
13973
|
const widthMethodCode = widthMethod === "wcwidth" ? 0 : 1;
|
|
13571
13974
|
const idToUse = id || "unnamed buffer";
|
|
13572
13975
|
const idBytes = this.encoder.encode(idToUse);
|
|
13573
|
-
const bufferPtr = this.opentui.symbols.createOptimizedBuffer(width, height, respectAlpha, widthMethodCode, idBytes, idBytes.length);
|
|
13976
|
+
const bufferPtr = this.opentui.symbols.createOptimizedBuffer(width, height, ffiBool(respectAlpha), widthMethodCode, idBytes, idBytes.length);
|
|
13574
13977
|
if (!bufferPtr) {
|
|
13575
13978
|
throw new Error(`Failed to create optimized buffer: ${width}x${height}`);
|
|
13576
13979
|
}
|
|
@@ -13587,7 +13990,7 @@ class FFIRenderLib {
|
|
|
13587
13990
|
this.opentui.symbols.drawFrameBuffer(targetBufferPtr, destX, destY, bufferPtr, srcX, srcY, srcWidth, srcHeight);
|
|
13588
13991
|
}
|
|
13589
13992
|
setDebugOverlay(renderer, enabled, corner) {
|
|
13590
|
-
this.opentui.symbols.setDebugOverlay(renderer, enabled, corner);
|
|
13993
|
+
this.opentui.symbols.setDebugOverlay(renderer, ffiBool(enabled), corner);
|
|
13591
13994
|
}
|
|
13592
13995
|
clearTerminal(renderer) {
|
|
13593
13996
|
this.opentui.symbols.clearTerminal(renderer);
|
|
@@ -13641,7 +14044,7 @@ class FFIRenderLib {
|
|
|
13641
14044
|
this.opentui.symbols.restoreTerminalModes(renderer);
|
|
13642
14045
|
}
|
|
13643
14046
|
enableMouse(renderer, enableMovement) {
|
|
13644
|
-
this.opentui.symbols.enableMouse(renderer, enableMovement);
|
|
14047
|
+
this.opentui.symbols.enableMouse(renderer, ffiBool(enableMovement));
|
|
13645
14048
|
}
|
|
13646
14049
|
disableMouse(renderer) {
|
|
13647
14050
|
this.opentui.symbols.disableMouse(renderer);
|
|
@@ -13659,7 +14062,7 @@ class FFIRenderLib {
|
|
|
13659
14062
|
return this.opentui.symbols.getKittyKeyboardFlags(renderer);
|
|
13660
14063
|
}
|
|
13661
14064
|
setupTerminal(renderer, useAlternateScreen) {
|
|
13662
|
-
this.opentui.symbols.setupTerminal(renderer, useAlternateScreen);
|
|
14065
|
+
this.opentui.symbols.setupTerminal(renderer, ffiBool(useAlternateScreen));
|
|
13663
14066
|
}
|
|
13664
14067
|
suspendRenderer(renderer) {
|
|
13665
14068
|
this.opentui.symbols.suspendRenderer(renderer);
|
|
@@ -13677,7 +14080,7 @@ class FFIRenderLib {
|
|
|
13677
14080
|
const bytes = typeof data === "string" ? new TextEncoder().encode(data) : data;
|
|
13678
14081
|
if (bytes.length === 0)
|
|
13679
14082
|
return;
|
|
13680
|
-
this.opentui.symbols.writeOut(renderer,
|
|
14083
|
+
this.opentui.symbols.writeOut(renderer, ptr(bytes), bytes.length);
|
|
13681
14084
|
}
|
|
13682
14085
|
createTextBuffer(widthMethod) {
|
|
13683
14086
|
const widthMethodCode = widthMethod === "wcwidth" ? 0 : 1;
|
|
@@ -13724,14 +14127,14 @@ class FFIRenderLib {
|
|
|
13724
14127
|
this.opentui.symbols.textBufferSetTabWidth(buffer, width);
|
|
13725
14128
|
}
|
|
13726
14129
|
textBufferRegisterMemBuffer(buffer, bytes, owned = false) {
|
|
13727
|
-
const result = this.opentui.symbols.textBufferRegisterMemBuffer(buffer, bytes, bytes.length, owned);
|
|
14130
|
+
const result = this.opentui.symbols.textBufferRegisterMemBuffer(buffer, bytes, bytes.length, ffiBool(owned));
|
|
13728
14131
|
if (result === 65535) {
|
|
13729
14132
|
throw new Error("Failed to register memory buffer");
|
|
13730
14133
|
}
|
|
13731
14134
|
return result;
|
|
13732
14135
|
}
|
|
13733
14136
|
textBufferReplaceMemBuffer(buffer, memId, bytes, owned = false) {
|
|
13734
|
-
return this.opentui.symbols.textBufferReplaceMemBuffer(buffer, memId, bytes, bytes.length, owned);
|
|
14137
|
+
return this.opentui.symbols.textBufferReplaceMemBuffer(buffer, memId, bytes, bytes.length, ffiBool(owned));
|
|
13735
14138
|
}
|
|
13736
14139
|
textBufferClearMemRegistry(buffer) {
|
|
13737
14140
|
this.opentui.symbols.textBufferClearMemRegistry(buffer);
|
|
@@ -13755,7 +14158,7 @@ class FFIRenderLib {
|
|
|
13755
14158
|
return;
|
|
13756
14159
|
}
|
|
13757
14160
|
const chunksBuffer = StyledChunkStruct.packList(chunks);
|
|
13758
|
-
this.opentui.symbols.textBufferSetStyledText(buffer,
|
|
14161
|
+
this.opentui.symbols.textBufferSetStyledText(buffer, ptr(chunksBuffer), chunks.length);
|
|
13759
14162
|
}
|
|
13760
14163
|
textBufferGetLineCount(buffer) {
|
|
13761
14164
|
return this.opentui.symbols.textBufferGetLineCount(buffer);
|
|
@@ -13766,7 +14169,7 @@ class FFIRenderLib {
|
|
|
13766
14169
|
}
|
|
13767
14170
|
getPlainTextBytes(buffer, maxLength) {
|
|
13768
14171
|
const outBuffer = new Uint8Array(maxLength);
|
|
13769
|
-
const actualLen = this.textBufferGetPlainText(buffer,
|
|
14172
|
+
const actualLen = this.textBufferGetPlainText(buffer, ptr(outBuffer), maxLength);
|
|
13770
14173
|
if (actualLen === 0) {
|
|
13771
14174
|
return null;
|
|
13772
14175
|
}
|
|
@@ -13774,7 +14177,7 @@ class FFIRenderLib {
|
|
|
13774
14177
|
}
|
|
13775
14178
|
textBufferGetTextRange(buffer, startOffset, endOffset, maxLength) {
|
|
13776
14179
|
const outBuffer = new Uint8Array(maxLength);
|
|
13777
|
-
const actualLen = this.opentui.symbols.textBufferGetTextRange(buffer, startOffset, endOffset,
|
|
14180
|
+
const actualLen = this.opentui.symbols.textBufferGetTextRange(buffer, startOffset, endOffset, ptr(outBuffer), maxLength);
|
|
13778
14181
|
const len = typeof actualLen === "bigint" ? Number(actualLen) : actualLen;
|
|
13779
14182
|
if (len === 0) {
|
|
13780
14183
|
return null;
|
|
@@ -13783,7 +14186,7 @@ class FFIRenderLib {
|
|
|
13783
14186
|
}
|
|
13784
14187
|
textBufferGetTextRangeByCoords(buffer, startRow, startCol, endRow, endCol, maxLength) {
|
|
13785
14188
|
const outBuffer = new Uint8Array(maxLength);
|
|
13786
|
-
const actualLen = this.opentui.symbols.textBufferGetTextRangeByCoords(buffer, startRow, startCol, endRow, endCol,
|
|
14189
|
+
const actualLen = this.opentui.symbols.textBufferGetTextRangeByCoords(buffer, startRow, startCol, endRow, endCol, ptr(outBuffer), maxLength);
|
|
13787
14190
|
const len = typeof actualLen === "bigint" ? Number(actualLen) : actualLen;
|
|
13788
14191
|
if (len === 0) {
|
|
13789
14192
|
return null;
|
|
@@ -13856,7 +14259,7 @@ class FFIRenderLib {
|
|
|
13856
14259
|
}
|
|
13857
14260
|
textBufferViewGetLineInfo(view) {
|
|
13858
14261
|
const outBuffer = new ArrayBuffer(LineInfoStruct.size);
|
|
13859
|
-
this.textBufferViewGetLineInfoDirect(view,
|
|
14262
|
+
this.textBufferViewGetLineInfoDirect(view, ptr(outBuffer));
|
|
13860
14263
|
const struct = LineInfoStruct.unpack(outBuffer);
|
|
13861
14264
|
const lineStartCols = struct.startCols;
|
|
13862
14265
|
const lineWidthCols = struct.widthCols;
|
|
@@ -13871,7 +14274,7 @@ class FFIRenderLib {
|
|
|
13871
14274
|
}
|
|
13872
14275
|
textBufferViewGetLogicalLineInfo(view) {
|
|
13873
14276
|
const outBuffer = new ArrayBuffer(LineInfoStruct.size);
|
|
13874
|
-
this.textBufferViewGetLogicalLineInfoDirect(view,
|
|
14277
|
+
this.textBufferViewGetLogicalLineInfoDirect(view, ptr(outBuffer));
|
|
13875
14278
|
const struct = LineInfoStruct.unpack(outBuffer);
|
|
13876
14279
|
const lineStartCols = struct.startCols;
|
|
13877
14280
|
const lineWidthCols = struct.widthCols;
|
|
@@ -13903,7 +14306,7 @@ class FFIRenderLib {
|
|
|
13903
14306
|
}
|
|
13904
14307
|
textBufferViewGetSelectedTextBytes(view, maxLength) {
|
|
13905
14308
|
const outBuffer = new Uint8Array(maxLength);
|
|
13906
|
-
const actualLen = this.textBufferViewGetSelectedText(view,
|
|
14309
|
+
const actualLen = this.textBufferViewGetSelectedText(view, ptr(outBuffer), maxLength);
|
|
13907
14310
|
if (actualLen === 0) {
|
|
13908
14311
|
return null;
|
|
13909
14312
|
}
|
|
@@ -13911,7 +14314,7 @@ class FFIRenderLib {
|
|
|
13911
14314
|
}
|
|
13912
14315
|
textBufferViewGetPlainTextBytes(view, maxLength) {
|
|
13913
14316
|
const outBuffer = new Uint8Array(maxLength);
|
|
13914
|
-
const actualLen = this.textBufferViewGetPlainText(view,
|
|
14317
|
+
const actualLen = this.textBufferViewGetPlainText(view, ptr(outBuffer), maxLength);
|
|
13915
14318
|
if (actualLen === 0) {
|
|
13916
14319
|
return null;
|
|
13917
14320
|
}
|
|
@@ -13924,11 +14327,11 @@ class FFIRenderLib {
|
|
|
13924
14327
|
this.opentui.symbols.textBufferViewSetTabIndicatorColor(view, rgbaPtr(color));
|
|
13925
14328
|
}
|
|
13926
14329
|
textBufferViewSetTruncate(view, truncate) {
|
|
13927
|
-
this.opentui.symbols.textBufferViewSetTruncate(view, truncate);
|
|
14330
|
+
this.opentui.symbols.textBufferViewSetTruncate(view, ffiBool(truncate));
|
|
13928
14331
|
}
|
|
13929
14332
|
textBufferViewMeasureForDimensions(view, width, height) {
|
|
13930
14333
|
const resultBuffer = new ArrayBuffer(MeasureResultStruct.size);
|
|
13931
|
-
const resultPtr =
|
|
14334
|
+
const resultPtr = ptr(new Uint8Array(resultBuffer));
|
|
13932
14335
|
const success = this.opentui.symbols.textBufferViewMeasureForDimensions(view, width, height, resultPtr);
|
|
13933
14336
|
if (!success) {
|
|
13934
14337
|
return null;
|
|
@@ -13938,11 +14341,11 @@ class FFIRenderLib {
|
|
|
13938
14341
|
}
|
|
13939
14342
|
textBufferAddHighlightByCharRange(buffer, highlight) {
|
|
13940
14343
|
const packedHighlight = HighlightStruct.pack(highlight);
|
|
13941
|
-
this.opentui.symbols.textBufferAddHighlightByCharRange(buffer,
|
|
14344
|
+
this.opentui.symbols.textBufferAddHighlightByCharRange(buffer, ptr(packedHighlight));
|
|
13942
14345
|
}
|
|
13943
14346
|
textBufferAddHighlight(buffer, lineIdx, highlight) {
|
|
13944
14347
|
const packedHighlight = HighlightStruct.pack(highlight);
|
|
13945
|
-
this.opentui.symbols.textBufferAddHighlight(buffer, lineIdx,
|
|
14348
|
+
this.opentui.symbols.textBufferAddHighlight(buffer, lineIdx, ptr(packedHighlight));
|
|
13946
14349
|
}
|
|
13947
14350
|
textBufferRemoveHighlightsByRef(buffer, hlRef) {
|
|
13948
14351
|
this.opentui.symbols.textBufferRemoveHighlightsByRef(buffer, hlRef);
|
|
@@ -13958,12 +14361,12 @@ class FFIRenderLib {
|
|
|
13958
14361
|
}
|
|
13959
14362
|
textBufferGetLineHighlights(buffer, lineIdx) {
|
|
13960
14363
|
const outCountBuf = new BigUint64Array(1);
|
|
13961
|
-
const nativePtr = this.opentui.symbols.textBufferGetLineHighlightsPtr(buffer, lineIdx,
|
|
14364
|
+
const nativePtr = this.opentui.symbols.textBufferGetLineHighlightsPtr(buffer, lineIdx, ptr(outCountBuf));
|
|
13962
14365
|
if (!nativePtr)
|
|
13963
14366
|
return [];
|
|
13964
14367
|
const count = Number(outCountBuf[0]);
|
|
13965
14368
|
const byteLen = count * HighlightStruct.size;
|
|
13966
|
-
const raw =
|
|
14369
|
+
const raw = toArrayBuffer(nativePtr, 0, byteLen);
|
|
13967
14370
|
const results = HighlightStruct.unpackList(raw, count);
|
|
13968
14371
|
this.opentui.symbols.textBufferFreeLineHighlights(nativePtr, count);
|
|
13969
14372
|
return results;
|
|
@@ -13977,7 +14380,7 @@ class FFIRenderLib {
|
|
|
13977
14380
|
}
|
|
13978
14381
|
getBuildOptions() {
|
|
13979
14382
|
const optionsBuffer = new ArrayBuffer(BuildOptionsStruct.size);
|
|
13980
|
-
this.opentui.symbols.getBuildOptions(
|
|
14383
|
+
this.opentui.symbols.getBuildOptions(ptr(optionsBuffer));
|
|
13981
14384
|
const options = BuildOptionsStruct.unpack(optionsBuffer);
|
|
13982
14385
|
return {
|
|
13983
14386
|
gpaSafeStats: !!options.gpaSafeStats,
|
|
@@ -13986,7 +14389,7 @@ class FFIRenderLib {
|
|
|
13986
14389
|
}
|
|
13987
14390
|
getAllocatorStats() {
|
|
13988
14391
|
const statsBuffer = new ArrayBuffer(AllocatorStatsStruct.size);
|
|
13989
|
-
this.opentui.symbols.getAllocatorStats(
|
|
14392
|
+
this.opentui.symbols.getAllocatorStats(ptr(statsBuffer));
|
|
13990
14393
|
const stats = AllocatorStatsStruct.unpack(statsBuffer);
|
|
13991
14394
|
return {
|
|
13992
14395
|
totalRequestedBytes: toNumber(stats.totalRequestedBytes),
|
|
@@ -14016,14 +14419,14 @@ class FFIRenderLib {
|
|
|
14016
14419
|
this.opentui.symbols.editorViewSetViewportSize(view, width, height);
|
|
14017
14420
|
}
|
|
14018
14421
|
editorViewSetViewport(view, x, y, width, height, moveCursor) {
|
|
14019
|
-
this.opentui.symbols.editorViewSetViewport(view, x, y, width, height, moveCursor);
|
|
14422
|
+
this.opentui.symbols.editorViewSetViewport(view, x, y, width, height, ffiBool(moveCursor));
|
|
14020
14423
|
}
|
|
14021
14424
|
editorViewGetViewport(view) {
|
|
14022
14425
|
const x = new Uint32Array(1);
|
|
14023
14426
|
const y = new Uint32Array(1);
|
|
14024
14427
|
const width = new Uint32Array(1);
|
|
14025
14428
|
const height = new Uint32Array(1);
|
|
14026
|
-
this.opentui.symbols.editorViewGetViewport(view,
|
|
14429
|
+
this.opentui.symbols.editorViewGetViewport(view, ptr(x), ptr(y), ptr(width), ptr(height));
|
|
14027
14430
|
return {
|
|
14028
14431
|
offsetX: x[0],
|
|
14029
14432
|
offsetY: y[0],
|
|
@@ -14053,7 +14456,7 @@ class FFIRenderLib {
|
|
|
14053
14456
|
}
|
|
14054
14457
|
editorViewGetLineInfo(view) {
|
|
14055
14458
|
const outBuffer = new ArrayBuffer(LineInfoStruct.size);
|
|
14056
|
-
this.opentui.symbols.editorViewGetLineInfoDirect(view,
|
|
14459
|
+
this.opentui.symbols.editorViewGetLineInfoDirect(view, ptr(outBuffer));
|
|
14057
14460
|
const struct = LineInfoStruct.unpack(outBuffer);
|
|
14058
14461
|
const lineStartCols = struct.startCols;
|
|
14059
14462
|
const lineWidthCols = struct.widthCols;
|
|
@@ -14068,7 +14471,7 @@ class FFIRenderLib {
|
|
|
14068
14471
|
}
|
|
14069
14472
|
editorViewGetLogicalLineInfo(view) {
|
|
14070
14473
|
const outBuffer = new ArrayBuffer(LineInfoStruct.size);
|
|
14071
|
-
this.opentui.symbols.editorViewGetLogicalLineInfoDirect(view,
|
|
14474
|
+
this.opentui.symbols.editorViewGetLogicalLineInfoDirect(view, ptr(outBuffer));
|
|
14072
14475
|
const struct = LineInfoStruct.unpack(outBuffer);
|
|
14073
14476
|
const lineStartCols = struct.startCols;
|
|
14074
14477
|
const lineWidthCols = struct.widthCols;
|
|
@@ -14106,7 +14509,7 @@ class FFIRenderLib {
|
|
|
14106
14509
|
}
|
|
14107
14510
|
editBufferGetText(buffer, maxLength) {
|
|
14108
14511
|
const outBuffer = new Uint8Array(maxLength);
|
|
14109
|
-
const actualLen = this.opentui.symbols.editBufferGetText(buffer,
|
|
14512
|
+
const actualLen = this.opentui.symbols.editBufferGetText(buffer, ptr(outBuffer), maxLength);
|
|
14110
14513
|
const len = typeof actualLen === "bigint" ? Number(actualLen) : actualLen;
|
|
14111
14514
|
if (len === 0)
|
|
14112
14515
|
return null;
|
|
@@ -14161,7 +14564,7 @@ class FFIRenderLib {
|
|
|
14161
14564
|
}
|
|
14162
14565
|
editBufferGetCursorPosition(buffer) {
|
|
14163
14566
|
const cursorBuffer = new ArrayBuffer(LogicalCursorStruct.size);
|
|
14164
|
-
this.opentui.symbols.editBufferGetCursorPosition(buffer,
|
|
14567
|
+
this.opentui.symbols.editBufferGetCursorPosition(buffer, ptr(cursorBuffer));
|
|
14165
14568
|
return LogicalCursorStruct.unpack(cursorBuffer);
|
|
14166
14569
|
}
|
|
14167
14570
|
editBufferGetId(buffer) {
|
|
@@ -14179,7 +14582,7 @@ class FFIRenderLib {
|
|
|
14179
14582
|
}
|
|
14180
14583
|
editBufferUndo(buffer, maxLength) {
|
|
14181
14584
|
const outBuffer = new Uint8Array(maxLength);
|
|
14182
|
-
const actualLen = this.opentui.symbols.editBufferUndo(buffer,
|
|
14585
|
+
const actualLen = this.opentui.symbols.editBufferUndo(buffer, ptr(outBuffer), maxLength);
|
|
14183
14586
|
const len = typeof actualLen === "bigint" ? Number(actualLen) : actualLen;
|
|
14184
14587
|
if (len === 0)
|
|
14185
14588
|
return null;
|
|
@@ -14187,7 +14590,7 @@ class FFIRenderLib {
|
|
|
14187
14590
|
}
|
|
14188
14591
|
editBufferRedo(buffer, maxLength) {
|
|
14189
14592
|
const outBuffer = new Uint8Array(maxLength);
|
|
14190
|
-
const actualLen = this.opentui.symbols.editBufferRedo(buffer,
|
|
14593
|
+
const actualLen = this.opentui.symbols.editBufferRedo(buffer, ptr(outBuffer), maxLength);
|
|
14191
14594
|
const len = typeof actualLen === "bigint" ? Number(actualLen) : actualLen;
|
|
14192
14595
|
if (len === 0)
|
|
14193
14596
|
return null;
|
|
@@ -14207,22 +14610,22 @@ class FFIRenderLib {
|
|
|
14207
14610
|
}
|
|
14208
14611
|
editBufferGetNextWordBoundary(buffer) {
|
|
14209
14612
|
const cursorBuffer = new ArrayBuffer(LogicalCursorStruct.size);
|
|
14210
|
-
this.opentui.symbols.editBufferGetNextWordBoundary(buffer,
|
|
14613
|
+
this.opentui.symbols.editBufferGetNextWordBoundary(buffer, ptr(cursorBuffer));
|
|
14211
14614
|
return LogicalCursorStruct.unpack(cursorBuffer);
|
|
14212
14615
|
}
|
|
14213
14616
|
editBufferGetPrevWordBoundary(buffer) {
|
|
14214
14617
|
const cursorBuffer = new ArrayBuffer(LogicalCursorStruct.size);
|
|
14215
|
-
this.opentui.symbols.editBufferGetPrevWordBoundary(buffer,
|
|
14618
|
+
this.opentui.symbols.editBufferGetPrevWordBoundary(buffer, ptr(cursorBuffer));
|
|
14216
14619
|
return LogicalCursorStruct.unpack(cursorBuffer);
|
|
14217
14620
|
}
|
|
14218
14621
|
editBufferGetEOL(buffer) {
|
|
14219
14622
|
const cursorBuffer = new ArrayBuffer(LogicalCursorStruct.size);
|
|
14220
|
-
this.opentui.symbols.editBufferGetEOL(buffer,
|
|
14623
|
+
this.opentui.symbols.editBufferGetEOL(buffer, ptr(cursorBuffer));
|
|
14221
14624
|
return LogicalCursorStruct.unpack(cursorBuffer);
|
|
14222
14625
|
}
|
|
14223
14626
|
editBufferOffsetToPosition(buffer, offset) {
|
|
14224
14627
|
const cursorBuffer = new ArrayBuffer(LogicalCursorStruct.size);
|
|
14225
|
-
const success = this.opentui.symbols.editBufferOffsetToPosition(buffer, offset,
|
|
14628
|
+
const success = this.opentui.symbols.editBufferOffsetToPosition(buffer, offset, ptr(cursorBuffer));
|
|
14226
14629
|
if (!success)
|
|
14227
14630
|
return null;
|
|
14228
14631
|
return LogicalCursorStruct.unpack(cursorBuffer);
|
|
@@ -14235,7 +14638,7 @@ class FFIRenderLib {
|
|
|
14235
14638
|
}
|
|
14236
14639
|
editBufferGetTextRange(buffer, startOffset, endOffset, maxLength) {
|
|
14237
14640
|
const outBuffer = new Uint8Array(maxLength);
|
|
14238
|
-
const actualLen = this.opentui.symbols.editBufferGetTextRange(buffer, startOffset, endOffset,
|
|
14641
|
+
const actualLen = this.opentui.symbols.editBufferGetTextRange(buffer, startOffset, endOffset, ptr(outBuffer), maxLength);
|
|
14239
14642
|
const len = typeof actualLen === "bigint" ? Number(actualLen) : actualLen;
|
|
14240
14643
|
if (len === 0)
|
|
14241
14644
|
return null;
|
|
@@ -14243,7 +14646,7 @@ class FFIRenderLib {
|
|
|
14243
14646
|
}
|
|
14244
14647
|
editBufferGetTextRangeByCoords(buffer, startRow, startCol, endRow, endCol, maxLength) {
|
|
14245
14648
|
const outBuffer = new Uint8Array(maxLength);
|
|
14246
|
-
const actualLen = this.opentui.symbols.editBufferGetTextRangeByCoords(buffer, startRow, startCol, endRow, endCol,
|
|
14649
|
+
const actualLen = this.opentui.symbols.editBufferGetTextRangeByCoords(buffer, startRow, startCol, endRow, endCol, ptr(outBuffer), maxLength);
|
|
14247
14650
|
const len = typeof actualLen === "bigint" ? Number(actualLen) : actualLen;
|
|
14248
14651
|
if (len === 0)
|
|
14249
14652
|
return null;
|
|
@@ -14269,7 +14672,7 @@ class FFIRenderLib {
|
|
|
14269
14672
|
editorViewSetLocalSelection(view, anchorX, anchorY, focusX, focusY, bgColor, fgColor, updateCursor, followCursor) {
|
|
14270
14673
|
const bg2 = optionalRgbaPtr(bgColor);
|
|
14271
14674
|
const fg2 = optionalRgbaPtr(fgColor);
|
|
14272
|
-
return this.opentui.symbols.editorViewSetLocalSelection(view, anchorX, anchorY, focusX, focusY, bg2, fg2, updateCursor, followCursor);
|
|
14675
|
+
return this.opentui.symbols.editorViewSetLocalSelection(view, anchorX, anchorY, focusX, focusY, bg2, fg2, ffiBool(updateCursor), ffiBool(followCursor));
|
|
14273
14676
|
}
|
|
14274
14677
|
editorViewUpdateSelection(view, end, bgColor, fgColor) {
|
|
14275
14678
|
const bg2 = optionalRgbaPtr(bgColor);
|
|
@@ -14279,14 +14682,14 @@ class FFIRenderLib {
|
|
|
14279
14682
|
editorViewUpdateLocalSelection(view, anchorX, anchorY, focusX, focusY, bgColor, fgColor, updateCursor, followCursor) {
|
|
14280
14683
|
const bg2 = optionalRgbaPtr(bgColor);
|
|
14281
14684
|
const fg2 = optionalRgbaPtr(fgColor);
|
|
14282
|
-
return this.opentui.symbols.editorViewUpdateLocalSelection(view, anchorX, anchorY, focusX, focusY, bg2, fg2, updateCursor, followCursor);
|
|
14685
|
+
return this.opentui.symbols.editorViewUpdateLocalSelection(view, anchorX, anchorY, focusX, focusY, bg2, fg2, ffiBool(updateCursor), ffiBool(followCursor));
|
|
14283
14686
|
}
|
|
14284
14687
|
editorViewResetLocalSelection(view) {
|
|
14285
14688
|
this.opentui.symbols.editorViewResetLocalSelection(view);
|
|
14286
14689
|
}
|
|
14287
14690
|
editorViewGetSelectedTextBytes(view, maxLength) {
|
|
14288
14691
|
const outBuffer = new Uint8Array(maxLength);
|
|
14289
|
-
const actualLen = this.opentui.symbols.editorViewGetSelectedTextBytes(view,
|
|
14692
|
+
const actualLen = this.opentui.symbols.editorViewGetSelectedTextBytes(view, ptr(outBuffer), maxLength);
|
|
14290
14693
|
const len = typeof actualLen === "bigint" ? Number(actualLen) : actualLen;
|
|
14291
14694
|
if (len === 0)
|
|
14292
14695
|
return null;
|
|
@@ -14295,12 +14698,12 @@ class FFIRenderLib {
|
|
|
14295
14698
|
editorViewGetCursor(view) {
|
|
14296
14699
|
const row = new Uint32Array(1);
|
|
14297
14700
|
const col = new Uint32Array(1);
|
|
14298
|
-
this.opentui.symbols.editorViewGetCursor(view,
|
|
14701
|
+
this.opentui.symbols.editorViewGetCursor(view, ptr(row), ptr(col));
|
|
14299
14702
|
return { row: row[0], col: col[0] };
|
|
14300
14703
|
}
|
|
14301
14704
|
editorViewGetText(view, maxLength) {
|
|
14302
14705
|
const outBuffer = new Uint8Array(maxLength);
|
|
14303
|
-
const actualLen = this.opentui.symbols.editorViewGetText(view,
|
|
14706
|
+
const actualLen = this.opentui.symbols.editorViewGetText(view, ptr(outBuffer), maxLength);
|
|
14304
14707
|
const len = typeof actualLen === "bigint" ? Number(actualLen) : actualLen;
|
|
14305
14708
|
if (len === 0)
|
|
14306
14709
|
return null;
|
|
@@ -14308,7 +14711,7 @@ class FFIRenderLib {
|
|
|
14308
14711
|
}
|
|
14309
14712
|
editorViewGetVisualCursor(view) {
|
|
14310
14713
|
const cursorBuffer = new ArrayBuffer(VisualCursorStruct.size);
|
|
14311
|
-
this.opentui.symbols.editorViewGetVisualCursor(view,
|
|
14714
|
+
this.opentui.symbols.editorViewGetVisualCursor(view, ptr(cursorBuffer));
|
|
14312
14715
|
return VisualCursorStruct.unpack(cursorBuffer);
|
|
14313
14716
|
}
|
|
14314
14717
|
editorViewMoveUpVisual(view) {
|
|
@@ -14325,27 +14728,27 @@ class FFIRenderLib {
|
|
|
14325
14728
|
}
|
|
14326
14729
|
editorViewGetNextWordBoundary(view) {
|
|
14327
14730
|
const cursorBuffer = new ArrayBuffer(VisualCursorStruct.size);
|
|
14328
|
-
this.opentui.symbols.editorViewGetNextWordBoundary(view,
|
|
14731
|
+
this.opentui.symbols.editorViewGetNextWordBoundary(view, ptr(cursorBuffer));
|
|
14329
14732
|
return VisualCursorStruct.unpack(cursorBuffer);
|
|
14330
14733
|
}
|
|
14331
14734
|
editorViewGetPrevWordBoundary(view) {
|
|
14332
14735
|
const cursorBuffer = new ArrayBuffer(VisualCursorStruct.size);
|
|
14333
|
-
this.opentui.symbols.editorViewGetPrevWordBoundary(view,
|
|
14736
|
+
this.opentui.symbols.editorViewGetPrevWordBoundary(view, ptr(cursorBuffer));
|
|
14334
14737
|
return VisualCursorStruct.unpack(cursorBuffer);
|
|
14335
14738
|
}
|
|
14336
14739
|
editorViewGetEOL(view) {
|
|
14337
14740
|
const cursorBuffer = new ArrayBuffer(VisualCursorStruct.size);
|
|
14338
|
-
this.opentui.symbols.editorViewGetEOL(view,
|
|
14741
|
+
this.opentui.symbols.editorViewGetEOL(view, ptr(cursorBuffer));
|
|
14339
14742
|
return VisualCursorStruct.unpack(cursorBuffer);
|
|
14340
14743
|
}
|
|
14341
14744
|
editorViewGetVisualSOL(view) {
|
|
14342
14745
|
const cursorBuffer = new ArrayBuffer(VisualCursorStruct.size);
|
|
14343
|
-
this.opentui.symbols.editorViewGetVisualSOL(view,
|
|
14746
|
+
this.opentui.symbols.editorViewGetVisualSOL(view, ptr(cursorBuffer));
|
|
14344
14747
|
return VisualCursorStruct.unpack(cursorBuffer);
|
|
14345
14748
|
}
|
|
14346
14749
|
editorViewGetVisualEOL(view) {
|
|
14347
14750
|
const cursorBuffer = new ArrayBuffer(VisualCursorStruct.size);
|
|
14348
|
-
this.opentui.symbols.editorViewGetVisualEOL(view,
|
|
14751
|
+
this.opentui.symbols.editorViewGetVisualEOL(view, ptr(cursorBuffer));
|
|
14349
14752
|
return VisualCursorStruct.unpack(cursorBuffer);
|
|
14350
14753
|
}
|
|
14351
14754
|
bufferPushScissorRect(buffer, x, y, width, height) {
|
|
@@ -14371,7 +14774,7 @@ class FFIRenderLib {
|
|
|
14371
14774
|
}
|
|
14372
14775
|
getTerminalCapabilities(renderer) {
|
|
14373
14776
|
const capsBuffer = new ArrayBuffer(TerminalCapabilitiesStruct.size);
|
|
14374
|
-
this.opentui.symbols.getTerminalCapabilities(renderer,
|
|
14777
|
+
this.opentui.symbols.getTerminalCapabilities(renderer, ptr(capsBuffer));
|
|
14375
14778
|
const caps = TerminalCapabilitiesStruct.unpack(capsBuffer);
|
|
14376
14779
|
return {
|
|
14377
14780
|
kitty_keyboard: caps.kitty_keyboard,
|
|
@@ -14390,6 +14793,7 @@ class FFIRenderLib {
|
|
|
14390
14793
|
hyperlinks: caps.hyperlinks,
|
|
14391
14794
|
osc52: caps.osc52,
|
|
14392
14795
|
explicit_cursor_positioning: caps.explicit_cursor_positioning,
|
|
14796
|
+
in_tmux: caps.in_tmux,
|
|
14393
14797
|
terminal: {
|
|
14394
14798
|
name: caps.term_name ?? "",
|
|
14395
14799
|
version: caps.term_version ?? "",
|
|
@@ -14406,7 +14810,7 @@ class FFIRenderLib {
|
|
|
14406
14810
|
const widthMethodCode = widthMethod === "wcwidth" ? 0 : 1;
|
|
14407
14811
|
const outPtrBuffer = new ArrayBuffer(8);
|
|
14408
14812
|
const outLenBuffer = new ArrayBuffer(8);
|
|
14409
|
-
const success = this.opentui.symbols.encodeUnicode(textBytes, textBytes.length,
|
|
14813
|
+
const success = this.opentui.symbols.encodeUnicode(textBytes, textBytes.length, ptr(outPtrBuffer), ptr(outLenBuffer), widthMethodCode);
|
|
14410
14814
|
if (!success) {
|
|
14411
14815
|
return null;
|
|
14412
14816
|
}
|
|
@@ -14418,7 +14822,7 @@ class FFIRenderLib {
|
|
|
14418
14822
|
return { ptr: resultPtr, data: [] };
|
|
14419
14823
|
}
|
|
14420
14824
|
const byteLen = resultLen * EncodedCharStruct.size;
|
|
14421
|
-
const raw =
|
|
14825
|
+
const raw = toArrayBuffer(resultPtr, 0, byteLen);
|
|
14422
14826
|
const data = EncodedCharStruct.unpackList(raw, resultLen);
|
|
14423
14827
|
return { ptr: resultPtr, data };
|
|
14424
14828
|
}
|
|
@@ -14430,37 +14834,37 @@ class FFIRenderLib {
|
|
|
14430
14834
|
}
|
|
14431
14835
|
registerNativeSpanFeedStream(stream, handler) {
|
|
14432
14836
|
const callback = this.ensureNativeSpanFeedCallback();
|
|
14433
|
-
this.nativeSpanFeedHandlers.set(
|
|
14837
|
+
this.nativeSpanFeedHandlers.set(stream, handler);
|
|
14434
14838
|
this.opentui.symbols.streamSetCallback(stream, callback.ptr);
|
|
14435
14839
|
}
|
|
14436
14840
|
unregisterNativeSpanFeedStream(stream) {
|
|
14437
14841
|
this.opentui.symbols.streamSetCallback(stream, null);
|
|
14438
|
-
this.nativeSpanFeedHandlers.delete(
|
|
14842
|
+
this.nativeSpanFeedHandlers.delete(stream);
|
|
14439
14843
|
}
|
|
14440
14844
|
createNativeSpanFeed(options) {
|
|
14441
14845
|
const optionsBuffer = options == null ? null : NativeSpanFeedOptionsStruct.pack(options);
|
|
14442
|
-
const streamPtr = this.opentui.symbols.createNativeSpanFeed(optionsBuffer ?
|
|
14846
|
+
const streamPtr = this.opentui.symbols.createNativeSpanFeed(optionsBuffer ? ptr(optionsBuffer) : null);
|
|
14443
14847
|
if (!streamPtr) {
|
|
14444
14848
|
throw new Error("Failed to create stream");
|
|
14445
14849
|
}
|
|
14446
|
-
return
|
|
14850
|
+
return streamPtr;
|
|
14447
14851
|
}
|
|
14448
14852
|
attachNativeSpanFeed(stream) {
|
|
14449
14853
|
return this.opentui.symbols.attachNativeSpanFeed(stream);
|
|
14450
14854
|
}
|
|
14451
14855
|
destroyNativeSpanFeed(stream) {
|
|
14452
14856
|
this.opentui.symbols.destroyNativeSpanFeed(stream);
|
|
14453
|
-
this.nativeSpanFeedHandlers.delete(
|
|
14857
|
+
this.nativeSpanFeedHandlers.delete(stream);
|
|
14454
14858
|
}
|
|
14455
14859
|
streamWrite(stream, data) {
|
|
14456
14860
|
const bytes = typeof data === "string" ? this.encoder.encode(data) : data;
|
|
14457
|
-
return this.opentui.symbols.streamWrite(stream,
|
|
14861
|
+
return this.opentui.symbols.streamWrite(stream, ptr(bytes), bytes.length);
|
|
14458
14862
|
}
|
|
14459
14863
|
streamCommit(stream) {
|
|
14460
14864
|
return this.opentui.symbols.streamCommit(stream);
|
|
14461
14865
|
}
|
|
14462
14866
|
streamDrainSpans(stream, outBuffer, maxSpans) {
|
|
14463
|
-
const count = this.opentui.symbols.streamDrainSpans(stream,
|
|
14867
|
+
const count = this.opentui.symbols.streamDrainSpans(stream, ptr(outBuffer), maxSpans);
|
|
14464
14868
|
return toNumber(count);
|
|
14465
14869
|
}
|
|
14466
14870
|
streamClose(stream) {
|
|
@@ -14468,11 +14872,11 @@ class FFIRenderLib {
|
|
|
14468
14872
|
}
|
|
14469
14873
|
streamSetOptions(stream, options) {
|
|
14470
14874
|
const optionsBuffer = NativeSpanFeedOptionsStruct.pack(options);
|
|
14471
|
-
return this.opentui.symbols.streamSetOptions(stream,
|
|
14875
|
+
return this.opentui.symbols.streamSetOptions(stream, ptr(optionsBuffer));
|
|
14472
14876
|
}
|
|
14473
14877
|
streamGetStats(stream) {
|
|
14474
14878
|
const statsBuffer = new ArrayBuffer(NativeSpanFeedStatsStruct.size);
|
|
14475
|
-
const status = this.opentui.symbols.streamGetStats(stream,
|
|
14879
|
+
const status = this.opentui.symbols.streamGetStats(stream, ptr(statsBuffer));
|
|
14476
14880
|
if (status !== 0) {
|
|
14477
14881
|
return null;
|
|
14478
14882
|
}
|
|
@@ -14486,7 +14890,7 @@ class FFIRenderLib {
|
|
|
14486
14890
|
}
|
|
14487
14891
|
streamReserve(stream, minLen) {
|
|
14488
14892
|
const reserveBuffer = new ArrayBuffer(ReserveInfoStruct.size);
|
|
14489
|
-
const status = this.opentui.symbols.streamReserve(stream, minLen,
|
|
14893
|
+
const status = this.opentui.symbols.streamReserve(stream, minLen, ptr(reserveBuffer));
|
|
14490
14894
|
if (status !== 0) {
|
|
14491
14895
|
return { status, info: null };
|
|
14492
14896
|
}
|
|
@@ -14527,7 +14931,7 @@ class FFIRenderLib {
|
|
|
14527
14931
|
return;
|
|
14528
14932
|
}
|
|
14529
14933
|
const chunksBuffer = StyledChunkStruct.packList(nonEmptyChunks);
|
|
14530
|
-
this.opentui.symbols.editorViewSetPlaceholderStyledText(view,
|
|
14934
|
+
this.opentui.symbols.editorViewSetPlaceholderStyledText(view, ptr(chunksBuffer), nonEmptyChunks.length);
|
|
14531
14935
|
}
|
|
14532
14936
|
editorViewSetTabIndicator(view, indicator) {
|
|
14533
14937
|
this.opentui.symbols.editorViewSetTabIndicator(view, indicator);
|
|
@@ -14582,9 +14986,9 @@ class TextBuffer {
|
|
|
14582
14986
|
_textBytes;
|
|
14583
14987
|
_memId;
|
|
14584
14988
|
_appendedChunks = [];
|
|
14585
|
-
constructor(lib,
|
|
14989
|
+
constructor(lib, ptr3) {
|
|
14586
14990
|
this.lib = lib;
|
|
14587
|
-
this.bufferPtr =
|
|
14991
|
+
this.bufferPtr = ptr3;
|
|
14588
14992
|
}
|
|
14589
14993
|
static create(widthMethod) {
|
|
14590
14994
|
const lib = resolveRenderLib();
|
|
@@ -16310,9 +16714,9 @@ class TextBufferView {
|
|
|
16310
16714
|
viewPtr;
|
|
16311
16715
|
textBuffer;
|
|
16312
16716
|
_destroyed = false;
|
|
16313
|
-
constructor(lib,
|
|
16717
|
+
constructor(lib, ptr3, textBuffer) {
|
|
16314
16718
|
this.lib = lib;
|
|
16315
|
-
this.viewPtr =
|
|
16719
|
+
this.viewPtr = ptr3;
|
|
16316
16720
|
this.textBuffer = textBuffer;
|
|
16317
16721
|
}
|
|
16318
16722
|
static create(textBuffer) {
|
|
@@ -16452,19 +16856,19 @@ class EditBuffer extends EventEmitter6 {
|
|
|
16452
16856
|
_singleTextBytes = null;
|
|
16453
16857
|
_singleTextMemId = null;
|
|
16454
16858
|
_syntaxStyle;
|
|
16455
|
-
constructor(lib,
|
|
16859
|
+
constructor(lib, ptr3) {
|
|
16456
16860
|
super();
|
|
16457
16861
|
this.lib = lib;
|
|
16458
|
-
this.bufferPtr =
|
|
16459
|
-
this.textBufferPtr = lib.editBufferGetTextBuffer(
|
|
16460
|
-
this.id = lib.editBufferGetId(
|
|
16862
|
+
this.bufferPtr = ptr3;
|
|
16863
|
+
this.textBufferPtr = lib.editBufferGetTextBuffer(ptr3);
|
|
16864
|
+
this.id = lib.editBufferGetId(ptr3);
|
|
16461
16865
|
EditBuffer.registry.set(this.id, this);
|
|
16462
16866
|
EditBuffer.subscribeToNativeEvents(lib);
|
|
16463
16867
|
}
|
|
16464
16868
|
static create(widthMethod) {
|
|
16465
16869
|
const lib = resolveRenderLib();
|
|
16466
|
-
const
|
|
16467
|
-
return new EditBuffer(lib,
|
|
16870
|
+
const ptr3 = lib.createEditBuffer(widthMethod);
|
|
16871
|
+
return new EditBuffer(lib, ptr3);
|
|
16468
16872
|
}
|
|
16469
16873
|
static subscribeToNativeEvents(lib) {
|
|
16470
16874
|
if (EditBuffer.nativeEventsSubscribed)
|
|
@@ -16757,9 +17161,9 @@ class EditorView {
|
|
|
16757
17161
|
_destroyed = false;
|
|
16758
17162
|
_extmarksController;
|
|
16759
17163
|
_textBufferViewPtr;
|
|
16760
|
-
constructor(lib,
|
|
17164
|
+
constructor(lib, ptr3, editBuffer) {
|
|
16761
17165
|
this.lib = lib;
|
|
16762
|
-
this.viewPtr =
|
|
17166
|
+
this.viewPtr = ptr3;
|
|
16763
17167
|
this.editBuffer = editBuffer;
|
|
16764
17168
|
}
|
|
16765
17169
|
static create(editBuffer, viewportWidth, viewportHeight) {
|
|
@@ -16978,14 +17382,14 @@ class SyntaxStyle {
|
|
|
16978
17382
|
nameCache = new Map;
|
|
16979
17383
|
styleDefs = new Map;
|
|
16980
17384
|
mergedCache = new Map;
|
|
16981
|
-
constructor(lib,
|
|
17385
|
+
constructor(lib, ptr3) {
|
|
16982
17386
|
this.lib = lib;
|
|
16983
|
-
this.stylePtr =
|
|
17387
|
+
this.stylePtr = ptr3;
|
|
16984
17388
|
}
|
|
16985
17389
|
static create() {
|
|
16986
17390
|
const lib = resolveRenderLib();
|
|
16987
|
-
const
|
|
16988
|
-
return new SyntaxStyle(lib,
|
|
17391
|
+
const ptr3 = lib.createSyntaxStyle();
|
|
17392
|
+
return new SyntaxStyle(lib, ptr3);
|
|
16989
17393
|
}
|
|
16990
17394
|
static fromTheme(theme) {
|
|
16991
17395
|
const style = SyntaxStyle.create();
|
|
@@ -21085,6 +21489,7 @@ var CliRenderEvents;
|
|
|
21085
21489
|
CliRenderEvents2["FOCUSED_RENDERABLE"] = "focused_renderable";
|
|
21086
21490
|
CliRenderEvents2["FOCUSED_EDITOR"] = "focused_editor";
|
|
21087
21491
|
CliRenderEvents2["THEME_MODE"] = "theme_mode";
|
|
21492
|
+
CliRenderEvents2["PALETTE"] = "palette";
|
|
21088
21493
|
CliRenderEvents2["CAPABILITIES"] = "capabilities";
|
|
21089
21494
|
CliRenderEvents2["SELECTION"] = "selection";
|
|
21090
21495
|
CliRenderEvents2["DEBUG_OVERLAY_TOGGLE"] = "debugOverlay:toggle";
|
|
@@ -21172,6 +21577,7 @@ class CliRenderer extends EventEmitter9 {
|
|
|
21172
21577
|
animationRequest = new Map;
|
|
21173
21578
|
resizeTimeoutId = null;
|
|
21174
21579
|
capabilityTimeoutId = null;
|
|
21580
|
+
xtVersionWaiters = new Set;
|
|
21175
21581
|
splitStartupSeedTimeoutId = null;
|
|
21176
21582
|
pendingSplitStartupCursorSeed = false;
|
|
21177
21583
|
resizeDebounceDelay = 100;
|
|
@@ -21221,11 +21627,11 @@ class CliRenderer extends EventEmitter9 {
|
|
|
21221
21627
|
_openConsoleOnError = true;
|
|
21222
21628
|
_paletteDetector = null;
|
|
21223
21629
|
_paletteCache = new Map;
|
|
21224
|
-
_cachedPalette = null;
|
|
21225
21630
|
_paletteDetectionPromise = null;
|
|
21226
21631
|
_paletteDetectionSize = 0;
|
|
21227
21632
|
_paletteEpoch = 0;
|
|
21228
|
-
|
|
21633
|
+
_nativePaletteSignature = null;
|
|
21634
|
+
_emittedPaletteSignature = null;
|
|
21229
21635
|
_palettePublishGeneration = 0;
|
|
21230
21636
|
_onDestroy;
|
|
21231
21637
|
themeModeState;
|
|
@@ -21344,6 +21750,10 @@ Captured external output:
|
|
|
21344
21750
|
this.themeModeHandler = (sequence) => {
|
|
21345
21751
|
const result = this.themeModeState.handleSequence(sequence);
|
|
21346
21752
|
if (result.changedMode) {
|
|
21753
|
+
this.clearPaletteCache();
|
|
21754
|
+
if (this.shouldSyncNativePaletteState() || this.listenerCount("palette" /* PALETTE */) > 0) {
|
|
21755
|
+
this.refreshPalette();
|
|
21756
|
+
}
|
|
21347
21757
|
this.emit("theme_mode" /* THEME_MODE */, result.changedMode);
|
|
21348
21758
|
}
|
|
21349
21759
|
return result.handled;
|
|
@@ -22510,6 +22920,7 @@ Captured external output:
|
|
|
22510
22920
|
explicitWidthCprActive: false,
|
|
22511
22921
|
startupCursorCprActive: false
|
|
22512
22922
|
}, true);
|
|
22923
|
+
this.resolveXtVersionWaiters();
|
|
22513
22924
|
}, 5000);
|
|
22514
22925
|
if (this._useMouse) {
|
|
22515
22926
|
this.enableMouse();
|
|
@@ -22531,7 +22942,9 @@ Captured external output:
|
|
|
22531
22942
|
}, 120);
|
|
22532
22943
|
}
|
|
22533
22944
|
this.queryPixelResolution();
|
|
22534
|
-
this.
|
|
22945
|
+
if (this.shouldSyncNativePaletteState()) {
|
|
22946
|
+
this.refreshPalette();
|
|
22947
|
+
}
|
|
22535
22948
|
}
|
|
22536
22949
|
stdinListener = ((chunk) => {
|
|
22537
22950
|
const data = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk);
|
|
@@ -22574,6 +22987,9 @@ Captured external output:
|
|
|
22574
22987
|
}
|
|
22575
22988
|
this.lib.processCapabilityResponse(this.rendererPtr, sequence);
|
|
22576
22989
|
this._capabilities = this.lib.getTerminalCapabilities(this.rendererPtr);
|
|
22990
|
+
if (this._capabilities?.terminal?.from_xtversion) {
|
|
22991
|
+
this.resolveXtVersionWaiters();
|
|
22992
|
+
}
|
|
22577
22993
|
if (hasStandardCapabilitySignature) {
|
|
22578
22994
|
this.forceFullRepaintRequested = true;
|
|
22579
22995
|
this.requestRender();
|
|
@@ -23218,6 +23634,7 @@ Captured external output:
|
|
|
23218
23634
|
return;
|
|
23219
23635
|
this._isDestroyed = true;
|
|
23220
23636
|
this._destroyPending = true;
|
|
23637
|
+
this._palettePublishGeneration++;
|
|
23221
23638
|
if (this.rendering) {
|
|
23222
23639
|
this.prepareDestroyDuringRender();
|
|
23223
23640
|
return;
|
|
@@ -23291,10 +23708,10 @@ Captured external output:
|
|
|
23291
23708
|
this._paletteCache.clear();
|
|
23292
23709
|
this._paletteDetectionPromise = null;
|
|
23293
23710
|
this._paletteDetectionSize = 0;
|
|
23294
|
-
this.
|
|
23295
|
-
this.
|
|
23711
|
+
this._nativePaletteSignature = null;
|
|
23712
|
+
this._emittedPaletteSignature = null;
|
|
23296
23713
|
this._paletteEpoch = 0;
|
|
23297
|
-
this.
|
|
23714
|
+
this.resolveXtVersionWaiters();
|
|
23298
23715
|
this.themeModeState.dispose();
|
|
23299
23716
|
this.emit("destroy" /* DESTROY */);
|
|
23300
23717
|
try {
|
|
@@ -23611,36 +24028,72 @@ Captured external output:
|
|
|
23611
24028
|
}
|
|
23612
24029
|
ensurePaletteDetector() {
|
|
23613
24030
|
if (!this._paletteDetector) {
|
|
24031
|
+
const isTmux = Boolean(this.capabilities?.in_tmux || this.capabilities?.terminal?.name?.toLowerCase()?.includes("tmux"));
|
|
23614
24032
|
const isLegacyTmux = this.capabilities?.terminal?.name?.toLowerCase()?.includes("tmux") && this.capabilities?.terminal?.version?.localeCompare("3.6") < 0;
|
|
23615
|
-
this._paletteDetector = createTerminalPalette(
|
|
23616
|
-
|
|
23617
|
-
|
|
24033
|
+
this._paletteDetector = createTerminalPalette({
|
|
24034
|
+
stdin: this.stdin,
|
|
24035
|
+
stdout: this.stdout,
|
|
24036
|
+
writeFn: (data) => this._isDestroyed ? false : this.writeOut(data),
|
|
24037
|
+
isLegacyTmux,
|
|
24038
|
+
isTmux,
|
|
24039
|
+
oscSource: {
|
|
24040
|
+
subscribeOsc: this.subscribeOsc.bind(this)
|
|
24041
|
+
},
|
|
24042
|
+
clock: this.clock
|
|
24043
|
+
});
|
|
23618
24044
|
}
|
|
23619
24045
|
return this._paletteDetector;
|
|
23620
24046
|
}
|
|
23621
24047
|
syncNativePaletteState(colors) {
|
|
23622
24048
|
const signature = buildTerminalPaletteSignature(colors);
|
|
23623
|
-
if (this.
|
|
24049
|
+
if (this._nativePaletteSignature !== signature) {
|
|
23624
24050
|
this._paletteEpoch = this._paletteEpoch + 1 >>> 0;
|
|
23625
24051
|
}
|
|
23626
|
-
this.
|
|
24052
|
+
this._nativePaletteSignature = signature;
|
|
23627
24053
|
const normalized = normalizeTerminalPalette(colors);
|
|
23628
24054
|
this.lib.rendererSetPaletteState(this.rendererPtr, normalized.palette, normalized.defaultForeground, normalized.defaultBackground, this._paletteEpoch);
|
|
23629
24055
|
}
|
|
23630
|
-
|
|
23631
|
-
if (
|
|
24056
|
+
emitPaletteChange(colors) {
|
|
24057
|
+
if (this.listenerCount("palette" /* PALETTE */) === 0)
|
|
23632
24058
|
return;
|
|
24059
|
+
const signature = buildTerminalPaletteSignature(colors);
|
|
24060
|
+
if (this._emittedPaletteSignature === signature)
|
|
24061
|
+
return;
|
|
24062
|
+
this._emittedPaletteSignature = signature;
|
|
24063
|
+
this.emit("palette" /* PALETTE */, colors);
|
|
24064
|
+
}
|
|
24065
|
+
resolveXtVersionWaiters() {
|
|
24066
|
+
if (this.xtVersionWaiters.size === 0)
|
|
24067
|
+
return;
|
|
24068
|
+
const resolvers = [...this.xtVersionWaiters];
|
|
24069
|
+
this.xtVersionWaiters.clear();
|
|
24070
|
+
for (const resolve4 of resolvers) {
|
|
24071
|
+
resolve4();
|
|
24072
|
+
}
|
|
24073
|
+
}
|
|
24074
|
+
waitForXtVersion() {
|
|
24075
|
+
if (this.capabilityTimeoutId === null || this._capabilities?.terminal?.from_xtversion) {
|
|
24076
|
+
return Promise.resolve();
|
|
24077
|
+
}
|
|
24078
|
+
return new Promise((resolve4) => {
|
|
24079
|
+
this.xtVersionWaiters.add(resolve4);
|
|
24080
|
+
});
|
|
24081
|
+
}
|
|
24082
|
+
shouldSyncNativePaletteState() {
|
|
24083
|
+
return Boolean(this._terminalIsSetup && !this._isDestroyed && this._capabilities?.ansi256 && !this._capabilities?.rgb);
|
|
24084
|
+
}
|
|
24085
|
+
refreshPalette() {
|
|
23633
24086
|
const publishGeneration = this._palettePublishGeneration;
|
|
23634
|
-
this.getPalette({ size: NATIVE_PALETTE_QUERY_SIZE }).then((
|
|
23635
|
-
if (this.
|
|
23636
|
-
|
|
23637
|
-
|
|
23638
|
-
|
|
24087
|
+
this.getPalette({ size: NATIVE_PALETTE_QUERY_SIZE }).then(() => {
|
|
24088
|
+
if (this._isDestroyed)
|
|
24089
|
+
return;
|
|
24090
|
+
if (this._palettePublishGeneration === publishGeneration)
|
|
24091
|
+
this.requestRender();
|
|
23639
24092
|
}).catch(() => {});
|
|
23640
24093
|
}
|
|
23641
24094
|
clearPaletteCache() {
|
|
24095
|
+
this._palettePublishGeneration++;
|
|
23642
24096
|
this._paletteCache.clear();
|
|
23643
|
-
this._cachedPalette = null;
|
|
23644
24097
|
}
|
|
23645
24098
|
async getPalette(options) {
|
|
23646
24099
|
if (this._controlState === "explicit_suspended" /* EXPLICIT_SUSPENDED */) {
|
|
@@ -23650,15 +24103,22 @@ Captured external output:
|
|
|
23650
24103
|
const detectionTimeout = options?.timeout;
|
|
23651
24104
|
const cachedPalette = this.getCachedPaletteBySize(requestedSize);
|
|
23652
24105
|
if (cachedPalette) {
|
|
23653
|
-
this._cachedPalette = cachedPalette;
|
|
23654
24106
|
return cachedPalette;
|
|
23655
24107
|
}
|
|
24108
|
+
const terminal = this._capabilities?.terminal;
|
|
24109
|
+
const hasTmuxVersion = terminal?.name?.toLowerCase() === "tmux" && Boolean(terminal.version);
|
|
24110
|
+
if (this._capabilities?.in_tmux && !hasTmuxVersion) {
|
|
24111
|
+
await this.waitForXtVersion();
|
|
24112
|
+
const afterCapabilityWait = this.getCachedPaletteBySize(requestedSize);
|
|
24113
|
+
if (afterCapabilityWait) {
|
|
24114
|
+
return afterCapabilityWait;
|
|
24115
|
+
}
|
|
24116
|
+
}
|
|
23656
24117
|
if (this._paletteDetectionPromise) {
|
|
23657
24118
|
if (this._paletteDetectionSize >= requestedSize) {
|
|
23658
24119
|
return this._paletteDetectionPromise.then((palette) => {
|
|
23659
24120
|
const cached = this.getCachedPaletteBySize(requestedSize);
|
|
23660
24121
|
if (cached) {
|
|
23661
|
-
this._cachedPalette = cached;
|
|
23662
24122
|
return cached;
|
|
23663
24123
|
}
|
|
23664
24124
|
const projected = {
|
|
@@ -23666,14 +24126,12 @@ Captured external output:
|
|
|
23666
24126
|
palette: palette.palette.slice(0, requestedSize)
|
|
23667
24127
|
};
|
|
23668
24128
|
this._paletteCache.set(requestedSize, projected);
|
|
23669
|
-
this._cachedPalette = projected;
|
|
23670
24129
|
return projected;
|
|
23671
24130
|
});
|
|
23672
24131
|
}
|
|
23673
24132
|
await this._paletteDetectionPromise;
|
|
23674
24133
|
const afterWait = this.getCachedPaletteBySize(requestedSize);
|
|
23675
24134
|
if (afterWait) {
|
|
23676
|
-
this._cachedPalette = afterWait;
|
|
23677
24135
|
return afterWait;
|
|
23678
24136
|
}
|
|
23679
24137
|
}
|
|
@@ -23682,14 +24140,14 @@ Captured external output:
|
|
|
23682
24140
|
this._paletteDetectionSize = requestedSize;
|
|
23683
24141
|
this._paletteDetectionPromise = detector.detect({ ...options, timeout: detectionTimeout }).then((result) => {
|
|
23684
24142
|
this._paletteCache.set(result.palette.length, result);
|
|
23685
|
-
this._cachedPalette = result;
|
|
23686
24143
|
this._paletteDetectionPromise = null;
|
|
23687
24144
|
this._paletteDetectionSize = 0;
|
|
23688
|
-
if (this._palettePublishGeneration === publishGeneration) {
|
|
23689
|
-
|
|
24145
|
+
if (!this._isDestroyed && this._palettePublishGeneration === publishGeneration) {
|
|
24146
|
+
this.emitPaletteChange(result);
|
|
24147
|
+
if (this.shouldSyncNativePaletteState() && result.palette.length >= NATIVE_PALETTE_QUERY_SIZE) {
|
|
23690
24148
|
this.syncNativePaletteState(result);
|
|
23691
|
-
} else if (this.
|
|
23692
|
-
this.
|
|
24149
|
+
} else if (this.shouldSyncNativePaletteState() && !this._paletteCache.has(NATIVE_PALETTE_QUERY_SIZE)) {
|
|
24150
|
+
this.refreshPalette();
|
|
23693
24151
|
}
|
|
23694
24152
|
}
|
|
23695
24153
|
return result;
|
|
@@ -23700,12 +24158,11 @@ Captured external output:
|
|
|
23700
24158
|
});
|
|
23701
24159
|
const detected = await this._paletteDetectionPromise;
|
|
23702
24160
|
const finalPalette = this.getCachedPaletteBySize(requestedSize) ?? detected;
|
|
23703
|
-
this._cachedPalette = finalPalette;
|
|
23704
24161
|
return finalPalette;
|
|
23705
24162
|
}
|
|
23706
24163
|
}
|
|
23707
24164
|
|
|
23708
|
-
export {
|
|
24165
|
+
export { __export, __require, MeasureMode, exports_src, isValidBorderStyle, parseBorderStyle, BorderChars, getBorderFromSides, getBorderSides, borderCharsToArray, BorderCharArrays, KeyEvent, PasteEvent, KeyHandler, InternalKeyHandler, DEFAULT_FOREGROUND_RGB, DEFAULT_BACKGROUND_RGB, normalizeIndexedColorIndex, ansi256IndexToRgb, RGBA, normalizeColorValue, hexToRgb, rgbToHex, hsvToRgb, parseColor, fonts, measureText, getCharacterPositions, coordinateToCharacterIndex, renderFontToFrameBuffer, TextAttributes, ATTRIBUTE_BASE_BITS, ATTRIBUTE_BASE_MASK, getBaseAttributes, DebugOverlayCorner, TargetChannel, createTextAttributes, attributesWithLink, getLinkId, 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, link, t, hastToStyledText, SystemClock, nonAlphanumericKeys, terminalNamedSingleStrokeKeys, parseKeypress, LinearScrollAccel, MacOSScrollAccel, parseAlign, parseAlignItems, parseBoxSizing, parseDimension, parseDirection, parseDisplay, parseEdge, parseFlexDirection, parseGutter, parseJustify, parseLogLevel, parseMeasureMode, parseOverflow, parsePositionType, parseUnit, parseWrap, MouseParser, Selection, convertGlobalToLocalSelection, ASCIIFontSelectionHelper, envRegistry, registerEnvVar, clearEnvCache, generateEnvMarkdown, generateEnvColored, env, StdinParser, treeSitterToTextChunks, treeSitterToStyledText, addDefaultParsers, TreeSitterClient, DataPathsManager, getDataPaths, extensionToFiletype, basenameToFiletype, extToFiletype, pathToFiletype, infoStringToFiletype, main, getTreeSitterClient, ExtmarksController, createExtmarksController, TerminalPalette, createTerminalPalette, normalizeTerminalPalette, buildTerminalPaletteSignature, decodePasteBytes, stripAnsiSequences, detectLinks, toArrayBuffer, TextBuffer, SpanInfoStruct, LogLevel2 as LogLevel, setRenderLibPath, resolveRenderLib, OptimizedBuffer, h, isVNode, maybeMakeRenderable, wrapWithDelegates, instantiate, delegate, LayoutEvents, RenderableEvents, isRenderable, BaseRenderable, Renderable, RootRenderable, TextBufferView, EditBuffer, EditorView, convertThemeToStyles, SyntaxStyle, ANSI, BoxRenderable, TextBufferRenderable, CodeRenderable, isTextNodeRenderable, TextNodeRenderable, RootTextNodeRenderable, TextRenderable, defaultKeyAliases, mergeKeyAliases, mergeKeyBindings, getKeyBindingAction, buildKeyBindingsMap, capture, ConsolePosition, TerminalConsole, getObjectsInViewport, EditBufferRenderableEvents, isEditBufferRenderable, EditBufferRenderable, calculateRenderGeometry, buildKittyKeyboardFlags, MouseEvent, MouseButton, createCliRenderer, CliRenderEvents, RendererControlState, CliRenderer };
|
|
23709
24166
|
|
|
23710
|
-
//# debugId=
|
|
23711
|
-
//# sourceMappingURL=index-
|
|
24167
|
+
//# debugId=74349463B90D49D364756E2164756E21
|
|
24168
|
+
//# sourceMappingURL=index-jv9g79dk.js.map
|