@opentui/core 0.1.107 → 0.2.1

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.
@@ -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);
@@ -10857,7 +10827,7 @@ function detectLinks(chunks, context) {
10857
10827
  return chunks;
10858
10828
  }
10859
10829
  // src/zig.ts
10860
- import { dlopen, toArrayBuffer as toArrayBuffer4, JSCallback, ptr as ptr4 } from "bun:ffi";
10830
+ import { dlopen as dlopen2, toArrayBuffer as toArrayBuffer5, JSCallback, ptr as ptr5 } from "bun:ffi";
10861
10831
  import { existsSync as existsSync2, writeFileSync } from "fs";
10862
10832
  import { EventEmitter as EventEmitter4 } from "events";
10863
10833
 
@@ -11975,6 +11945,331 @@ var ReserveInfoStruct = defineStruct([
11975
11945
  })
11976
11946
  });
11977
11947
 
11948
+ // src/platform/ffi.ts
11949
+ import { fileURLToPath as fileURLToPath2 } from "url";
11950
+ var FFIType = {
11951
+ char: "char",
11952
+ int8_t: "int8_t",
11953
+ i8: "i8",
11954
+ uint8_t: "uint8_t",
11955
+ u8: "u8",
11956
+ int16_t: "int16_t",
11957
+ i16: "i16",
11958
+ uint16_t: "uint16_t",
11959
+ u16: "u16",
11960
+ int32_t: "int32_t",
11961
+ i32: "i32",
11962
+ int: "int",
11963
+ uint32_t: "uint32_t",
11964
+ u32: "u32",
11965
+ int64_t: "int64_t",
11966
+ i64: "i64",
11967
+ uint64_t: "uint64_t",
11968
+ u64: "u64",
11969
+ double: "double",
11970
+ f64: "f64",
11971
+ float: "float",
11972
+ f32: "f32",
11973
+ bool: "bool",
11974
+ ptr: "ptr",
11975
+ pointer: "pointer",
11976
+ void: "void",
11977
+ cstring: "cstring",
11978
+ function: "function",
11979
+ usize: "usize",
11980
+ callback: "callback",
11981
+ napi_env: "napi_env",
11982
+ napi_value: "napi_value",
11983
+ buffer: "buffer"
11984
+ };
11985
+ var FFI_UNAVAILABLE = "OpenTUI native FFI is not available for this runtime yet";
11986
+ var BUN_DLOPEN_NULL = "Bun FFI backend does not support dlopen(null)";
11987
+ var LIBRARY_CLOSED = "Cannot create FFI callback after library.close() has been called";
11988
+ var NODE_CALLBACK_THREADSAFE = "Node FFI callbacks are same-thread only and do not support threadsafe callbacks";
11989
+ var NODE_NAPI_UNSUPPORTED = "Node FFI backend does not support Bun N-API FFI types";
11990
+ var NODE_POINTER_OVERRIDE = "Node FFI backend does not support FFIFunction.ptr overrides";
11991
+ var NODE_PTR_VALUE = "node:ffi ptr() only supports ArrayBuffer and ArrayBufferView values backed by ArrayBuffer";
11992
+ var NODE_STRING_RETURN = "Node FFI backend does not normalize string return values (yet)";
11993
+ var NODE_USIZE_UNSUPPORTED = "Node FFI backend does not support usize until (yet)";
11994
+ var POINTER_NEGATIVE = "Pointer must be non-negative";
11995
+ var POINTER_UNSAFE = "Pointer exceeds safe integer range";
11996
+ function unavailable(cause) {
11997
+ throw new Error(FFI_UNAVAILABLE, { cause });
11998
+ }
11999
+ function createUnsupportedBackend(cause) {
12000
+ return {
12001
+ dlopen() {
12002
+ return unavailable(cause);
12003
+ },
12004
+ ptr() {
12005
+ return unavailable(cause);
12006
+ },
12007
+ suffix: "",
12008
+ toArrayBuffer() {
12009
+ return unavailable(cause);
12010
+ }
12011
+ };
12012
+ }
12013
+ var isBun = typeof process !== "undefined" && typeof process.versions === "object" && process.versions !== null && typeof process.versions.bun === "string";
12014
+ var backend = await loadBackend();
12015
+ function importModule(specifier) {
12016
+ return import(specifier);
12017
+ }
12018
+ async function loadBackend() {
12019
+ if (isBun) {
12020
+ return createBunBackend(await importModule("bun:ffi"));
12021
+ }
12022
+ try {
12023
+ const nodeFfi = await importModule("node:ffi");
12024
+ return createNodeBackend(nodeFfi.default ?? nodeFfi);
12025
+ } catch (error) {
12026
+ return createUnsupportedBackend(error);
12027
+ }
12028
+ }
12029
+ function toPointer(value) {
12030
+ if (typeof value === "bigint") {
12031
+ return toSafeNumberPointer(value);
12032
+ }
12033
+ return value;
12034
+ }
12035
+ function toSafeNumberPointer(pointer) {
12036
+ if (pointer < 0n) {
12037
+ throw new Error(POINTER_NEGATIVE);
12038
+ }
12039
+ if (pointer > BigInt(Number.MAX_SAFE_INTEGER)) {
12040
+ throw new Error(POINTER_UNSAFE);
12041
+ }
12042
+ return Number(pointer);
12043
+ }
12044
+ function createManagedCallback(raw, callbacks) {
12045
+ let ptr4 = raw.ptr;
12046
+ let closed = false;
12047
+ const instance = {
12048
+ get ptr() {
12049
+ return ptr4;
12050
+ },
12051
+ get threadsafe() {
12052
+ return raw.threadsafe;
12053
+ },
12054
+ close() {
12055
+ if (closed) {
12056
+ return;
12057
+ }
12058
+ closed = true;
12059
+ callbacks.delete(instance);
12060
+ try {
12061
+ raw.close();
12062
+ } finally {
12063
+ ptr4 = null;
12064
+ }
12065
+ }
12066
+ };
12067
+ callbacks.add(instance);
12068
+ return instance;
12069
+ }
12070
+ function normalizeBunDefinitions(definitions) {
12071
+ return Object.fromEntries(Object.entries(definitions).map(([name, definition]) => [name, normalizeBunDefinition(definition)]));
12072
+ }
12073
+ function normalizeBunDefinition(definition) {
12074
+ return {
12075
+ args: definition.args,
12076
+ returns: definition.returns,
12077
+ ptr: definition.ptr == null ? undefined : toBunPointer(definition.ptr),
12078
+ threadsafe: definition.threadsafe
12079
+ };
12080
+ }
12081
+ function toBunPointer(pointer) {
12082
+ return typeof pointer === "bigint" ? toSafeNumberPointer(pointer) : pointer;
12083
+ }
12084
+ function createBunBackend(bun) {
12085
+ return {
12086
+ dlopen(path5, symbols) {
12087
+ if (path5 === null) {
12088
+ throw new Error(BUN_DLOPEN_NULL);
12089
+ }
12090
+ const library = bun.dlopen(path5, normalizeBunDefinitions(symbols));
12091
+ const callbacks = new Set;
12092
+ let closed = false;
12093
+ return {
12094
+ symbols: library.symbols,
12095
+ createCallback(callback, definition) {
12096
+ if (closed) {
12097
+ throw new Error(LIBRARY_CLOSED);
12098
+ }
12099
+ const raw = new bun.JSCallback(callback, normalizeBunDefinition(definition));
12100
+ return createManagedCallback(raw, callbacks);
12101
+ },
12102
+ close() {
12103
+ if (closed) {
12104
+ return;
12105
+ }
12106
+ closed = true;
12107
+ try {
12108
+ library.close();
12109
+ } finally {
12110
+ for (const callback of [...callbacks]) {
12111
+ callback.close();
12112
+ }
12113
+ }
12114
+ }
12115
+ };
12116
+ },
12117
+ ptr: bun.ptr,
12118
+ suffix: bun.suffix,
12119
+ toArrayBuffer(pointer, offset, length) {
12120
+ return bun.toArrayBuffer(toBunPointer(pointer), offset, length);
12121
+ }
12122
+ };
12123
+ }
12124
+ function createNodeBackend(nodeFfi) {
12125
+ return {
12126
+ dlopen(path5, symbols) {
12127
+ const { lib, functions } = nodeFfi.dlopen(toNodeLibraryPath(path5), normalizeNodeDefinitions(symbols));
12128
+ const callbacks = new Set;
12129
+ let closed = false;
12130
+ let libraryClosed = false;
12131
+ return {
12132
+ symbols: functions,
12133
+ createCallback(callback, definition) {
12134
+ if (closed) {
12135
+ throw new Error(LIBRARY_CLOSED);
12136
+ }
12137
+ if (definition.threadsafe) {
12138
+ throw new Error(NODE_CALLBACK_THREADSAFE);
12139
+ }
12140
+ const callbackPointer = lib.registerCallback(normalizeNodeDefinition(definition), callback);
12141
+ const raw = {
12142
+ ptr: callbackPointer,
12143
+ threadsafe: false,
12144
+ close() {
12145
+ if (!libraryClosed) {
12146
+ lib.unregisterCallback(callbackPointer);
12147
+ }
12148
+ }
12149
+ };
12150
+ return createManagedCallback(raw, callbacks);
12151
+ },
12152
+ close() {
12153
+ if (closed) {
12154
+ return;
12155
+ }
12156
+ closed = true;
12157
+ try {
12158
+ libraryClosed = true;
12159
+ lib.close();
12160
+ } finally {
12161
+ for (const callback of [...callbacks]) {
12162
+ callback.close();
12163
+ }
12164
+ }
12165
+ }
12166
+ };
12167
+ },
12168
+ ptr(value) {
12169
+ if (ArrayBuffer.isView(value)) {
12170
+ if (!(value.buffer instanceof ArrayBuffer)) {
12171
+ throw new TypeError(NODE_PTR_VALUE);
12172
+ }
12173
+ return nodeFfi.getRawPointer(value.buffer) + BigInt(value.byteOffset);
12174
+ }
12175
+ if (value instanceof ArrayBuffer) {
12176
+ return nodeFfi.getRawPointer(value);
12177
+ }
12178
+ throw new TypeError(NODE_PTR_VALUE);
12179
+ },
12180
+ suffix: nodeFfi.suffix,
12181
+ toArrayBuffer(pointer, offset, length) {
12182
+ return nodeFfi.toArrayBuffer(toBigIntPointer(pointer) + BigInt(offset ?? 0), length, false);
12183
+ }
12184
+ };
12185
+ }
12186
+ function toNodeLibraryPath(path5) {
12187
+ return path5 instanceof URL ? fileURLToPath2(path5) : path5;
12188
+ }
12189
+ function normalizeNodeDefinitions(definitions) {
12190
+ return Object.fromEntries(Object.entries(definitions).map(([name, definition]) => [name, normalizeNodeDefinition(definition)]));
12191
+ }
12192
+ function normalizeNodeDefinition(definition) {
12193
+ if (definition.ptr != null) {
12194
+ throw new Error(NODE_POINTER_OVERRIDE);
12195
+ }
12196
+ return {
12197
+ parameters: (definition.args ?? []).map((type) => toNodeFFIType(type, "parameter")),
12198
+ result: toNodeFFIType(definition.returns ?? FFIType.void, "result")
12199
+ };
12200
+ }
12201
+ function toNodeFFIType(type, position) {
12202
+ switch (type) {
12203
+ case FFIType.char:
12204
+ return "char";
12205
+ case FFIType.int8_t:
12206
+ case FFIType.i8:
12207
+ return "i8";
12208
+ case FFIType.uint8_t:
12209
+ case FFIType.u8:
12210
+ return "u8";
12211
+ case FFIType.int16_t:
12212
+ case FFIType.i16:
12213
+ return "i16";
12214
+ case FFIType.uint16_t:
12215
+ case FFIType.u16:
12216
+ return "u16";
12217
+ case FFIType.int32_t:
12218
+ case FFIType.int:
12219
+ case FFIType.i32:
12220
+ return "i32";
12221
+ case FFIType.uint32_t:
12222
+ case FFIType.u32:
12223
+ return "u32";
12224
+ case FFIType.int64_t:
12225
+ case FFIType.i64:
12226
+ return "i64";
12227
+ case FFIType.uint64_t:
12228
+ case FFIType.u64:
12229
+ return "u64";
12230
+ case FFIType.double:
12231
+ case FFIType.f64:
12232
+ return "f64";
12233
+ case FFIType.float:
12234
+ case FFIType.f32:
12235
+ return "f32";
12236
+ case FFIType.bool:
12237
+ return "bool";
12238
+ case FFIType.ptr:
12239
+ case FFIType.pointer:
12240
+ return "pointer";
12241
+ case FFIType.void:
12242
+ return "void";
12243
+ case FFIType.cstring:
12244
+ if (position === "result") {
12245
+ throw new Error(NODE_STRING_RETURN);
12246
+ }
12247
+ return "string";
12248
+ case FFIType.function:
12249
+ case FFIType.callback:
12250
+ return "pointer";
12251
+ case FFIType.usize:
12252
+ throw new Error(NODE_USIZE_UNSUPPORTED);
12253
+ case FFIType.napi_env:
12254
+ case FFIType.napi_value:
12255
+ throw new Error(NODE_NAPI_UNSUPPORTED);
12256
+ case FFIType.buffer:
12257
+ return "buffer";
12258
+ default:
12259
+ return unsupportedNodeFFIType(type);
12260
+ }
12261
+ }
12262
+ function unsupportedNodeFFIType(type) {
12263
+ throw new Error(`Unsupported FFIType for node:ffi: ${String(type)}`);
12264
+ }
12265
+ function toBigIntPointer(pointer) {
12266
+ return typeof pointer === "bigint" ? pointer : BigInt(pointer);
12267
+ }
12268
+ var dlopen = backend.dlopen;
12269
+ var ptr4 = backend.ptr;
12270
+ var suffix = backend.suffix;
12271
+ var toArrayBuffer4 = backend.toArrayBuffer;
12272
+
11978
12273
  // src/zig.ts
