@opentui/core 0.1.63 → 0.1.64

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/buffer.d.ts CHANGED
@@ -22,7 +22,7 @@ export declare class OptimizedBuffer {
22
22
  char: Uint32Array;
23
23
  fg: Float32Array;
24
24
  bg: Float32Array;
25
- attributes: Uint8Array;
25
+ attributes: Uint32Array;
26
26
  };
27
27
  constructor(lib: RenderLib, ptr: Pointer, width: number, height: number, options: {
28
28
  respectAlpha?: boolean;
@@ -27,7 +27,7 @@ var __export = (target, all) => {
27
27
  };
28
28
  var __require = import.meta.require;
29
29
 
30
- // ../../node_modules/yoga-layout/dist/src/index.js
30
+ // ../../node_modules/.bun/yoga-layout@3.2.1/node_modules/yoga-layout/dist/src/index.js
31
31
  var exports_src = {};
32
32
  __export(exports_src, {
33
33
  default: () => src_default,
@@ -51,7 +51,7 @@ __export(exports_src, {
51
51
  Align: () => Align
52
52
  });
53
53
 
54
- // ../../node_modules/yoga-layout/dist/binaries/yoga-wasm-base64-esm.js
54
+ // ../../node_modules/.bun/yoga-layout@3.2.1/node_modules/yoga-layout/dist/binaries/yoga-wasm-base64-esm.js
55
55
  var loadYoga = (() => {
56
56
  var _scriptDir = import.meta.url;
57
57
  return function(loadYoga2) {
@@ -1356,7 +1356,7 @@ var loadYoga = (() => {
1356
1356
  })();
1357
1357
  var yoga_wasm_base64_esm_default = loadYoga;
1358
1358
 
1359
- // ../../node_modules/yoga-layout/dist/src/generated/YGEnums.js
1359
+ // ../../node_modules/.bun/yoga-layout@3.2.1/node_modules/yoga-layout/dist/src/generated/YGEnums.js
1360
1360
  var Align = /* @__PURE__ */ function(Align2) {
1361
1361
  Align2[Align2["Auto"] = 0] = "Auto";
1362
1362
  Align2[Align2["FlexStart"] = 1] = "FlexStart";
@@ -1559,7 +1559,7 @@ var constants = {
1559
1559
  };
1560
1560
  var YGEnums_default = constants;
1561
1561
 
1562
- // ../../node_modules/yoga-layout/dist/src/wrapAssembly.js
1562
+ // ../../node_modules/.bun/yoga-layout@3.2.1/node_modules/yoga-layout/dist/src/wrapAssembly.js
1563
1563
  function wrapAssembly(lib) {
1564
1564
  function patch(prototype, name, fn) {
1565
1565
  const original = prototype[name];
@@ -1661,7 +1661,7 @@ function wrapAssembly(lib) {
1661
1661
  };
1662
1662
  }
1663
1663
 
1664
- // ../../node_modules/yoga-layout/dist/src/index.js
1664
+ // ../../node_modules/.bun/yoga-layout@3.2.1/node_modules/yoga-layout/dist/src/index.js
1665
1665
  var Yoga = wrapAssembly(await yoga_wasm_base64_esm_default());
1666
1666
  var src_default = Yoga;
1667
1667
 
@@ -5605,6 +5605,11 @@ var TextAttributes = {
5605
5605
  HIDDEN: 1 << 6,
5606
5606
  STRIKETHROUGH: 1 << 7
5607
5607
  };
5608
+ var ATTRIBUTE_BASE_BITS = 8;
5609
+ var ATTRIBUTE_BASE_MASK = 255;
5610
+ function getBaseAttributes(attr) {
5611
+ return attr & ATTRIBUTE_BASE_MASK;
5612
+ }
5608
5613
  var DebugOverlayCorner;
5609
5614
  ((DebugOverlayCorner2) => {
5610
5615
  DebugOverlayCorner2[DebugOverlayCorner2["topLeft"] = 0] = "topLeft";
@@ -5643,6 +5648,17 @@ function createTextAttributes({
5643
5648
  attributes |= TextAttributes.STRIKETHROUGH;
5644
5649
  return attributes;
5645
5650
  }
5651
+ var ATTRIBUTE_BASE_MASK2 = 255;
5652
+ var LINK_ID_SHIFT = 8;
5653
+ var LINK_ID_PAYLOAD_MASK = 16777215;
5654
+ function attributesWithLink(baseAttributes, linkId) {
5655
+ const base = baseAttributes & ATTRIBUTE_BASE_MASK2;
5656
+ const linkBits = (linkId & LINK_ID_PAYLOAD_MASK) << LINK_ID_SHIFT;
5657
+ return base | linkBits;
5658
+ }
5659
+ function getLinkId(attributes) {
5660
+ return attributes >>> LINK_ID_SHIFT & LINK_ID_PAYLOAD_MASK;
5661
+ }
5646
5662
  function visualizeRenderableTree(renderable, maxDepth = 10) {
5647
5663
  function buildTreeLines(node, prefix = "", parentPrefix = "", isLastChild = true, depth = 0) {
5648
5664
  if (depth >= maxDepth) {
@@ -5701,7 +5717,8 @@ function applyStyle(input, style) {
5701
5717
  text: existingChunk.text,
5702
5718
  fg,
5703
5719
  bg,
5704
- attributes: mergedAttrs
5720
+ attributes: mergedAttrs,
5721
+ link: existingChunk.link
5705
5722
  };
5706
5723
  } else {
5707
5724
  const plainTextStr = String(input);
@@ -5750,6 +5767,16 @@ var reverse = (input) => applyStyle(input, { reverse: true });
5750
5767
  var blink = (input) => applyStyle(input, { blink: true });
5751
5768
  var fg = (color) => (input) => applyStyle(input, { fg: color });
5752
5769
  var bg = (color) => (input) => applyStyle(input, { bg: color });
5770
+ var link = (url) => (input) => {
5771
+ const chunk = typeof input === "object" && "__isChunk" in input ? input : {
5772
+ __isChunk: true,
5773
+ text: String(input)
5774
+ };
5775
+ return {
5776
+ ...chunk,
5777
+ link: { url }
5778
+ };
5779
+ };
5753
5780
  function t(strings, ...values) {
5754
5781
  const chunks = [];
5755
5782
  for (let i = 0;i < strings.length; i++) {
@@ -6125,6 +6152,33 @@ function parseAlign(value) {
6125
6152
  return Align.Auto;
6126
6153
  }
6127
6154
  }
6155
+ function parseAlignItems(value) {
6156
+ if (value == null) {
6157
+ return Align.Stretch;
6158
+ }
6159
+ switch (value.toLowerCase()) {
6160
+ case "auto":
6161
+ return Align.Auto;
6162
+ case "flex-start":
6163
+ return Align.FlexStart;
6164
+ case "center":
6165
+ return Align.Center;
6166
+ case "flex-end":
6167
+ return Align.FlexEnd;
6168
+ case "stretch":
6169
+ return Align.Stretch;
6170
+ case "baseline":
6171
+ return Align.Baseline;
6172
+ case "space-between":
6173
+ return Align.SpaceBetween;
6174
+ case "space-around":
6175
+ return Align.SpaceAround;
6176
+ case "space-evenly":
6177
+ return Align.SpaceEvenly;
6178
+ default:
6179
+ return Align.Stretch;
6180
+ }
6181
+ }
6128
6182
  function parseBoxSizing(value) {
6129
6183
  if (value == null) {
6130
6184
  return BoxSizing.BorderBox;
@@ -9246,7 +9300,7 @@ class OptimizedBuffer {
9246
9300
  char: new Uint32Array(toArrayBuffer(charPtr, 0, size * 4)),
9247
9301
  fg: new Float32Array(toArrayBuffer(fgPtr, 0, size * 4 * 4)),
9248
9302
  bg: new Float32Array(toArrayBuffer(bgPtr, 0, size * 4 * 4)),
9249
- attributes: new Uint8Array(toArrayBuffer(attributesPtr, 0, size))
9303
+ attributes: new Uint32Array(toArrayBuffer(attributesPtr, 0, size * 4))
9250
9304
  };
9251
9305
  }
9252
9306
  return this._rawBuffers;
@@ -9421,7 +9475,7 @@ class OptimizedBuffer {
9421
9475
  }
9422
9476
  }
9423
9477
 
9424
- // ../../node_modules/bun-ffi-structs/index.js
9478
+ // ../../node_modules/.bun/bun-ffi-structs@0.1.2+1fb4c65d43e298b9/node_modules/bun-ffi-structs/index.js
9425
9479
  import { ptr, toArrayBuffer as toArrayBuffer2 } from "bun:ffi";
9426
9480
  function fatalError(...args) {
9427
9481
  const message = args.join(" ");
@@ -10054,7 +10108,7 @@ var StyledChunkStruct = defineStruct([
10054
10108
  unpackTransform: rgbaUnpackTransform
10055
10109
  }
10056
10110
  ],
10057
- ["attributes", "u8", { optional: true }]
10111
+ ["attributes", "u32", { optional: true }]
10058
10112
  ]);
10059
10113
  var HighlightStruct = defineStruct([
10060
10114
  ["start", "u32"],
@@ -10268,15 +10322,15 @@ function getOpenTUILib(libPath) {
10268
10322
  returns: "u32"
10269
10323
  },
10270
10324
  bufferDrawText: {
10271
- args: ["ptr", "ptr", "u32", "u32", "u32", "ptr", "ptr", "u8"],
10325
+ args: ["ptr", "ptr", "u32", "u32", "u32", "ptr", "ptr", "u32"],
10272
10326
  returns: "void"
10273
10327
  },
10274
10328
  bufferSetCellWithAlphaBlending: {
10275
- args: ["ptr", "u32", "u32", "u32", "ptr", "ptr", "u8"],
10329
+ args: ["ptr", "u32", "u32", "u32", "ptr", "ptr", "u32"],
10276
10330
  returns: "void"
10277
10331
  },
10278
10332
  bufferSetCell: {
10279
- args: ["ptr", "u32", "u32", "u32", "ptr", "ptr", "u8"],
10333
+ args: ["ptr", "u32", "u32", "u32", "ptr", "ptr", "u32"],
10280
10334
  returns: "void"
10281
10335
  },
10282
10336
  bufferFillRect: {
@@ -10287,6 +10341,22 @@ function getOpenTUILib(libPath) {
10287
10341
  args: ["ptr", "u32", "u32"],
10288
10342
  returns: "void"
10289
10343
  },
10344
+ linkAlloc: {
10345
+ args: ["ptr", "u32"],
10346
+ returns: "u32"
10347
+ },
10348
+ linkGetUrl: {
10349
+ args: ["u32", "ptr", "u32"],
10350
+ returns: "u32"
10351
+ },
10352
+ attributesWithLink: {
10353
+ args: ["u32", "u32"],
10354
+ returns: "u32"
10355
+ },
10356
+ attributesGetLinkId: {
10357
+ args: ["u32"],
10358
+ returns: "u32"
10359
+ },
10290
10360
  resizeRenderer: {
10291
10361
  args: ["ptr", "u32", "u32"],
10292
10362
  returns: "void"
@@ -10976,7 +11046,7 @@ function getOpenTUILib(libPath) {
10976
11046
  returns: "void"
10977
11047
  },
10978
11048
  bufferDrawChar: {
10979
- args: ["ptr", "u32", "u32", "u32", "ptr", "ptr", "u8"],
11049
+ args: ["ptr", "u32", "u32", "u32", "ptr", "ptr", "u32"],
10980
11050
  returns: "void"
10981
11051
  }
10982
11052
  });
@@ -11370,6 +11440,21 @@ class FFIRenderLib {
11370
11440
  bufferResize(buffer, width, height) {
11371
11441
  this.opentui.symbols.bufferResize(buffer, width, height);
11372
11442
  }
11443
+ linkAlloc(url) {
11444
+ const urlBytes = this.encoder.encode(url);
11445
+ return this.opentui.symbols.linkAlloc(urlBytes, urlBytes.length);
11446
+ }
11447
+ linkGetUrl(linkId, maxLen = 512) {
11448
+ const outBuffer = new Uint8Array(maxLen);
11449
+ const actualLen = this.opentui.symbols.linkGetUrl(linkId, outBuffer, maxLen);
11450
+ return this.decoder.decode(outBuffer.slice(0, actualLen));
11451
+ }
11452
+ attributesWithLink(baseAttributes, linkId) {
11453
+ return this.opentui.symbols.attributesWithLink(baseAttributes, linkId);
11454
+ }
11455
+ attributesGetLinkId(attributes) {
11456
+ return this.opentui.symbols.attributesGetLinkId(attributes);
11457
+ }
11373
11458
  resizeRenderer(renderer, width, height) {
11374
11459
  this.opentui.symbols.resizeRenderer(renderer, width, height);
11375
11460
  }
@@ -11542,8 +11627,18 @@ class FFIRenderLib {
11542
11627
  this.textBufferClear(buffer);
11543
11628
  return;
11544
11629
  }
11545
- const chunksBuffer = StyledChunkStruct.packList(nonEmptyChunks);
11546
- this.opentui.symbols.textBufferSetStyledText(buffer, ptr3(chunksBuffer), nonEmptyChunks.length);
11630
+ const processedChunks = nonEmptyChunks.map((chunk) => {
11631
+ if (chunk.link) {
11632
+ const linkId = this.linkAlloc(chunk.link.url);
11633
+ return {
11634
+ ...chunk,
11635
+ attributes: attributesWithLink(chunk.attributes ?? 0, linkId)
11636
+ };
11637
+ }
11638
+ return chunk;
11639
+ });
11640
+ const chunksBuffer = StyledChunkStruct.packList(processedChunks);
11641
+ this.opentui.symbols.textBufferSetStyledText(buffer, ptr3(chunksBuffer), processedChunks.length);
11547
11642
  }
11548
11643
  textBufferGetLineCount(buffer) {
11549
11644
  return this.opentui.symbols.textBufferGetLineCount(buffer);
@@ -12313,7 +12408,8 @@ class TextBuffer {
12313
12408
  text: chunk.text,
12314
12409
  fg: chunk.fg || null,
12315
12410
  bg: chunk.bg || null,
12316
- attributes: chunk.attributes ?? 0
12411
+ attributes: chunk.attributes ?? 0,
12412
+ link: chunk.link
12317
12413
  }));
12318
12414
  this.lib.textBufferSetStyledText(this.bufferPtr, chunks);
12319
12415
  this._length = this.lib.textBufferGetLength(this.bufferPtr);
@@ -12957,21 +13053,11 @@ class Renderable extends BaseRenderable {
12957
13053
  this._flexShrink = hasExplicitWidth || hasExplicitHeight ? 0 : 1;
12958
13054
  node.setFlexShrink(this._flexShrink);
12959
13055
  }
12960
- if (options.flexDirection !== undefined) {
12961
- node.setFlexDirection(parseFlexDirection(options.flexDirection));
12962
- }
12963
- if (options.flexWrap !== undefined) {
12964
- node.setFlexWrap(parseWrap(options.flexWrap));
12965
- }
12966
- if (options.alignItems !== undefined) {
12967
- node.setAlignItems(parseAlign(options.alignItems));
12968
- }
12969
- if (options.justifyContent !== undefined) {
12970
- node.setJustifyContent(parseJustify(options.justifyContent));
12971
- }
12972
- if (options.alignSelf !== undefined) {
12973
- node.setAlignSelf(parseAlign(options.alignSelf));
12974
- }
13056
+ node.setFlexDirection(parseFlexDirection(options.flexDirection));
13057
+ node.setFlexWrap(parseWrap(options.flexWrap));
13058
+ node.setAlignItems(parseAlignItems(options.alignItems));
13059
+ node.setJustifyContent(parseJustify(options.justifyContent));
13060
+ node.setAlignSelf(parseAlign(options.alignSelf));
12975
13061
  if (isDimensionType(options.width)) {
12976
13062
  this._width = options.width;
12977
13063
  this.yogaNode.setWidth(options.width);
@@ -13122,7 +13208,7 @@ class Renderable extends BaseRenderable {
13122
13208
  this.requestRender();
13123
13209
  }
13124
13210
  set alignItems(alignItems) {
13125
- this.yogaNode.setAlignItems(parseAlign(alignItems));
13211
+ this.yogaNode.setAlignItems(parseAlignItems(alignItems));
13126
13212
  this.requestRender();
13127
13213
  }
13128
13214
  set justifyContent(justifyContent) {
@@ -16260,6 +16346,9 @@ Captured output:
16260
16346
  }
16261
16347
  }
16262
16348
  destroy() {
16349
+ if (this._isDestroyed)
16350
+ return;
16351
+ this._isDestroyed = true;
16263
16352
  process.removeListener("SIGWINCH", this.sigwinchHandler);
16264
16353
  process.removeListener("uncaughtException", this.handleError);
16265
16354
  process.removeListener("unhandledRejection", this.handleError);
@@ -16284,9 +16373,6 @@ Captured output:
16284
16373
  }
16285
16374
  this._paletteDetectionPromise = null;
16286
16375
  this._cachedPalette = null;
16287
- if (this._isDestroyed)
16288
- return;
16289
- this._isDestroyed = true;
16290
16376
  this.emit("destroy" /* DESTROY */);
16291
16377
  if (this.renderTimeout) {
16292
16378
  clearTimeout(this.renderTimeout);
@@ -16590,7 +16676,7 @@ Captured output:
16590
16676
  }
16591
16677
  }
16592
16678
 
16593
- export { __toESM, __commonJS, __export, __require, Edge, Gutter, MeasureMode, exports_src, BorderChars, getBorderFromSides, getBorderSides, borderCharsToArray, BorderCharArrays, nonAlphanumericKeys, parseKeypress, KeyEvent, PasteEvent, KeyHandler, InternalKeyHandler, RGBA, hexToRgb, rgbToHex, hsvToRgb, parseColor, fonts, measureText, getCharacterPositions, coordinateToCharacterIndex, renderFontToFrameBuffer, TextAttributes, DebugOverlayCorner, createTextAttributes, visualizeRenderableTree, isStyledText, StyledText, stringToStyledText, black, red, green, yellow, blue, magenta, cyan, white, brightBlack, brightRed, brightGreen, brightYellow, brightBlue, brightMagenta, brightCyan, brightWhite, bgBlack, bgRed, bgGreen, bgYellow, bgBlue, bgMagenta, bgCyan, bgWhite, bold, italic, underline, strikethrough, dim, reverse, blink, fg, bg, t, hastToStyledText, LinearScrollAccel, MacOSScrollAccel, StdinBuffer, parseAlign, parseBoxSizing, parseDimension, parseDirection, parseDisplay, parseEdge, parseFlexDirection, parseGutter, parseJustify, parseLogLevel, parseMeasureMode, parseOverflow, parsePositionType, parseUnit, parseWrap, MouseParser, Selection, convertGlobalToLocalSelection, ASCIIFontSelectionHelper, envRegistry, registerEnvVar, clearEnvCache, generateEnvMarkdown, generateEnvColored, env, treeSitterToTextChunks, treeSitterToStyledText, addDefaultParsers, TreeSitterClient, DataPathsManager, getDataPaths, extToFiletype, pathToFiletype, main, getTreeSitterClient, ExtmarksController, createExtmarksController, TerminalPalette, createTerminalPalette, TextBuffer, 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 };
16679
+ export { __toESM, __commonJS, __export, __require, Edge, Gutter, MeasureMode, exports_src, 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, 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 };
16594
16680
 
16595
- //# debugId=C92528FA268EFFA664756E2164756E21
16596
- //# sourceMappingURL=index-689t9q65.js.map
16681
+ //# debugId=2A8F4167DDD29BBD64756E2164756E21
16682
+ //# sourceMappingURL=index-h33hh1n5.js.map