@opentui/core 0.1.81 → 0.1.82

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/3d.js CHANGED
@@ -6,7 +6,7 @@ import {
6
6
  __export,
7
7
  __require,
8
8
  __toESM
9
- } from "./index-ve2seej0.js";
9
+ } from "./index-fv58mb45.js";
10
10
 
11
11
  // ../../node_modules/.bun/omggif@1.0.10/node_modules/omggif/omggif.js
12
12
  var require_omggif = __commonJS((exports) => {
package/buffer.d.ts CHANGED
@@ -94,5 +94,14 @@ export declare class OptimizedBuffer {
94
94
  char: number;
95
95
  }>;
96
96
  }): void;
97
+ drawGrid(options: {
98
+ borderChars: Uint32Array;
99
+ borderFg: RGBA;
100
+ borderBg: RGBA;
101
+ columnOffsets: Int32Array;
102
+ rowOffsets: Int32Array;
103
+ drawInner: boolean;
104
+ drawOuter: boolean;
105
+ }): void;
97
106
  drawChar(char: number, x: number, y: number, fg: RGBA, bg: RGBA, attributes?: number): void;
98
107
  }
@@ -9690,6 +9690,15 @@ class OptimizedBuffer {
9690
9690
  this.guard();
9691
9691
  this.lib.freeUnicode(encoded);
9692
9692
  }