11979
12274
  var module = await import(`@opentui/core-${process.platform}-${process.arch}/index.ts`);
11980
12275
  var targetLibPath = module.default;
@@ -12026,27 +12321,19 @@ var MOUSE_STYLE_TO_ID = { default: 0, pointer: 1, text: 2, crosshair: 3, move: 4
12026
12321
  var globalTraceSymbols = null;
12027
12322
  var globalFFILogPath = null;
12028
12323
  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
- }
12324
+ var toPointer2 = toPointer;
12038
12325
  function toNumber(value) {
12039
12326
  return typeof value === "bigint" ? Number(value) : value;
12040
12327
  }
12041
12328
  function rgbaPtr(value) {
12042
- return ptr4(value.buffer);
12329
+ return ptr5(value.buffer);
12043
12330
  }
12044
12331
  function optionalRgbaPtr(value) {
12045
12332
  return value ? rgbaPtr(value) : null;
12046
12333
  }
12047
12334
  function getOpenTUILib(libPath) {
12048
12335
  const resolvedLibPath = libPath || targetLibPath;
12049
- const rawSymbols = dlopen(resolvedLibPath, {
12336
+ const rawSymbols = dlopen2(resolvedLibPath, {
12050
12337
  setLogCallback: {
12051
12338
  args: ["ptr"],
12052
12339
  returns: "void"
@@ -13228,7 +13515,7 @@ class FFIRenderLib {
13228
13515
  if (msgLen === 0 || !msgPtr) {
13229
13516
  return;
13230
13517
  }
13231
- const msgBuffer = toArrayBuffer4(msgPtr, 0, msgLen);
13518
+ const msgBuffer = toArrayBuffer5(msgPtr, 0, msgLen);
13232
13519
  const msgBytes = new Uint8Array(msgBuffer);
13233
13520
  const message = this.decoder.decode(msgBytes);
13234
13521
  switch (level) {
@@ -13274,12 +13561,12 @@ class FFIRenderLib {
13274
13561
  if (nameLen === 0 || !namePtr) {
13275
13562
  return;
13276
13563
  }
13277
- const nameBuffer = toArrayBuffer4(namePtr, 0, nameLen);
13564
+ const nameBuffer = toArrayBuffer5(namePtr, 0, nameLen);
13278
13565
  const nameBytes = new Uint8Array(nameBuffer);
13279
13566
  const eventName = this.decoder.decode(nameBytes);
13280
13567
  let eventData;
13281
13568
  if (dataLen > 0 && dataPtr) {
13282
- eventData = toArrayBuffer4(dataPtr, 0, dataLen).slice();
13569
+ eventData = toArrayBuffer5(dataPtr, 0, dataLen).slice();
13283
13570
  } else {
13284
13571
  eventData = new ArrayBuffer(0);
13285
13572
  }
@@ -13307,7 +13594,7 @@ class FFIRenderLib {
13307
13594
  return this.nativeSpanFeedCallbackWrapper;
13308
13595
  }
13309
13596
  const callback = new JSCallback((streamPtr, eventId, arg0, arg1) => {
13310
- const handler = this.nativeSpanFeedHandlers.get(toPointer(streamPtr));
13597
+ const handler = this.nativeSpanFeedHandlers.get(toPointer2(streamPtr));
13311
13598
  if (handler) {
13312
13599
  handler(eventId, arg0, arg1);
13313
13600
  }
@@ -13390,35 +13677,35 @@ class FFIRenderLib {
13390
13677
  for (let index = 0;index < palette.length; index++) {
13391
13678
  paletteBuffer.set(palette[index].buffer, index * 4);
13392
13679
  }
13393
- this.opentui.symbols.rendererSetPaletteState(renderer, ptr4(paletteBuffer), palette.length, rgbaPtr(defaultForeground), rgbaPtr(defaultBackground), paletteEpoch >>> 0);
13680
+ this.opentui.symbols.rendererSetPaletteState(renderer, ptr5(paletteBuffer), palette.length, rgbaPtr(defaultForeground), rgbaPtr(defaultBackground), paletteEpoch >>> 0);
13394
13681
  }
13395
13682
  bufferGetCharPtr(buffer) {
13396
- const ptr5 = this.opentui.symbols.bufferGetCharPtr(buffer);
13397
- if (!ptr5) {
13683
+ const ptr6 = this.opentui.symbols.bufferGetCharPtr(buffer);
13684
+ if (!ptr6) {
13398
13685
  throw new Error("Failed to get char pointer");
13399
13686
  }
13400
- return ptr5;
13687
+ return ptr6;
13401
13688
  }
13402
13689
  bufferGetFgPtr(buffer) {
13403
- const ptr5 = this.opentui.symbols.bufferGetFgPtr(buffer);
13404
- if (!ptr5) {
13690
+ const ptr6 = this.opentui.symbols.bufferGetFgPtr(buffer);
13691
+ if (!ptr6) {
13405
13692
  throw new Error("Failed to get fg pointer");
13406
13693
  }
13407
- return ptr5;
13694
+ return ptr6;
13408
13695
  }
13409
13696
  bufferGetBgPtr(buffer) {
13410
- const ptr5 = this.opentui.symbols.bufferGetBgPtr(buffer);
13411
- if (!ptr5) {
13697
+ const ptr6 = this.opentui.symbols.bufferGetBgPtr(buffer);
13698
+ if (!ptr6) {
13412
13699
  throw new Error("Failed to get bg pointer");
13413
13700
  }
13414
- return ptr5;
13701
+ return ptr6;
13415
13702
  }
13416
13703
  bufferGetAttributesPtr(buffer) {
13417
- const ptr5 = this.opentui.symbols.bufferGetAttributesPtr(buffer);
13418
- if (!ptr5) {
13704
+ const ptr6 = this.opentui.symbols.bufferGetAttributesPtr(buffer);
13705
+ if (!ptr6) {
13419
13706
  throw new Error("Failed to get attributes pointer");
13420
13707
  }
13421
- return ptr5;
13708
+ return ptr6;
13422
13709
  }
13423
13710
  bufferGetRespectAlpha(buffer) {
13424
13711
  return this.opentui.symbols.bufferGetRespectAlpha(buffer);
@@ -13496,7 +13783,7 @@ class FFIRenderLib {
13496
13783
  drawInner: options.drawInner,
13497
13784
  drawOuter: options.drawOuter
13498
13785
  });
13499
- this.opentui.symbols.bufferDrawGrid(buffer, borderChars, rgbaPtr(borderFg), rgbaPtr(borderBg), columnOffsets, columnCount, rowOffsets, rowCount, ptr4(optionsBuffer));
13786
+ this.opentui.symbols.bufferDrawGrid(buffer, borderChars, rgbaPtr(borderFg), rgbaPtr(borderBg), columnOffsets, columnCount, rowOffsets, rowCount, ptr5(optionsBuffer));
13500
13787
  }
13501
13788
  bufferDrawBox(buffer, x, y, width, height, borderChars, packedOptions, borderColor, backgroundColor, title, bottomTitle) {
13502
13789
  const titleBytes = title ? this.encoder.encode(title) : null;
@@ -13536,7 +13823,7 @@ class FFIRenderLib {
13536
13823
  }
13537
13824
  getCursorState(renderer) {
13538
13825
  const cursorBuffer = new ArrayBuffer(CursorStateStruct.size);
13539
- this.opentui.symbols.getCursorState(renderer, ptr4(cursorBuffer));
13826
+ this.opentui.symbols.getCursorState(renderer, ptr5(cursorBuffer));
13540
13827
  const struct = CursorStateStruct.unpack(cursorBuffer);
13541
13828
  return {
13542
13829
  x: struct.x,
@@ -13552,7 +13839,7 @@ class FFIRenderLib {
13552
13839
  const blinking = options.blinking != null ? options.blinking ? 1 : 0 : 255;
13553
13840
  const cursor = options.cursor != null ? MOUSE_STYLE_TO_ID[options.cursor] : 255;
13554
13841
  const buffer = CursorStyleOptionsStruct.pack({ style, blinking, color: options.color, cursor });
13555
- this.opentui.symbols.setCursorStyleOptions(renderer, ptr4(buffer));
13842
+ this.opentui.symbols.setCursorStyleOptions(renderer, ptr5(buffer));
13556
13843
  }
13557
13844
  render(renderer, force) {
13558
13845
  this.opentui.symbols.render(renderer, force);
@@ -13677,7 +13964,7 @@ class FFIRenderLib {
13677
13964
  const bytes = typeof data === "string" ? new TextEncoder().encode(data) : data;
13678
13965
  if (bytes.length === 0)
13679
13966
  return;
13680
- this.opentui.symbols.writeOut(renderer, ptr4(bytes), bytes.length);
13967
+ this.opentui.symbols.writeOut(renderer, ptr5(bytes), bytes.length);
13681
13968
  }
13682
13969
  createTextBuffer(widthMethod) {
13683
13970
  const widthMethodCode = widthMethod === "wcwidth" ? 0 : 1;
@@ -13755,7 +14042,7 @@ class FFIRenderLib {
13755
14042
  return;
13756
14043
  }
13757
14044
  const chunksBuffer = StyledChunkStruct.packList(chunks);
13758
- this.opentui.symbols.textBufferSetStyledText(buffer, ptr4(chunksBuffer), chunks.length);
14045
+ this.opentui.symbols.textBufferSetStyledText(buffer, ptr5(chunksBuffer), chunks.length);
13759
14046
  }
13760
14047
  textBufferGetLineCount(buffer) {
13761
14048
  return this.opentui.symbols.textBufferGetLineCount(buffer);
@@ -13766,7 +14053,7 @@ class FFIRenderLib {
13766
14053
  }
13767
14054
  getPlainTextBytes(buffer, maxLength) {
13768
14055
  const outBuffer = new Uint8Array(maxLength);
13769
- const actualLen = this.textBufferGetPlainText(buffer, ptr4(outBuffer), maxLength);
14056
+ const actualLen = this.textBufferGetPlainText(buffer, ptr5(outBuffer), maxLength);
13770
14057
  if (actualLen === 0) {
13771
14058
  return null;
13772
14059
  }
@@ -13774,7 +14061,7 @@ class FFIRenderLib {
13774
14061
  }
13775
14062
  textBufferGetTextRange(buffer, startOffset, endOffset, maxLength) {
13776
14063
  const outBuffer = new Uint8Array(maxLength);
13777
- const actualLen = this.opentui.symbols.textBufferGetTextRange(buffer, startOffset, endOffset, ptr4(outBuffer), maxLength);
14064
+ const actualLen = this.opentui.symbols.textBufferGetTextRange(buffer, startOffset, endOffset, ptr5(outBuffer), maxLength);
13778
14065
  const len = typeof actualLen === "bigint" ? Number(actualLen) : actualLen;
13779
14066
  if (len === 0) {
13780
14067
  return null;
@@ -13783,7 +14070,7 @@ class FFIRenderLib {
13783
14070
  }
13784
14071
  textBufferGetTextRangeByCoords(buffer, startRow, startCol, endRow, endCol, maxLength) {
13785
14072
  const outBuffer = new Uint8Array(maxLength);
13786
- const actualLen = this.opentui.symbols.textBufferGetTextRangeByCoords(buffer, startRow, startCol, endRow, endCol, ptr4(outBuffer), maxLength);
14073
+ const actualLen = this.opentui.symbols.textBufferGetTextRangeByCoords(buffer, startRow, startCol, endRow, endCol, ptr5(outBuffer), maxLength);
13787
14074
  const len = typeof actualLen === "bigint" ? Number(actualLen) : actualLen;
13788
14075
  if (len === 0) {
13789
14076
  return null;
@@ -13856,7 +14143,7 @@ class FFIRenderLib {
13856
14143
  }
13857
14144
  textBufferViewGetLineInfo(view) {
13858
14145
  const outBuffer = new ArrayBuffer(LineInfoStruct.size);
13859
- this.textBufferViewGetLineInfoDirect(view, ptr4(outBuffer));
14146
+ this.textBufferViewGetLineInfoDirect(view, ptr5(outBuffer));
13860
14147
  const struct = LineInfoStruct.unpack(outBuffer);
13861
14148
  const lineStartCols = struct.startCols;
13862
14149
  const lineWidthCols = struct.widthCols;
@@ -13871,7 +14158,7 @@ class FFIRenderLib {
13871
14158
  }
13872
14159
  textBufferViewGetLogicalLineInfo(view) {
13873
14160
  const outBuffer = new ArrayBuffer(LineInfoStruct.size);
13874
- this.textBufferViewGetLogicalLineInfoDirect(view, ptr4(outBuffer));
14161
+ this.textBufferViewGetLogicalLineInfoDirect(view, ptr5(outBuffer));
13875
14162
  const struct = LineInfoStruct.unpack(outBuffer);
13876
14163
  const lineStartCols = struct.startCols;
13877
14164
  const lineWidthCols = struct.widthCols;
@@ -13903,7 +14190,7 @@ class FFIRenderLib {
13903
14190
  }
13904
14191
  textBufferViewGetSelectedTextBytes(view, maxLength) {
13905
14192
  const outBuffer = new Uint8Array(maxLength);
13906
- const actualLen = this.textBufferViewGetSelectedText(view, ptr4(outBuffer), maxLength);
14193
+ const actualLen = this.textBufferViewGetSelectedText(view, ptr5(outBuffer), maxLength);
13907
14194
  if (actualLen === 0) {
13908
14195
  return null;
13909
14196
  }
@@ -13911,7 +14198,7 @@ class FFIRenderLib {
13911
14198
  }
13912
14199
  textBufferViewGetPlainTextBytes(view, maxLength) {
13913
14200
  const outBuffer = new Uint8Array(maxLength);
13914
- const actualLen = this.textBufferViewGetPlainText(view, ptr4(outBuffer), maxLength);
14201
+ const actualLen = this.textBufferViewGetPlainText(view, ptr5(outBuffer), maxLength);
13915
14202
  if (actualLen === 0) {
13916
14203
  return null;
13917
14204
  }
@@ -13928,7 +14215,7 @@ class FFIRenderLib {
13928
14215
  }
13929
14216
  textBufferViewMeasureForDimensions(view, width, height) {
13930
14217
  const resultBuffer = new ArrayBuffer(MeasureResultStruct.size);
13931
- const resultPtr = ptr4(new Uint8Array(resultBuffer));
14218
+ const resultPtr = ptr5(new Uint8Array(resultBuffer));
13932
14219
  const success = this.opentui.symbols.textBufferViewMeasureForDimensions(view, width, height, resultPtr);
13933
14220
  if (!success) {
13934
14221
  return null;
@@ -13938,11 +14225,11 @@ class FFIRenderLib {
13938
14225
  }
13939
14226
  textBufferAddHighlightByCharRange(buffer, highlight) {
13940
14227
  const packedHighlight = HighlightStruct.pack(highlight);
13941
- this.opentui.symbols.textBufferAddHighlightByCharRange(buffer, ptr4(packedHighlight));
14228
+ this.opentui.symbols.textBufferAddHighlightByCharRange(buffer, ptr5(packedHighlight));
13942
14229
  }
13943
14230
  textBufferAddHighlight(buffer, lineIdx, highlight) {
13944
14231
  const packedHighlight = HighlightStruct.pack(highlight);
13945
- this.opentui.symbols.textBufferAddHighlight(buffer, lineIdx, ptr4(packedHighlight));
14232
+ this.opentui.symbols.textBufferAddHighlight(buffer, lineIdx, ptr5(packedHighlight));
13946
14233
  }
13947
14234
  textBufferRemoveHighlightsByRef(buffer, hlRef) {
13948
14235
  this.opentui.symbols.textBufferRemoveHighlightsByRef(buffer, hlRef);
@@ -13958,12 +14245,12 @@ class FFIRenderLib {
13958
14245
  }
13959
14246
  textBufferGetLineHighlights(buffer, lineIdx) {
13960
14247
  const outCountBuf = new BigUint64Array(1);
13961
- const nativePtr = this.opentui.symbols.textBufferGetLineHighlightsPtr(buffer, lineIdx, ptr4(outCountBuf));
14248
+ const nativePtr = this.opentui.symbols.textBufferGetLineHighlightsPtr(buffer, lineIdx, ptr5(outCountBuf));
13962
14249
  if (!nativePtr)
13963
14250
  return [];
13964
14251
  const count = Number(outCountBuf[0]);
13965
14252
  const byteLen = count * HighlightStruct.size;
13966
- const raw = toArrayBuffer4(nativePtr, 0, byteLen);
14253
+ const raw = toArrayBuffer5(nativePtr, 0, byteLen);
13967
14254
  const results = HighlightStruct.unpackList(raw, count);
13968
14255
  this.opentui.symbols.textBufferFreeLineHighlights(nativePtr, count);
13969
14256
  return results;
@@ -13977,7 +14264,7 @@ class FFIRenderLib {
13977
14264
  }
13978
14265
  getBuildOptions() {
13979
14266
  const optionsBuffer = new ArrayBuffer(BuildOptionsStruct.size);
13980
- this.opentui.symbols.getBuildOptions(ptr4(optionsBuffer));
14267
+ this.opentui.symbols.getBuildOptions(ptr5(optionsBuffer));
13981
14268
  const options = BuildOptionsStruct.unpack(optionsBuffer);
13982
14269
  return {
13983
14270
  gpaSafeStats: !!options.gpaSafeStats,
@@ -13986,7 +14273,7 @@ class FFIRenderLib {
13986
14273
  }
13987
14274
  getAllocatorStats() {
13988
14275
  const statsBuffer = new ArrayBuffer(AllocatorStatsStruct.size);
13989
- this.opentui.symbols.getAllocatorStats(ptr4(statsBuffer));
14276
+ this.opentui.symbols.getAllocatorStats(ptr5(statsBuffer));
13990
14277
  const stats = AllocatorStatsStruct.unpack(statsBuffer);
13991
14278
  return {
13992
14279
  totalRequestedBytes: toNumber(stats.totalRequestedBytes),
@@ -14023,7 +14310,7 @@ class FFIRenderLib {
14023
14310
  const y = new Uint32Array(1);
14024
14311
  const width = new Uint32Array(1);
14025
14312
  const height = new Uint32Array(1);
14026
- this.opentui.symbols.editorViewGetViewport(view, ptr4(x), ptr4(y), ptr4(width), ptr4(height));
14313
+ this.opentui.symbols.editorViewGetViewport(view, ptr5(x), ptr5(y), ptr5(width), ptr5(height));
14027
14314
  return {
14028
14315
  offsetX: x[0],
14029
14316
  offsetY: y[0],
@@ -14053,7 +14340,7 @@ class FFIRenderLib {
14053
14340
  }
14054
14341
  editorViewGetLineInfo(view) {
14055
14342
  const outBuffer = new ArrayBuffer(LineInfoStruct.size);
14056
- this.opentui.symbols.editorViewGetLineInfoDirect(view, ptr4(outBuffer));
14343
+ this.opentui.symbols.editorViewGetLineInfoDirect(view, ptr5(outBuffer));
14057
14344
  const struct = LineInfoStruct.unpack(outBuffer);
14058
14345
  const lineStartCols = struct.startCols;
14059
14346
  const lineWidthCols = struct.widthCols;
@@ -14068,7 +14355,7 @@ class FFIRenderLib {
14068
14355
  }
14069
14356
  editorViewGetLogicalLineInfo(view) {
14070
14357
  const outBuffer = new ArrayBuffer(LineInfoStruct.size);
14071
- this.opentui.symbols.editorViewGetLogicalLineInfoDirect(view, ptr4(outBuffer));
14358
+ this.opentui.symbols.editorViewGetLogicalLineInfoDirect(view, ptr5(outBuffer));
14072
14359
  const struct = LineInfoStruct.unpack(outBuffer);
14073
14360
  const lineStartCols = struct.startCols;
14074
14361
  const lineWidthCols = struct.widthCols;
@@ -14106,7 +14393,7 @@ class FFIRenderLib {
14106
14393
  }
14107
14394
  editBufferGetText(buffer, maxLength) {
14108
14395
  const outBuffer = new Uint8Array(maxLength);
14109
- const actualLen = this.opentui.symbols.editBufferGetText(buffer, ptr4(outBuffer), maxLength);
14396
+ const actualLen = this.opentui.symbols.editBufferGetText(buffer, ptr5(outBuffer), maxLength);
14110
14397
  const len = typeof actualLen === "bigint" ? Number(actualLen) : actualLen;
14111
14398
  if (len === 0)
14112
14399
  return null;
@@ -14161,7 +14448,7 @@ class FFIRenderLib {
14161
14448
  }
14162
14449
  editBufferGetCursorPosition(buffer) {
14163
14450
  const cursorBuffer = new ArrayBuffer(LogicalCursorStruct.size);
14164
- this.opentui.symbols.editBufferGetCursorPosition(buffer, ptr4(cursorBuffer));
14451
+ this.opentui.symbols.editBufferGetCursorPosition(buffer, ptr5(cursorBuffer));
14165
14452
  return LogicalCursorStruct.unpack(cursorBuffer);
14166
14453
  }
14167
14454
  editBufferGetId(buffer) {
@@ -14179,7 +14466,7 @@ class FFIRenderLib {
14179
14466
  }
14180
14467
  editBufferUndo(buffer, maxLength) {
14181
14468
  const outBuffer = new Uint8Array(maxLength);
14182
- const actualLen = this.opentui.symbols.editBufferUndo(buffer, ptr4(outBuffer), maxLength);
14469
+ const actualLen = this.opentui.symbols.editBufferUndo(buffer, ptr5(outBuffer), maxLength);
14183
14470
  const len = typeof actualLen === "bigint" ? Number(actualLen) : actualLen;
14184
14471
  if (len === 0)
14185
14472
  return null;
@@ -14187,7 +14474,7 @@ class FFIRenderLib {
14187
14474
  }
14188
14475
  editBufferRedo(buffer, maxLength) {
14189
14476
  const outBuffer = new Uint8Array(maxLength);
14190
- const actualLen = this.opentui.symbols.editBufferRedo(buffer, ptr4(outBuffer), maxLength);
14477
+ const actualLen = this.opentui.symbols.editBufferRedo(buffer, ptr5(outBuffer), maxLength);
14191
14478
  const len = typeof actualLen === "bigint" ? Number(actualLen) : actualLen;
14192
14479
  if (len === 0)
14193
14480
  return null;
@@ -14207,22 +14494,22 @@ class FFIRenderLib {
14207
14494
  }
14208
14495
  editBufferGetNextWordBoundary(buffer) {
14209
14496
  const cursorBuffer = new ArrayBuffer(LogicalCursorStruct.size);
14210
- this.opentui.symbols.editBufferGetNextWordBoundary(buffer, ptr4(cursorBuffer));
14497
+ this.opentui.symbols.editBufferGetNextWordBoundary(buffer, ptr5(cursorBuffer));
14211
14498
  return LogicalCursorStruct.unpack(cursorBuffer);
14212
14499
  }
14213
14500
  editBufferGetPrevWordBoundary(buffer) {
14214
14501
  const cursorBuffer = new ArrayBuffer(LogicalCursorStruct.size);
14215
- this.opentui.symbols.editBufferGetPrevWordBoundary(buffer, ptr4(cursorBuffer));
14502
+ this.opentui.symbols.editBufferGetPrevWordBoundary(buffer, ptr5(cursorBuffer));
14216
14503
  return LogicalCursorStruct.unpack(cursorBuffer);
14217
14504
  }
14218
14505
  editBufferGetEOL(buffer) {
14219
14506
  const cursorBuffer = new ArrayBuffer(LogicalCursorStruct.size);
14220
- this.opentui.symbols.editBufferGetEOL(buffer, ptr4(cursorBuffer));
14507
+ this.opentui.symbols.editBufferGetEOL(buffer, ptr5(cursorBuffer));
14221
14508
  return LogicalCursorStruct.unpack(cursorBuffer);
14222
14509
  }
14223
14510
  editBufferOffsetToPosition(buffer, offset) {
14224
14511
  const cursorBuffer = new ArrayBuffer(LogicalCursorStruct.size);
14225
- const success = this.opentui.symbols.editBufferOffsetToPosition(buffer, offset, ptr4(cursorBuffer));
14512
+ const success = this.opentui.symbols.editBufferOffsetToPosition(buffer, offset, ptr5(cursorBuffer));
14226
14513
  if (!success)
14227
14514
  return null;
14228
14515
  return LogicalCursorStruct.unpack(cursorBuffer);
@@ -14235,7 +14522,7 @@ class FFIRenderLib {
14235
14522
  }
14236
14523
  editBufferGetTextRange(buffer, startOffset, endOffset, maxLength) {
14237
14524
  const outBuffer = new Uint8Array(maxLength);
14238
- const actualLen = this.opentui.symbols.editBufferGetTextRange(buffer, startOffset, endOffset, ptr4(outBuffer), maxLength);
14525
+ const actualLen = this.opentui.symbols.editBufferGetTextRange(buffer, startOffset, endOffset, ptr5(outBuffer), maxLength);
14239
14526
  const len = typeof actualLen === "bigint" ? Number(actualLen) : actualLen;
14240
14527
  if (len === 0)
14241
14528
  return null;
@@ -14243,7 +14530,7 @@ class FFIRenderLib {
14243
14530
  }
14244
14531
  editBufferGetTextRangeByCoords(buffer, startRow, startCol, endRow, endCol, maxLength) {
14245
14532
  const outBuffer = new Uint8Array(maxLength);
14246
- const actualLen = this.opentui.symbols.editBufferGetTextRangeByCoords(buffer, startRow, startCol, endRow, endCol, ptr4(outBuffer), maxLength);
14533
+ const actualLen = this.opentui.symbols.editBufferGetTextRangeByCoords(buffer, startRow, startCol, endRow, endCol, ptr5(outBuffer), maxLength);
14247
14534
  const len = typeof actualLen === "bigint" ? Number(actualLen) : actualLen;
14248
14535
  if (len === 0)
14249
14536
  return null;
@@ -14286,7 +14573,7 @@ class FFIRenderLib {
14286
14573
  }
14287
14574
  editorViewGetSelectedTextBytes(view, maxLength) {
14288
14575
  const outBuffer = new Uint8Array(maxLength);
14289
- const actualLen = this.opentui.symbols.editorViewGetSelectedTextBytes(view, ptr4(outBuffer), maxLength);
14576
+ const actualLen = this.opentui.symbols.editorViewGetSelectedTextBytes(view, ptr5(outBuffer), maxLength);
14290
14577
  const len = typeof actualLen === "bigint" ? Number(actualLen) : actualLen;
14291
14578
  if (len === 0)
14292
14579
  return null;
@@ -14295,12 +14582,12 @@ class FFIRenderLib {
14295
14582
  editorViewGetCursor(view) {
14296
14583
  const row = new Uint32Array(1);
14297
14584
  const col = new Uint32Array(1);
14298
- this.opentui.symbols.editorViewGetCursor(view, ptr4(row), ptr4(col));
14585
+ this.opentui.symbols.editorViewGetCursor(view, ptr5(row), ptr5(col));
14299
14586
  return { row: row[0], col: col[0] };
14300
14587
  }
14301
14588
  editorViewGetText(view, maxLength) {
14302
14589
  const outBuffer = new Uint8Array(maxLength);
14303
- const actualLen = this.opentui.symbols.editorViewGetText(view, ptr4(outBuffer), maxLength);
14590
+ const actualLen = this.opentui.symbols.editorViewGetText(view, ptr5(outBuffer), maxLength);
14304
14591
  const len = typeof actualLen === "bigint" ? Number(actualLen) : actualLen;
14305
14592
  if (len === 0)
14306
14593
  return null;
@@ -14308,7 +14595,7 @@ class FFIRenderLib {
14308
14595
  }
14309
14596
  editorViewGetVisualCursor(view) {
14310
14597
  const cursorBuffer = new ArrayBuffer(VisualCursorStruct.size);
14311
- this.opentui.symbols.editorViewGetVisualCursor(view, ptr4(cursorBuffer));
14598
+ this.opentui.symbols.editorViewGetVisualCursor(view, ptr5(cursorBuffer));
14312
14599
  return VisualCursorStruct.unpack(cursorBuffer);
14313
14600
  }
14314
14601
  editorViewMoveUpVisual(view) {
@@ -14325,27 +14612,27 @@ class FFIRenderLib {
14325
14612
  }
14326
14613
  editorViewGetNextWordBoundary(view) {
14327
14614
  const cursorBuffer = new ArrayBuffer(VisualCursorStruct.size);
14328
- this.opentui.symbols.editorViewGetNextWordBoundary(view, ptr4(cursorBuffer));
14615
+ this.opentui.symbols.editorViewGetNextWordBoundary(view, ptr5(cursorBuffer));
14329
14616
  return VisualCursorStruct.unpack(cursorBuffer);
14330
14617
  }
14331
14618
  editorViewGetPrevWordBoundary(view) {
14332
14619
  const cursorBuffer = new ArrayBuffer(VisualCursorStruct.size);
14333
- this.opentui.symbols.editorViewGetPrevWordBoundary(view, ptr4(cursorBuffer));
14620
+ this.opentui.symbols.editorViewGetPrevWordBoundary(view, ptr5(cursorBuffer));
14334
14621
  return VisualCursorStruct.unpack(cursorBuffer);
14335
14622
  }
14336
14623
  editorViewGetEOL(view) {
14337
14624
  const cursorBuffer = new ArrayBuffer(VisualCursorStruct.size);
14338
- this.opentui.symbols.editorViewGetEOL(view, ptr4(cursorBuffer));
14625
+ this.opentui.symbols.editorViewGetEOL(view, ptr5(cursorBuffer));
14339
14626
  return VisualCursorStruct.unpack(cursorBuffer);
14340
14627
  }
14341
14628
  editorViewGetVisualSOL(view) {
14342
14629
  const cursorBuffer = new ArrayBuffer(VisualCursorStruct.size);
14343
- this.opentui.symbols.editorViewGetVisualSOL(view, ptr4(cursorBuffer));
14630
+ this.opentui.symbols.editorViewGetVisualSOL(view, ptr5(cursorBuffer));
14344
14631
  return VisualCursorStruct.unpack(cursorBuffer);
14345
14632
  }
14346
14633
  editorViewGetVisualEOL(view) {
14347
14634
  const cursorBuffer = new ArrayBuffer(VisualCursorStruct.size);
14348
- this.opentui.symbols.editorViewGetVisualEOL(view, ptr4(cursorBuffer));
14635
+ this.opentui.symbols.editorViewGetVisualEOL(view, ptr5(cursorBuffer));
14349
14636
  return VisualCursorStruct.unpack(cursorBuffer);
14350
14637
  }
14351
14638
  bufferPushScissorRect(buffer, x, y, width, height) {
@@ -14371,7 +14658,7 @@ class FFIRenderLib {
14371
14658
  }
14372
14659
  getTerminalCapabilities(renderer) {
14373
14660
  const capsBuffer = new ArrayBuffer(TerminalCapabilitiesStruct.size);
14374
- this.opentui.symbols.getTerminalCapabilities(renderer, ptr4(capsBuffer));
14661
+ this.opentui.symbols.getTerminalCapabilities(renderer, ptr5(capsBuffer));
14375
14662
  const caps = TerminalCapabilitiesStruct.unpack(capsBuffer);
14376
14663
  return {
14377
14664
  kitty_keyboard: caps.kitty_keyboard,
@@ -14406,7 +14693,7 @@ class FFIRenderLib {
14406
14693
  const widthMethodCode = widthMethod === "wcwidth" ? 0 : 1;
14407
14694
  const outPtrBuffer = new ArrayBuffer(8);
14408
14695
  const outLenBuffer = new ArrayBuffer(8);
14409
- const success = this.opentui.symbols.encodeUnicode(textBytes, textBytes.length, ptr4(outPtrBuffer), ptr4(outLenBuffer), widthMethodCode);
14696
+ const success = this.opentui.symbols.encodeUnicode(textBytes, textBytes.length, ptr5(outPtrBuffer), ptr5(outLenBuffer), widthMethodCode);
14410
14697
  if (!success) {
14411
14698
  return null;
14412
14699
  }
@@ -14418,7 +14705,7 @@ class FFIRenderLib {
14418
14705
  return { ptr: resultPtr, data: [] };
14419
14706
  }
14420
14707
  const byteLen = resultLen * EncodedCharStruct.size;
14421
- const raw = toArrayBuffer4(resultPtr, 0, byteLen);
14708
+ const raw = toArrayBuffer5(resultPtr, 0, byteLen);
14422
14709
  const data = EncodedCharStruct.unpackList(raw, resultLen);
14423
14710
  return { ptr: resultPtr, data };
14424
14711
  }
@@ -14430,37 +14717,37 @@ class FFIRenderLib {
14430
14717
  }
14431
14718
  registerNativeSpanFeedStream(stream, handler) {
14432
14719
  const callback = this.ensureNativeSpanFeedCallback();
14433
- this.nativeSpanFeedHandlers.set(toPointer(stream), handler);
14720
+ this.nativeSpanFeedHandlers.set(toPointer2(stream), handler);
14434
14721
  this.opentui.symbols.streamSetCallback(stream, callback.ptr);
14435
14722
  }
14436
14723
  unregisterNativeSpanFeedStream(stream) {
14437
14724
  this.opentui.symbols.streamSetCallback(stream, null);
14438
- this.nativeSpanFeedHandlers.delete(toPointer(stream));
14725
+ this.nativeSpanFeedHandlers.delete(toPointer2(stream));
14439
14726
  }
14440
14727
  createNativeSpanFeed(options) {
14441
14728
  const optionsBuffer = options == null ? null : NativeSpanFeedOptionsStruct.pack(options);
14442
- const streamPtr = this.opentui.symbols.createNativeSpanFeed(optionsBuffer ? ptr4(optionsBuffer) : null);
14729
+ const streamPtr = this.opentui.symbols.createNativeSpanFeed(optionsBuffer ? ptr5(optionsBuffer) : null);
14443
14730
  if (!streamPtr) {
14444
14731
  throw new Error("Failed to create stream");
14445
14732
  }
14446
- return toPointer(streamPtr);
14733
+ return toPointer2(streamPtr);
14447
14734
  }
14448
14735
  attachNativeSpanFeed(stream) {
14449
14736
  return this.opentui.symbols.attachNativeSpanFeed(stream);
14450
14737
  }
14451
14738
  destroyNativeSpanFeed(stream) {
14452
14739
  this.opentui.symbols.destroyNativeSpanFeed(stream);
14453
- this.nativeSpanFeedHandlers.delete(toPointer(stream));
14740
+ this.nativeSpanFeedHandlers.delete(toPointer2(stream));
14454
14741
  }
14455
14742
  streamWrite(stream, data) {
14456
14743
  const bytes = typeof data === "string" ? this.encoder.encode(data) : data;
14457
- return this.opentui.symbols.streamWrite(stream, ptr4(bytes), bytes.length);
14744
+ return this.opentui.symbols.streamWrite(stream, ptr5(bytes), bytes.length);
14458
14745
  }
14459
14746
  streamCommit(stream) {
14460
14747
  return this.opentui.symbols.streamCommit(stream);
14461
14748
  }
14462
14749
  streamDrainSpans(stream, outBuffer, maxSpans) {
14463
- const count = this.opentui.symbols.streamDrainSpans(stream, ptr4(outBuffer), maxSpans);
14750
+ const count = this.opentui.symbols.streamDrainSpans(stream, ptr5(outBuffer), maxSpans);
14464
14751
  return toNumber(count);
14465
14752
  }
14466
14753
  streamClose(stream) {
@@ -14468,11 +14755,11 @@ class FFIRenderLib {
14468
14755
  }
14469
14756
  streamSetOptions(stream, options) {
14470
14757
  const optionsBuffer = NativeSpanFeedOptionsStruct.pack(options);
14471
- return this.opentui.symbols.streamSetOptions(stream, ptr4(optionsBuffer));
14758
+ return this.opentui.symbols.streamSetOptions(stream, ptr5(optionsBuffer));
14472
14759
  }
14473
14760
  streamGetStats(stream) {
14474
14761
  const statsBuffer = new ArrayBuffer(NativeSpanFeedStatsStruct.size);
14475
- const status = this.opentui.symbols.streamGetStats(stream, ptr4(statsBuffer));
14762
+ const status = this.opentui.symbols.streamGetStats(stream, ptr5(statsBuffer));
14476
14763
  if (status !== 0) {
14477
14764
  return null;
14478
14765
  }
@@ -14486,7 +14773,7 @@ class FFIRenderLib {
14486
14773
  }
14487
14774
  streamReserve(stream, minLen) {
14488
14775
  const reserveBuffer = new ArrayBuffer(ReserveInfoStruct.size);
14489
- const status = this.opentui.symbols.streamReserve(stream, minLen, ptr4(reserveBuffer));
14776
+ const status = this.opentui.symbols.streamReserve(stream, minLen, ptr5(reserveBuffer));
14490
14777
  if (status !== 0) {
14491
14778
  return { status, info: null };
14492
14779
  }
@@ -14527,7 +14814,7 @@ class FFIRenderLib {
14527
14814
  return;
14528
14815
  }
14529
14816
  const chunksBuffer = StyledChunkStruct.packList(nonEmptyChunks);
14530
- this.opentui.symbols.editorViewSetPlaceholderStyledText(view, ptr4(chunksBuffer), nonEmptyChunks.length);
14817
+ this.opentui.symbols.editorViewSetPlaceholderStyledText(view, ptr5(chunksBuffer), nonEmptyChunks.length);
14531
14818
  }
14532
14819
  editorViewSetTabIndicator(view, indicator) {
14533
14820
  this.opentui.symbols.editorViewSetTabIndicator(view, indicator);
@@ -14582,9 +14869,9 @@ class TextBuffer {
14582
14869
  _textBytes;
14583
14870
  _memId;
14584
14871
  _appendedChunks = [];
14585
- constructor(lib, ptr5) {
14872
+ constructor(lib, ptr6) {
14586
14873
  this.lib = lib;
14587
- this.bufferPtr = ptr5;
14874
+ this.bufferPtr = ptr6;
14588
14875
  }
14589
14876
  static create(widthMethod) {
14590
14877
  const lib = resolveRenderLib();
@@ -16310,9 +16597,9 @@ class TextBufferView {
16310
16597
  viewPtr;
16311
16598
  textBuffer;
16312
16599
  _destroyed = false;
16313
- constructor(lib, ptr5, textBuffer) {
16600
+ constructor(lib, ptr6, textBuffer) {
16314
16601
  this.lib = lib;
16315
- this.viewPtr = ptr5;
16602
+ this.viewPtr = ptr6;
16316
16603
  this.textBuffer = textBuffer;
16317
16604
  }
16318
16605
  static create(textBuffer) {
@@ -16452,19 +16739,19 @@ class EditBuffer extends EventEmitter6 {
16452
16739
  _singleTextBytes = null;
16453
16740
  _singleTextMemId = null;
16454
16741
  _syntaxStyle;
16455
- constructor(lib, ptr5) {
16742
+ constructor(lib, ptr6) {
16456
16743
  super();
16457
16744
  this.lib = lib;
16458
- this.bufferPtr = ptr5;
16459
- this.textBufferPtr = lib.editBufferGetTextBuffer(ptr5);
16460
- this.id = lib.editBufferGetId(ptr5);
16745
+ this.bufferPtr = ptr6;
16746
+ this.textBufferPtr = lib.editBufferGetTextBuffer(ptr6);
16747
+ this.id = lib.editBufferGetId(ptr6);
16461
16748
  EditBuffer.registry.set(this.id, this);
16462
16749
  EditBuffer.subscribeToNativeEvents(lib);
16463
16750
  }
16464
16751
  static create(widthMethod) {
16465
16752
  const lib = resolveRenderLib();
16466
- const ptr5 = lib.createEditBuffer(widthMethod);
16467
- return new EditBuffer(lib, ptr5);
16753
+ const ptr6 = lib.createEditBuffer(widthMethod);
16754
+ return new EditBuffer(lib, ptr6);
16468
16755
  }
16469
16756
  static subscribeToNativeEvents(lib) {
16470
16757
  if (EditBuffer.nativeEventsSubscribed)
@@ -16757,9 +17044,9 @@ class EditorView {
16757
17044
  _destroyed = false;
16758
17045
  _extmarksController;
16759
17046
  _textBufferViewPtr;
16760
- constructor(lib, ptr5, editBuffer) {
17047
+ constructor(lib, ptr6, editBuffer) {
16761
17048
  this.lib = lib;
16762
- this.viewPtr = ptr5;
17049
+ this.viewPtr = ptr6;
16763
17050
  this.editBuffer = editBuffer;
16764
17051
  }
16765
17052
  static create(editBuffer, viewportWidth, viewportHeight) {
@@ -16978,14 +17265,14 @@ class SyntaxStyle {
16978
17265
  nameCache = new Map;
16979
17266
  styleDefs = new Map;
16980
17267
  mergedCache = new Map;
16981
- constructor(lib, ptr5) {
17268
+ constructor(lib, ptr6) {
16982
17269
  this.lib = lib;
16983
- this.stylePtr = ptr5;
17270
+ this.stylePtr = ptr6;
16984
17271
  }
16985
17272
  static create() {
16986
17273
  const lib = resolveRenderLib();
16987
- const ptr5 = lib.createSyntaxStyle();
16988
- return new SyntaxStyle(lib, ptr5);
17274
+ const ptr6 = lib.createSyntaxStyle();
17275
+ return new SyntaxStyle(lib, ptr6);
16989
17276
  }
16990
17277
  static fromTheme(theme) {
16991
17278
  const style = SyntaxStyle.create();
@@ -23218,6 +23505,7 @@ Captured external output:
23218
23505
  return;
23219
23506
  this._isDestroyed = true;
23220
23507
  this._destroyPending = true;
23508
+ this._palettePublishGeneration++;
23221
23509
  if (this.rendering) {
23222
23510
  this.prepareDestroyDuringRender();
23223
23511
  return;
@@ -23294,7 +23582,6 @@ Captured external output:
23294
23582
  this._cachedPalette = null;
23295
23583
  this._publishedPaletteSignature = null;
23296
23584
  this._paletteEpoch = 0;
23297
- this._palettePublishGeneration = 0;
23298
23585
  this.themeModeState.dispose();
23299
23586
  this.emit("destroy" /* DESTROY */);
23300
23587
  try {
@@ -23612,7 +23899,7 @@ Captured external output:
23612
23899
  ensurePaletteDetector() {
23613
23900
  if (!this._paletteDetector) {
23614
23901
  const isLegacyTmux = this.capabilities?.terminal?.name?.toLowerCase()?.includes("tmux") && this.capabilities?.terminal?.version?.localeCompare("3.6") < 0;
23615
- this._paletteDetector = createTerminalPalette(this.stdin, this.stdout, this.writeOut.bind(this), isLegacyTmux, {
23902
+ this._paletteDetector = createTerminalPalette(this.stdin, this.stdout, (data) => this._isDestroyed ? false : this.writeOut(data), isLegacyTmux, {
23616
23903
  subscribeOsc: this.subscribeOsc.bind(this)
23617
23904
  }, this.clock);
23618
23905
  }
@@ -23632,9 +23919,13 @@ Captured external output:
23632
23919
  return;
23633
23920
  const publishGeneration = this._palettePublishGeneration;
23634
23921
  this.getPalette({ size: NATIVE_PALETTE_QUERY_SIZE }).then((colors) => {
23922
+ if (this._isDestroyed)
23923
+ return;
23635
23924
  if (this._palettePublishGeneration === publishGeneration) {
23636
23925
  this.syncNativePaletteState(colors);
23637
23926
  }
23927
+ if (this._isDestroyed)
23928
+ return;
23638
23929
  this.requestRender();
23639
23930
  }).catch(() => {});
23640
23931
  }
@@ -23685,7 +23976,7 @@ Captured external output:
23685
23976
  this._cachedPalette = result;
23686
23977
  this._paletteDetectionPromise = null;
23687
23978
  this._paletteDetectionSize = 0;
23688
- if (this._palettePublishGeneration === publishGeneration) {
23979
+ if (!this._isDestroyed && this._palettePublishGeneration === publishGeneration) {
23689
23980
  if (result.palette.length >= NATIVE_PALETTE_QUERY_SIZE) {
23690
23981
  this.syncNativePaletteState(result);
23691
23982
  } else if (this._terminalIsSetup && !this._paletteCache.has(NATIVE_PALETTE_QUERY_SIZE)) {
@@ -23705,7 +23996,7 @@ Captured external output:
23705
23996
  }
23706
23997
  }
23707
23998
 
23708
- export { __toESM, __commonJS, __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, 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 };
23999
+ 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, TextBuffer, SpanInfoStruct, toPointer, 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
24000
 
23710
- //# debugId=9856AC3785612B6364756E2164756E21
23711
- //# sourceMappingURL=index-mw2x3082.js.map
24001
+ //# debugId=C97131CABF4DEE6A64756E2164756E21
24002
+ //# sourceMappingURL=index-b9g14b8c.js.map