@opentui/core 0.5.12 → 0.5.14

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.
@@ -13703,6 +13703,10 @@ function toSafeFFIU32Length(value, label) {
13703
13703
  function isFFIU32(value) {
13704
13704
  return Number.isInteger(value) && value >= 0 && value <= MAX_FFI_U32;
13705
13705
  }
13706
+ var DRAW_TEXT_SCRATCH_BYTES = 4096;
13707
+ function drawTextString(text) {
13708
+ return typeof text === "string" ? text : text === undefined ? "" : `${text}`;
13709
+ }
13706
13710
  function viewOrNull(value) {
13707
13711
  return value.byteLength === 0 ? null : value;
13708
13712
  }
@@ -15609,6 +15613,8 @@ class FFIRenderLib {
15609
15613
  clipboardServices = new Set;
15610
15614
  encoder = new TextEncoder;
15611
15615
  decoder = new TextDecoder;
15616
+ drawTextScratch = new Uint8Array(DRAW_TEXT_SCRATCH_BYTES);
15617
+ drawBottomTitleScratch = new Uint8Array(DRAW_TEXT_SCRATCH_BYTES);
15612
15618
  logCallbackWrapper = null;
15613
15619
  eventCallbackWrapper = null;
15614
15620
  eventSinkPtr = null;
@@ -16050,10 +16056,15 @@ class FFIRenderLib {
16050
16056
  this.opentui.symbols.bufferClear(buffer, rgbaBuffer(color));
16051
16057
  }
16052
16058
  bufferDrawText(buffer, text, x, y, color, bgColor, attributes) {
16053
- const textBytes = this.encoder.encode(text);
16054
16059
  const bg = optionalRgbaBuffer(bgColor);
16055
16060
  const fg = rgbaBuffer(color);
16056
- this.opentui.symbols.bufferDrawText(buffer, viewOrNull(textBytes), textBytes.byteLength, x, y, fg, bg, attributes ?? 0);
16061
+ const string = drawTextString(text);
16062
+ const bytes = this.drawTextStorage(string, this.drawTextScratch);
16063
+ const length = this.encoder.encodeInto(string, bytes).written;
16064
+ this.opentui.symbols.bufferDrawText(buffer, length === 0 ? null : bytes, length, x, y, fg, bg, attributes ?? 0);
16065
+ }
16066
+ drawTextStorage(text, scratch) {
16067
+ return text.length * 3 <= scratch.byteLength ? scratch : new Uint8Array(text.length * 3);
16057
16068
  }
16058
16069
  bufferSetCellWithAlphaBlending(buffer, x, y, char, color, bgColor, attributes) {
16059
16070
  const charPtr = char.codePointAt(0) ?? " ".codePointAt(0);
@@ -16113,13 +16124,16 @@ class FFIRenderLib {
16113
16124
  this.opentui.symbols.bufferDrawGrid(buffer, borderChars, rgbaBuffer(borderFg), rgbaBuffer(borderBg), columnOffsets, columnCount, rowOffsets, rowCount, this.ffiStructStorage.gridDrawOptions.ffiView);
16114
16125
  }
16115
16126
  bufferDrawBox(buffer, x, y, width, height, borderChars, packedOptions, borderColor, backgroundColor, titleColor, title, bottomTitle) {
16116
- const titleBytes = title ? this.encoder.encode(title) : null;
16117
- const titleLen = titleBytes?.byteLength ?? 0;
16118
- const titleBuffer = titleBytes ? titleBytes : null;
16119
- const bottomTitleBytes = bottomTitle ? this.encoder.encode(bottomTitle) : null;
16120
- const bottomTitleLen = bottomTitleBytes?.byteLength ?? 0;
16121
- const bottomTitleBuffer = bottomTitleBytes ? bottomTitleBytes : null;
16122
- this.opentui.symbols.bufferDrawBox(buffer, x, y, width, height, borderChars, packedOptions, rgbaBuffer(borderColor), rgbaBuffer(backgroundColor), rgbaBuffer(titleColor), titleBuffer, titleLen, bottomTitleBuffer, bottomTitleLen);
16127
+ const border = rgbaBuffer(borderColor);
16128
+ const background = rgbaBuffer(backgroundColor);
16129
+ const titleFg = rgbaBuffer(titleColor);
16130
+ const top = title ? drawTextString(title) : null;
16131
+ const bottom = bottomTitle ? drawTextString(bottomTitle) : null;
16132
+ const topBytes = top === null ? null : this.drawTextStorage(top, this.drawTextScratch);
16133
+ const bottomBytes = bottom === null ? null : this.drawTextStorage(bottom, this.drawBottomTitleScratch);
16134
+ const topLength = top === null ? 0 : this.encoder.encodeInto(top, topBytes).written;
16135
+ const bottomLength = bottom === null ? 0 : this.encoder.encodeInto(bottom, bottomBytes).written;
16136
+ this.opentui.symbols.bufferDrawBox(buffer, x, y, width, height, borderChars, packedOptions, border, background, titleFg, topBytes, topLength, bottomBytes, bottomLength);
16123
16137
  }
16124
16138
  bufferResize(buffer, width, height) {
16125
16139
  this.opentui.symbols.bufferResize(buffer, width, height);
@@ -18838,5 +18852,5 @@ var yoga_default = Yoga;
18838
18852
 
18839
18853
  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 };
18840
18854
 
18841
- //# debugId=1D4925856A3AFEEC64756E2164756E21
18842
- //# sourceMappingURL=chunk-bun-8f4q4e2m.js.map
18855
+ //# debugId=B5A6C4CAF586358164756E2164756E21
18856
+ //# sourceMappingURL=chunk-bun-sjw2d9bq.js.map