@opentui/core 0.5.12 → 0.5.13

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.
@@ -13685,6 +13685,10 @@ function toSafeFFIU32Length(value, label) {
13685
13685
  function isFFIU32(value) {
13686
13686
  return Number.isInteger(value) && value >= 0 && value <= MAX_FFI_U32;
13687
13687
  }
13688
+ var DRAW_TEXT_SCRATCH_BYTES = 4096;
13689
+ function drawTextString(text) {
13690
+ return typeof text === "string" ? text : text === undefined ? "" : `${text}`;
13691
+ }
13688
13692
  function viewOrNull(value) {
13689
13693
  return value.byteLength === 0 ? null : value;
13690
13694
  }
@@ -15591,6 +15595,8 @@ class FFIRenderLib {
15591
15595
  clipboardServices = new Set;
15592
15596
  encoder = new TextEncoder;
15593
15597
  decoder = new TextDecoder;
15598
+ drawTextScratch = new Uint8Array(DRAW_TEXT_SCRATCH_BYTES);
15599
+ drawBottomTitleScratch = new Uint8Array(DRAW_TEXT_SCRATCH_BYTES);
15594
15600
  logCallbackWrapper = null;
15595
15601
  eventCallbackWrapper = null;
15596
15602
  eventSinkPtr = null;
@@ -16032,10 +16038,15 @@ class FFIRenderLib {
16032
16038
  this.opentui.symbols.bufferClear(buffer, rgbaBuffer(color));
16033
16039
  }
16034
16040
  bufferDrawText(buffer, text, x, y, color, bgColor, attributes) {
16035
- const textBytes = this.encoder.encode(text);
16036
16041
  const bg = optionalRgbaBuffer(bgColor);
16037
16042
  const fg = rgbaBuffer(color);
16038
- this.opentui.symbols.bufferDrawText(buffer, viewOrNull(textBytes), textBytes.byteLength, x, y, fg, bg, attributes ?? 0);
16043
+ const string = drawTextString(text);
16044
+ const bytes = this.drawTextStorage(string, this.drawTextScratch);
16045
+ const length = this.encoder.encodeInto(string, bytes).written;
16046
+ this.opentui.symbols.bufferDrawText(buffer, length === 0 ? null : bytes, length, x, y, fg, bg, attributes ?? 0);
16047
+ }
16048
+ drawTextStorage(text, scratch) {
16049
+ return text.length * 3 <= scratch.byteLength ? scratch : new Uint8Array(text.length * 3);
16039
16050
  }
16040
16051
  bufferSetCellWithAlphaBlending(buffer, x, y, char, color, bgColor, attributes) {
16041
16052
  const charPtr = char.codePointAt(0) ?? " ".codePointAt(0);
@@ -16095,13 +16106,16 @@ class FFIRenderLib {
16095
16106
  this.opentui.symbols.bufferDrawGrid(buffer, borderChars, rgbaBuffer(borderFg), rgbaBuffer(borderBg), columnOffsets, columnCount, rowOffsets, rowCount, this.ffiStructStorage.gridDrawOptions.ffiView);
16096
16107
  }
16097
16108
  bufferDrawBox(buffer, x, y, width, height, borderChars, packedOptions, borderColor, backgroundColor, titleColor, title, bottomTitle) {
16098
- const titleBytes = title ? this.encoder.encode(title) : null;
16099
- const titleLen = titleBytes?.byteLength ?? 0;
16100
- const titleBuffer = titleBytes ? titleBytes : null;
16101
- const bottomTitleBytes = bottomTitle ? this.encoder.encode(bottomTitle) : null;
16102
- const bottomTitleLen = bottomTitleBytes?.byteLength ?? 0;
16103
- const bottomTitleBuffer = bottomTitleBytes ? bottomTitleBytes : null;
16104
- this.opentui.symbols.bufferDrawBox(buffer, x, y, width, height, borderChars, packedOptions, rgbaBuffer(borderColor), rgbaBuffer(backgroundColor), rgbaBuffer(titleColor), titleBuffer, titleLen, bottomTitleBuffer, bottomTitleLen);
16109
+ const border = rgbaBuffer(borderColor);
16110
+ const background = rgbaBuffer(backgroundColor);
16111
+ const titleFg = rgbaBuffer(titleColor);
16112
+ const top = title ? drawTextString(title) : null;
16113
+ const bottom = bottomTitle ? drawTextString(bottomTitle) : null;
16114
+ const topBytes = top === null ? null : this.drawTextStorage(top, this.drawTextScratch);
16115
+ const bottomBytes = bottom === null ? null : this.drawTextStorage(bottom, this.drawBottomTitleScratch);
16116
+ const topLength = top === null ? 0 : this.encoder.encodeInto(top, topBytes).written;
16117
+ const bottomLength = bottom === null ? 0 : this.encoder.encodeInto(bottom, bottomBytes).written;
16118
+ this.opentui.symbols.bufferDrawBox(buffer, x, y, width, height, borderChars, packedOptions, border, background, titleFg, topBytes, topLength, bottomBytes, bottomLength);
16105
16119
  }
16106
16120
  bufferResize(buffer, width, height) {
16107
16121
  this.opentui.symbols.bufferResize(buffer, width, height);
@@ -18820,5 +18834,5 @@ var yoga_default = Yoga;
18820
18834
 
18821
18835
  export { toArrayBuffer, singleton, envRegistry2, registerEnvVar2, clearEnvCache2, generateEnvMarkdown2, generateEnvColored2, env2, sleep, stringWidth, resolveBundledFilePath2, DEFAULT_FOREGROUND_RGB2, DEFAULT_BACKGROUND_RGB2, normalizeIndexedColorIndex2, ansi256IndexToRgb2, RGBA2, normalizeColorValue2, hexToRgb2, rgbToHex2, hsvToRgb2, parseColor2, isValidBorderStyle2, parseBorderStyle2, BorderChars2, getBorderFromSides2, getBorderSides2, borderCharsToArray2, BorderCharArrays2, KeyEvent2, PasteEvent2, KeyHandler2, InternalKeyHandler2, fonts2, measureText2, getCharacterPositions2, coordinateToCharacterIndex2, renderFontToFrameBuffer2, TextAttributes2, ATTRIBUTE_BASE_BITS2, ATTRIBUTE_BASE_MASK2, getBaseAttributes2, DebugOverlayCorner2, TargetChannel2, createTextAttributes2, attributesWithLink2, getLinkId2, visualizeRenderableTree2, isStyledText2, StyledText2, stringToStyledText2, black2, red2, green2, yellow2, blue2, magenta2, cyan2, white2, brightBlack2, brightRed2, brightGreen2, brightYellow2, brightBlue2, brightMagenta2, brightCyan2, brightWhite2, bgBlack2, bgRed2, bgGreen2, bgYellow2, bgBlue2, bgMagenta2, bgCyan2, bgWhite2, bold2, italic2, underline2, strikethrough2, dim2, reverse2, blink2, fg2, bg2, link2, t2, hastToStyledText2, SystemClock2, nonAlphanumericKeys2, terminalNamedSingleStrokeKeys2, parseKeypress2, LinearScrollAccel2, MacOSScrollAccel2, parseAlign2, parseAlignItems2, parseBoxSizing2, parseDimension2, parseDirection2, parseDisplay2, parseEdge2, parseFlexDirection2, parseGutter2, parseJustify2, parseLogLevel2, parseMeasureMode2, parseOverflow2, parsePositionType2, parseUnit2, parseWrap2, MouseParser2, Selection2, convertGlobalToLocalSelection2, ASCIIFontSelectionHelper2, StdinParser2, addDefaultParsers2, TreeSitterClient2, treeSitterToTextChunks2, treeSitterToStyledText2, DataPathsManager2, getDataPaths2, extensionToFiletype2, basenameToFiletype2, extToFiletype2, pathToFiletype2, infoStringToFiletype2, getTreeSitterClient2, destroyTreeSitterClient2, ExtmarksController2, createExtmarksController2, TerminalPalette2, createTerminalPalette2, normalizeTerminalPalette2, buildTerminalPaletteSignature2, decodePasteBytes2, stripAnsiSequences2, createHostClipboard2, createClipboard2, ClipboardTarget2, createRendererClipboardAdapter2, Clipboard2, normalizeMarkdownLinkTarget, detectLinks2, OptimizedBuffer2, TextBuffer2, SpanInfoStruct, NativeAudioStreamFormat2, NativeAudioStreamState2, NativeAudioStreamStateNames, NativeAudioStreamCloseReason2, NativeAudioStreamState3, NativeAudioStreamCloseReason3, NativeAudioStreamFormat3, MAX_LINK_URL_BYTES2, NativeClipboardOperationStatus2, NativeClipboardStartStatus2, NativeClipboardCancelStatus2, NativeClipboardCopyStatus2, NativeClipboardDestroyStatus2, NativeClipboardShutdownStatus2, LogLevel2, NativeMeasureTargetKind2, setRenderLibPath2, resolveRenderLib2, Align2, BoxSizing2, Dimension2, Direction2, Display2, Edge2, Errata2, ExperimentalFeature2, FlexDirection2, Gutter2, Justify2, LogLevel3, MeasureMode2, NodeType2, Overflow2, PositionType2, Unit2, Wrap2, ALIGN_AUTO2, ALIGN_FLEX_START2, ALIGN_CENTER2, ALIGN_FLEX_END2, ALIGN_STRETCH2, ALIGN_BASELINE2, ALIGN_SPACE_BETWEEN2, ALIGN_SPACE_AROUND2, ALIGN_SPACE_EVENLY2, BOX_SIZING_BORDER_BOX2, BOX_SIZING_CONTENT_BOX2, DIMENSION_WIDTH2, DIMENSION_HEIGHT2, DIRECTION_INHERIT2, DIRECTION_LTR2, DIRECTION_RTL2, DISPLAY_FLEX2, DISPLAY_NONE2, DISPLAY_CONTENTS2, EDGE_LEFT2, EDGE_TOP2, EDGE_RIGHT2, EDGE_BOTTOM2, EDGE_START2, EDGE_END2, EDGE_HORIZONTAL2, EDGE_VERTICAL2, EDGE_ALL2, ERRATA_NONE2, ERRATA_STRETCH_FLEX_BASIS2, ERRATA_ABSOLUTE_POSITION_WITHOUT_INSETS_EXCLUDES_PADDING2, ERRATA_ABSOLUTE_PERCENT_AGAINST_INNER_SIZE2, ERRATA_ALL2, ERRATA_CLASSIC2, EXPERIMENTAL_FEATURE_WEB_FLEX_BASIS2, FLEX_DIRECTION_COLUMN2, FLEX_DIRECTION_COLUMN_REVERSE2, FLEX_DIRECTION_ROW2, FLEX_DIRECTION_ROW_REVERSE2, GUTTER_COLUMN2, GUTTER_ROW2, GUTTER_ALL2, JUSTIFY_FLEX_START2, JUSTIFY_CENTER2, JUSTIFY_FLEX_END2, JUSTIFY_SPACE_BETWEEN2, JUSTIFY_SPACE_AROUND2, JUSTIFY_SPACE_EVENLY2, LOG_LEVEL_ERROR2, LOG_LEVEL_WARN2, LOG_LEVEL_INFO2, LOG_LEVEL_DEBUG2, LOG_LEVEL_VERBOSE2, LOG_LEVEL_FATAL2, MEASURE_MODE_UNDEFINED2, MEASURE_MODE_EXACTLY2, MEASURE_MODE_AT_MOST2, NODE_TYPE_DEFAULT2, NODE_TYPE_TEXT2, OVERFLOW_VISIBLE2, OVERFLOW_HIDDEN2, OVERFLOW_SCROLL2, POSITION_TYPE_STATIC2, POSITION_TYPE_RELATIVE2, POSITION_TYPE_ABSOLUTE2, UNIT_UNDEFINED2, UNIT_POINT2, UNIT_PERCENT2, UNIT_AUTO2, WRAP_NO_WRAP2, WRAP_WRAP2, WRAP_WRAP_REVERSE2, Config2, Node2, exports_yoga, yoga_default };
18822
18836
 
18823
- //# debugId=B09FAACBA517D7BA64756E2164756E21
18824
- //# sourceMappingURL=chunk-node-1zjyxy5y.js.map
18837
+ //# debugId=0EEB9DEBA63FBE2964756E2164756E21
18838
+ //# sourceMappingURL=chunk-node-80p7e6t6.js.map