9693
+ drawGrid(options) {
9694
+ this.guard();
9695
+ const columnCount = Math.max(0, options.columnOffsets.length - 1);
9696
+ const rowCount = Math.max(0, options.rowOffsets.length - 1);
9697
+ this.lib.bufferDrawGrid(this.bufferPtr, options.borderChars, options.borderFg, options.borderBg, options.columnOffsets, columnCount, options.rowOffsets, rowCount, {
9698
+ drawInner: options.drawInner,
9699
+ drawOuter: options.drawOuter
9700
+ });
9701
+ }
9693
9702
  drawChar(char, x, y, fg2, bg2, attributes = 0) {
9694
9703
  this.guard();
9695
9704
  this.lib.bufferDrawChar(this.bufferPtr, char, x, y, fg2, bg2, attributes);
@@ -10329,8 +10338,20 @@ var StyledChunkStruct = defineStruct([
10329
10338
  unpackTransform: rgbaUnpackTransform
10330
10339
  }
10331
10340
  ],
10332
- ["attributes", "u32", { optional: true }]
10333
- ]);
10341
+ ["attributes", "u32", { default: 0 }],
10342
+ ["link", "char*", { default: "" }],
10343
+ ["link_len", "u64", { lengthOf: "link" }]
10344
+ ], {
10345
+ mapValue: (chunk) => {
10346
+ if (!chunk.link || typeof chunk.link === "string") {
10347
+ return chunk;
10348
+ }
10349
+ return {
10350
+ ...chunk,
10351
+ link: chunk.link.url
10352
+ };
10353
+ }
10354
+ });
10334
10355
  var HighlightStruct = defineStruct([
10335
10356
  ["start", "u32"],
10336
10357
  ["end", "u32"],
@@ -10417,6 +10438,21 @@ var CursorStyleOptionsStruct = defineStruct([
10417
10438
  ],
10418
10439
  ["cursor", "u8", { default: 255 }]
10419
10440
  ]);
10441
+ var GridDrawOptionsStruct = defineStruct([
10442
+ ["drawInner", "bool_u8", { default: true }],
10443
+ ["drawOuter", "bool_u8", { default: true }]
10444
+ ]);
10445
+ var BuildOptionsStruct = defineStruct([
10446
+ ["gpaSafeStats", "bool_u8"],
10447
+ ["gpaMemoryLimitTracking", "bool_u8"]
10448
+ ]);
10449
+ var AllocatorStatsStruct = defineStruct([
10450
+ ["totalRequestedBytes", "u64"],
10451
+ ["activeAllocations", "u64"],
10452
+ ["smallAllocations", "u64"],
10453
+ ["largeAllocations", "u64"],
10454
+ ["requestedBytesValid", "bool_u8"]
10455
+ ]);
10420
10456
  var GrowthPolicyEnum = defineEnum({ grow: 0, block: 1 }, "u8");
10421
10457
  var NativeSpanFeedOptionsStruct = defineStruct([
10422
10458
  ["chunkSize", "u32", { default: 64 * 1024 }],
@@ -10491,10 +10527,10 @@ registerEnvVar({
10491
10527
  default: false
10492
10528
  });
10493
10529
  registerEnvVar({
10494
- name: "OPENTUI_NO_GRAPHICS",
10495
- description: "Disable Kitty graphics protocol detection",
10530
+ name: "OPENTUI_GRAPHICS",
10531
+ description: "Enable Kitty graphics protocol detection",
10496
10532
  type: "boolean",
10497
- default: false
10533
+ default: true
10498
10534
  });
10499
10535
  registerEnvVar({
10500
10536
  name: "OPENTUI_FORCE_NOZWJ",
@@ -10535,6 +10571,10 @@ function getOpenTUILib(libPath) {
10535
10571
  args: ["u32", "u32", "bool", "bool"],
10536
10572
  returns: "ptr"
10537
10573
  },
10574
+ setTerminalEnvVar: {
10575
+ args: ["ptr", "ptr", "usize", "ptr", "usize"],
10576
+ returns: "bool"
10577
+ },
10538
10578
  destroyRenderer: {
10539
10579
  args: ["ptr"],
10540
10580
  returns: "void"
@@ -10727,6 +10767,10 @@ function getOpenTUILib(libPath) {
10727
10767
  args: ["ptr", "i32", "i32", "ptr", "u32", "u32", "ptr", "ptr"],
10728
10768
  returns: "void"
10729
10769
  },
10770
+ bufferDrawGrid: {
10771
+ args: ["ptr", "ptr", "ptr", "ptr", "ptr", "u32", "ptr", "u32", "ptr"],
10772
+ returns: "void"
10773
+ },
10730
10774
  bufferDrawBox: {
10731
10775
  args: ["ptr", "i32", "i32", "u32", "u32", "ptr", "u32", "ptr", "ptr", "ptr", "u32"],
10732
10776
  returns: "void"
@@ -11379,6 +11423,14 @@ function getOpenTUILib(libPath) {
11379
11423
  args: [],
11380
11424
  returns: "usize"
11381
11425
  },
11426
+ getBuildOptions: {
11427
+ args: ["ptr"],
11428
+ returns: "void"
11429
+ },
11430
+ getAllocatorStats: {
11431
+ args: ["ptr"],
11432
+ returns: "void"
11433
+ },
11382
11434
  createSyntaxStyle: {
11383
11435
  args: [],
11384
11436
  returns: "ptr"
@@ -11749,6 +11801,11 @@ class FFIRenderLib {
11749
11801
  const remote = options.remote ?? false;
11750
11802
  return this.opentui.symbols.createRenderer(width, height, testing, remote);
11751
11803
  }
11804
+ setTerminalEnvVar(renderer, key, value) {
11805
+ const keyBytes = this.encoder.encode(key);
11806
+ const valueBytes = this.encoder.encode(value);
11807
+ return this.opentui.symbols.setTerminalEnvVar(renderer, keyBytes, keyBytes.length, valueBytes, valueBytes.length);
11808
+ }
11752
11809
  destroyRenderer(renderer) {
11753
11810
  this.opentui.symbols.destroyRenderer(renderer);
11754
11811
  }
@@ -11878,6 +11935,13 @@ class FFIRenderLib {
11878
11935
  bufferDrawGrayscaleBufferSupersampled(buffer, posX, posY, intensitiesPtr, srcWidth, srcHeight, fg2, bg2) {
11879
11936
  this.opentui.symbols.bufferDrawGrayscaleBufferSupersampled(buffer, posX, posY, intensitiesPtr, srcWidth, srcHeight, fg2?.buffer ?? null, bg2?.buffer ?? null);
11880
11937
  }
11938
+ bufferDrawGrid(buffer, borderChars, borderFg, borderBg, columnOffsets, columnCount, rowOffsets, rowCount, options) {
11939
+ const optionsBuffer = GridDrawOptionsStruct.pack({
11940
+ drawInner: options.drawInner,
11941
+ drawOuter: options.drawOuter
11942
+ });
11943
+ this.opentui.symbols.bufferDrawGrid(buffer, borderChars, borderFg.buffer, borderBg.buffer, columnOffsets, columnCount, rowOffsets, rowCount, ptr4(optionsBuffer));
11944
+ }
11881
11945
  bufferDrawBox(buffer, x, y, width, height, borderChars, packedOptions, borderColor, backgroundColor, title) {
11882
11946
  const titleBytes = title ? this.encoder.encode(title) : null;
11883
11947
  const titleLen = title ? titleBytes.length : 0;
@@ -12118,23 +12182,12 @@ class FFIRenderLib {
12118
12182
  return this.opentui.symbols.textBufferLoadFile(buffer, pathBytes, pathBytes.length);
12119
12183
  }
12120
12184
  textBufferSetStyledText(buffer, chunks) {
12121
- const nonEmptyChunks = chunks.filter((c) => c.text.length > 0);
12122
- if (nonEmptyChunks.length === 0) {
12185
+ if (chunks.length === 0) {
12123
12186
  this.textBufferClear(buffer);
12124
12187
  return;
12125
12188
  }
12126
- const processedChunks = nonEmptyChunks.map((chunk) => {
12127
- if (chunk.link) {
12128
- const linkId = this.linkAlloc(chunk.link.url);
12129
- return {
12130
- ...chunk,
12131
- attributes: attributesWithLink(chunk.attributes ?? 0, linkId)
12132
- };
12133
- }
12134
- return chunk;
12135
- });
12136
- const chunksBuffer = StyledChunkStruct.packList(processedChunks);
12137
- this.opentui.symbols.textBufferSetStyledText(buffer, ptr4(chunksBuffer), processedChunks.length);
12189
+ const chunksBuffer = StyledChunkStruct.packList(chunks);
12190
+ this.opentui.symbols.textBufferSetStyledText(buffer, ptr4(chunksBuffer), chunks.length);
12138
12191
  }
12139
12192
  textBufferGetLineCount(buffer) {
12140
12193
  return this.opentui.symbols.textBufferGetLineCount(buffer);
@@ -12345,6 +12398,27 @@ class FFIRenderLib {
12345
12398
  const result = this.opentui.symbols.getArenaAllocatedBytes();
12346
12399
  return typeof result === "bigint" ? Number(result) : result;
12347
12400
  }
12401
+ getBuildOptions() {
12402
+ const optionsBuffer = new ArrayBuffer(BuildOptionsStruct.size);
12403
+ this.opentui.symbols.getBuildOptions(ptr4(optionsBuffer));
12404
+ const options = BuildOptionsStruct.unpack(optionsBuffer);
12405
+ return {
12406
+ gpaSafeStats: !!options.gpaSafeStats,
12407
+ gpaMemoryLimitTracking: !!options.gpaMemoryLimitTracking
12408
+ };
12409
+ }
12410
+ getAllocatorStats() {
12411
+ const statsBuffer = new ArrayBuffer(AllocatorStatsStruct.size);
12412
+ this.opentui.symbols.getAllocatorStats(ptr4(statsBuffer));
12413
+ const stats = AllocatorStatsStruct.unpack(statsBuffer);
12414
+ return {
12415
+ totalRequestedBytes: toNumber(stats.totalRequestedBytes),
12416
+ activeAllocations: toNumber(stats.activeAllocations),
12417
+ smallAllocations: toNumber(stats.smallAllocations),
12418
+ largeAllocations: toNumber(stats.largeAllocations),
12419
+ requestedBytesValid: !!stats.requestedBytesValid
12420
+ };
12421
+ }
12348
12422
  bufferDrawTextBufferView(buffer, view, x, y) {
12349
12423
  this.opentui.symbols.bufferDrawTextBufferView(buffer, view, x, y);
12350
12424
  }
@@ -12972,14 +13046,7 @@ class TextBuffer {
12972
13046
  }
12973
13047
  setStyledText(text) {
12974
13048
  this.guard();
12975
- const chunks = text.chunks.map((chunk) => ({
12976
- text: chunk.text,
12977
- fg: chunk.fg || null,
12978
- bg: chunk.bg || null,
12979
- attributes: chunk.attributes ?? 0,
12980
- link: chunk.link
12981
- }));
12982
- this.lib.textBufferSetStyledText(this.bufferPtr, chunks);
13049
+ this.lib.textBufferSetStyledText(this.bufferPtr, text.chunks);
12983
13050
  this._length = this.lib.textBufferGetLength(this.bufferPtr);
12984
13051
  this._byteSize = this.lib.textBufferGetByteSize(this.bufferPtr);
12985
13052
  this._lineInfo = undefined;
@@ -15882,6 +15949,24 @@ registerEnvVar({
15882
15949
  type: "boolean",
15883
15950
  default: false
15884
15951
  });
15952
+ var DEFAULT_FORWARDED_ENV_KEYS = [
15953
+ "TMUX",
15954
+ "TERM",
15955
+ "OPENTUI_GRAPHICS",
15956
+ "TERM_PROGRAM",
15957
+ "TERM_PROGRAM_VERSION",
15958
+ "ALACRITTY_SOCKET",
15959
+ "ALACRITTY_LOG",
15960
+ "COLORTERM",
15961
+ "TERMUX_VERSION",
15962
+ "VHS_RECORD",
15963
+ "OPENTUI_FORCE_WCWIDTH",
15964
+ "OPENTUI_FORCE_UNICODE",
15965
+ "OPENTUI_FORCE_NOZWJ",
15966
+ "OPENTUI_FORCE_EXPLICIT_WIDTH",
15967
+ "WT_SESSION",
15968
+ "STY"
15969
+ ];
15885
15970
  var KITTY_FLAG_DISAMBIGUATE = 1;
15886
15971
  var KITTY_FLAG_EVENT_TYPES = 2;
15887
15972
  var KITTY_FLAG_ALTERNATE_KEYS = 4;
@@ -15982,7 +16067,10 @@ async function createCliRenderer(config = {}) {
15982
16067
  const height = stdout.rows || 24;
15983
16068
  const renderHeight = config.experimental_splitHeight && config.experimental_splitHeight > 0 ? config.experimental_splitHeight : height;
15984
16069
  const ziglib = resolveRenderLib();
15985
- const rendererPtr = ziglib.createRenderer(width, renderHeight, { remote: config.remote ?? false });
16070
+ const rendererPtr = ziglib.createRenderer(width, renderHeight, {
16071
+ remote: config.remote ?? false,
16072
+ testing: config.testing ?? false
16073
+ });
15986
16074
  if (!rendererPtr) {
15987
16075
  throw new Error("Failed to create renderer");
15988
16076
  }
@@ -15997,7 +16085,9 @@ async function createCliRenderer(config = {}) {
15997
16085
  const kittyFlags = buildKittyKeyboardFlags(kittyConfig);
15998
16086
  ziglib.setKittyKeyboardFlags(rendererPtr, kittyFlags);
15999
16087
  const renderer = new CliRenderer(ziglib, rendererPtr, stdin, stdout, width, height, config);
16000
- await renderer.setupTerminal();
16088
+ if (!config.testing) {
16089
+ await renderer.setupTerminal();
16090
+ }
16001
16091
  return renderer;
16002
16092
  }
16003
16093
  var CliRenderEvents;
@@ -16191,6 +16281,13 @@ Captured output:
16191
16281
  lib.setRenderOffset(rendererPtr, this.renderOffset);
16192
16282
  }
16193
16283
  this.rendererPtr = rendererPtr;
16284
+ const forwardEnvKeys = config.forwardEnvKeys ?? [...DEFAULT_FORWARDED_ENV_KEYS];
16285
+ for (const key of forwardEnvKeys) {
16286
+ const value = process.env[key];
16287
+ if (value === undefined)
16288
+ continue;
16289
+ this.lib.setTerminalEnvVar(this.rendererPtr, key, value);
16290
+ }
16194
16291
  this.exitOnCtrlC = config.exitOnCtrlC === undefined ? true : config.exitOnCtrlC;
16195
16292
  this.exitSignals = config.exitSignals || [
16196
16293
  "SIGINT",
@@ -17511,5 +17608,5 @@ Captured output:
17511
17608
 
17512
17609
  export { __toESM, __commonJS, __export, __require, Edge, Gutter, MeasureMode, exports_src, isValidBorderStyle, parseBorderStyle, BorderChars, getBorderFromSides, getBorderSides, borderCharsToArray, BorderCharArrays, nonAlphanumericKeys, parseKeypress, KeyEvent, PasteEvent, KeyHandler, InternalKeyHandler, RGBA, hexToRgb, rgbToHex, hsvToRgb, parseColor, fonts, measureText, getCharacterPositions, coordinateToCharacterIndex, renderFontToFrameBuffer, TextAttributes, ATTRIBUTE_BASE_BITS, ATTRIBUTE_BASE_MASK, getBaseAttributes, DebugOverlayCorner, 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, LinearScrollAccel, MacOSScrollAccel, StdinBuffer, 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, treeSitterToTextChunks, treeSitterToStyledText, addDefaultParsers, TreeSitterClient, DataPathsManager, getDataPaths, extToFiletype, pathToFiletype, main, getTreeSitterClient, ExtmarksController, createExtmarksController, TerminalPalette, createTerminalPalette, TextBuffer, SpanInfoStruct, LogLevel2 as LogLevel, setRenderLibPath, resolveRenderLib, OptimizedBuffer, h, isVNode, maybeMakeRenderable, wrapWithDelegates, instantiate, delegate, isValidPercentage, LayoutEvents, RenderableEvents, isRenderable, BaseRenderable, Renderable, RootRenderable, ANSI, defaultKeyAliases, mergeKeyAliases, mergeKeyBindings, getKeyBindingKey, buildKeyBindingsMap, capture, ConsolePosition, TerminalConsole, getObjectsInViewport, buildKittyKeyboardFlags, MouseEvent, MouseButton, createCliRenderer, CliRenderEvents, RendererControlState, CliRenderer };
17513
17610
 
17514
- //# debugId=EFA968BC34E6ECA564756E2164756E21
17515
- //# sourceMappingURL=index-ve2seej0.js.map
17611
+ //# debugId=DFD3E6E19525D7AC64756E2164756E21
17612
+ //# sourceMappingURL=index-fv58mb45.js.map