@opentui/core 0.1.106 → 0.2.0

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-jct3zgy3.js";
9
+ } from "./index-mw2x3082.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
@@ -15,18 +15,16 @@ export declare class OptimizedBuffer {
15
15
  private _widthMethod;
16
16
  respectAlpha: boolean;
17
17
  private _rawBuffers;
18
- private _rawColorTags;
19
18
  private _destroyed;
20
19
  get ptr(): Pointer;
21
20
  private guard;
22
21
  private ensureRawBufferViews;
23
22
  get buffers(): {
24
23
  char: Uint32Array;
25
- fg: Float32Array;
26
- bg: Float32Array;
24
+ fg: Uint16Array;
25
+ bg: Uint16Array;
27
26
  attributes: Uint32Array;
28
27
  };
29
- private get rawColorTags();
30
28
  constructor(lib: RenderLib, ptr: Pointer, width: number, height: number, options: {
31
29
  respectAlpha?: boolean;
32
30
  id?: string;
@@ -1,10 +1,10 @@
1
1
  // @bun
2
2
  import {
3
3
  exports_src
4
- } from "./index-jfshts6b.js";
4
+ } from "./index-mch6dv67.js";
5
5
  import {
6
6
  __require
7
- } from "./index-jct3zgy3.js";
7
+ } from "./index-mw2x3082.js";
8
8
 
9
9
  // src/runtime-plugin.ts
10
10
  import { existsSync, readFileSync, realpathSync } from "fs";
@@ -408,4 +408,4 @@ function createRuntimePlugin(input = {}) {
408
408
  export { isCoreRuntimeModuleSpecifier, runtimeModuleIdForSpecifier, createRuntimePlugin };
409
409
 
410
410
  //# debugId=5D58E30F1E057B9664756E2164756E21
411
- //# sourceMappingURL=index-h1ewdzdj.js.map
411
+ //# sourceMappingURL=index-epp5y71w.js.map
@@ -7,8 +7,6 @@ import {
7
7
  BorderCharArrays,
8
8
  BorderChars,
9
9
  BoxRenderable,
10
- COLOR_TAG_DEFAULT,
11
- COLOR_TAG_RGB,
12
10
  CliRenderEvents,
13
11
  CliRenderer,
14
12
  CodeRenderable,
@@ -97,7 +95,6 @@ import {
97
95
  createTerminalPalette,
98
96
  createTextAttributes,
99
97
  cyan,
100
- decodeColorTag,
101
98
  decodePasteBytes,
102
99
  defaultKeyAliases,
103
100
  delegate,
@@ -185,7 +182,7 @@ import {
185
182
  white,
186
183
  wrapWithDelegates,
187
184
  yellow
188
- } from "./index-jct3zgy3.js";
185
+ } from "./index-mw2x3082.js";
189
186
 
190
187
  // src/index.ts
191
188
  var exports_src2 = {};
@@ -276,7 +273,6 @@ __export(exports_src2, {
276
273
  delegate: () => delegate,
277
274
  defaultTextareaKeyBindings: () => defaultTextareaKeyBindings,
278
275
  decodePasteBytes: () => decodePasteBytes,
279
- decodeColorTag: () => decodeColorTag,
280
276
  cyan: () => cyan,
281
277
  createTimeline: () => createTimeline,
282
278
  createTextAttributes: () => createTextAttributes,
@@ -421,8 +417,6 @@ __export(exports_src2, {
421
417
  CliRenderer: () => CliRenderer,
422
418
  CliRenderEvents: () => CliRenderEvents,
423
419
  CRTRollingBarEffect: () => CRTRollingBarEffect,
424
- COLOR_TAG_RGB: () => COLOR_TAG_RGB,
425
- COLOR_TAG_DEFAULT: () => COLOR_TAG_DEFAULT,
426
420
  BoxRenderable: () => BoxRenderable,
427
421
  Box: () => Box,
428
422
  BorderChars: () => BorderChars,
@@ -439,6 +433,20 @@ __export(exports_src2, {
439
433
  });
440
434
 
441
435
  // src/post/effects.ts
436
+ function toU8(value) {
437
+ return Math.round(Math.max(0, Math.min(1, Number.isFinite(value) ? value : 0)) * 255);
438
+ }
439
+ function channel(buffer, index) {
440
+ return (buffer[index] & 255) / 255;
441
+ }
442
+ function setRgb(buffer, base, r, g, b) {
443
+ const a = buffer[base + 3] & 255;
444
+ buffer[base] = toU8(r);
445
+ buffer[base + 1] = toU8(g);
446
+ buffer[base + 2] = toU8(b);
447
+ buffer[base + 3] = a;
448
+ }
449
+
442
450
  class DistortionEffect {
443
451
  glitchChancePerSecond = 0.5;
444
452
  maxGlitchLines = 3;
@@ -502,8 +510,8 @@ class DistortionEffect {
502
510
  if (glitch.type === "shift" || glitch.type === "flip") {
503
511
  if (!tempChar) {
504
512
  tempChar = new Uint32Array(width);
505
- tempFg = new Float32Array(width * 4);
506
- tempBg = new Float32Array(width * 4);
513
+ tempFg = new Uint16Array(width * 4);
514
+ tempBg = new Uint16Array(width * 4);
507
515
  tempAttr = new Uint8Array(width);
508
516
  }
509
517
  try {
@@ -610,12 +618,8 @@ class DistortionEffect {
610
618
  gBg = 1 - gFg;
611
619
  bBg = 1 - bFg;
612
620
  }
613
- buf.fg[destColorIndex] = rFg;
614
- buf.fg[destColorIndex + 1] = gFg;
615
- buf.fg[destColorIndex + 2] = bFg;
616
- buf.bg[destColorIndex] = rBg;
617
- buf.bg[destColorIndex + 1] = gBg;
618
- buf.bg[destColorIndex + 2] = bBg;
621
+ setRgb(buf.fg, destColorIndex, rFg, gFg, bFg);
622
+ setRgb(buf.bg, destColorIndex, rBg, gBg, bBg);
619
623
  }
620
624
  }
621
625
  }
@@ -880,9 +884,7 @@ class FlamesEffect {
880
884
  g = flameIntensity * 0.5;
881
885
  b = 0;
882
886
  }
883
- bg2[colorIndex] = Math.max(bg2[colorIndex], r * flameIntensity);
884
- bg2[colorIndex + 1] = Math.max(bg2[colorIndex + 1], g * flameIntensity);
885
- bg2[colorIndex + 2] = Math.max(bg2[colorIndex + 2], b * flameIntensity);
887
+ setRgb(bg2, colorIndex, Math.max(channel(bg2, colorIndex), r * flameIntensity), Math.max(channel(bg2, colorIndex + 1), g * flameIntensity), Math.max(channel(bg2, colorIndex + 2), b * flameIntensity));
886
888
  }
887
889
  }
888
890
  }
@@ -948,12 +950,8 @@ class CRTRollingBarEffect {
948
950
  const rowMultiplier = 1 + this._intensity * barFactor;
949
951
  for (let x = 0;x < width; x++) {
950
952
  const colorIndex = (y * width + x) * 4;
951
- fg2[colorIndex] = Math.min(1, fg2[colorIndex] * rowMultiplier);
952
- fg2[colorIndex + 1] = Math.min(1, fg2[colorIndex + 1] * rowMultiplier);
953
- fg2[colorIndex + 2] = Math.min(1, fg2[colorIndex + 2] * rowMultiplier);
954
- bg2[colorIndex] = Math.min(1, bg2[colorIndex] * rowMultiplier);
955
- bg2[colorIndex + 1] = Math.min(1, bg2[colorIndex + 1] * rowMultiplier);
956
- bg2[colorIndex + 2] = Math.min(1, bg2[colorIndex + 2] * rowMultiplier);
953
+ setRgb(fg2, colorIndex, Math.min(1, channel(fg2, colorIndex) * rowMultiplier), Math.min(1, channel(fg2, colorIndex + 1) * rowMultiplier), Math.min(1, channel(fg2, colorIndex + 2) * rowMultiplier));
954
+ setRgb(bg2, colorIndex, Math.min(1, channel(bg2, colorIndex) * rowMultiplier), Math.min(1, channel(bg2, colorIndex + 1) * rowMultiplier), Math.min(1, channel(bg2, colorIndex + 2) * rowMultiplier));
957
955
  }
958
956
  }
959
957
  }
@@ -1052,23 +1050,34 @@ class RainbowTextEffect {
1052
1050
  for (let y = 0;y < height; y++) {
1053
1051
  for (let x = 0;x < width; x++) {
1054
1052
  const colorIndex = (y * width + x) * 4;
1055
- const r = fg2[colorIndex];
1056
- const g = fg2[colorIndex + 1];
1057
- const b = fg2[colorIndex + 2];
1053
+ const r = channel(fg2, colorIndex);
1054
+ const g = channel(fg2, colorIndex + 1);
1055
+ const b = channel(fg2, colorIndex + 2);
1058
1056
  if (r >= whiteThreshold && g >= whiteThreshold && b >= whiteThreshold) {
1059
1057
  const projection = x * cosAngle + y * sinAngle;
1060
1058
  const maxProjection = width * cosAngle + height * sinAngle;
1061
1059
  const hue = (projection / maxProjection * repeats + this.time * 0.1) % 1;
1062
1060
  const [newR, newG, newB] = this.hsvToRgb(hue, saturation, value);
1063
- fg2[colorIndex] = newR;
1064
- fg2[colorIndex + 1] = newG;
1065
- fg2[colorIndex + 2] = newB;
1061
+ setRgb(fg2, colorIndex, newR, newG, newB);
1066
1062
  }
1067
1063
  }
1068
1064
  }
1069
1065
  }
1070
1066
  }
1071
1067
  // src/post/filters.ts
1068
+ function toU82(value) {
1069
+ return Math.round(Math.max(0, Math.min(1, Number.isFinite(value) ? value : 0)) * 255);
1070
+ }
1071
+ function channel2(buffer, index) {
1072
+ return (buffer[index] & 255) / 255;
1073
+ }
1074
+ function setRgb2(buffer, base, r, g, b) {
1075
+ const a = buffer[base + 3] & 255;
1076
+ buffer[base] = toU82(r);
1077
+ buffer[base + 1] = toU82(g);
1078
+ buffer[base + 2] = toU82(b);
1079
+ buffer[base + 3] = a;
1080
+ }
1072
1081
  function applyScanlines(buffer, strength = 0.8, step = 2) {
1073
1082
  if (strength === 1 || step < 1)
1074
1083
  return;
@@ -1168,7 +1177,7 @@ function applyNoise(buffer, strength = 0.1) {
1168
1177
  function applyChromaticAberration(buffer, strength = 1) {
1169
1178
  const width = buffer.width;
1170
1179
  const height = buffer.height;
1171
- const srcFg = Float32Array.from(buffer.buffers.fg);
1180
+ const srcFg = Uint16Array.from(buffer.buffers.fg);
1172
1181
  const destFg = buffer.buffers.fg;
1173
1182
  const centerX = width / 2;
1174
1183
  const centerY = height / 2;
@@ -1183,9 +1192,7 @@ function applyChromaticAberration(buffer, strength = 1) {
1183
1192
  const gIndex = (y * width + x) * 4;
1184
1193
  const bIndex = (y * width + bX) * 4;
1185
1194
  const destIndex = (y * width + x) * 4;
1186
- destFg[destIndex] = srcFg[rIndex];
1187
- destFg[destIndex + 1] = srcFg[gIndex + 1];
1188
- destFg[destIndex + 2] = srcFg[bIndex + 2];
1195
+ setRgb2(destFg, destIndex, channel2(srcFg, rIndex), channel2(srcFg, gIndex + 1), channel2(srcFg, bIndex + 2));
1189
1196
  }
1190
1197
  }
1191
1198
  }
@@ -1199,9 +1206,9 @@ function applyAsciiArt(buffer, ramp = ' .\'`^"",:;Il!i><~+_-?][}{1)(|\\/tfjrxnuv
1199
1206
  for (let x = 0;x < width; x++) {
1200
1207
  const index = y * width + x;
1201
1208
  const colorIndex = index * 4;
1202
- const bgR = bg2[colorIndex];
1203
- const bgG = bg2[colorIndex + 1];
1204
- const bgB = bg2[colorIndex + 2];
1209
+ const bgR = channel2(bg2, colorIndex);
1210
+ const bgG = channel2(bg2, colorIndex + 1);
1211
+ const bgB = channel2(bg2, colorIndex + 2);
1205
1212
  const lum = 0.299 * bgR + 0.587 * bgG + 0.114 * bgB;
1206
1213
  const rampIndex = Math.min(rampLength - 1, Math.floor(lum * rampLength));
1207
1214
  chars[index] = ramp[rampIndex].charCodeAt(0);
@@ -1382,16 +1389,16 @@ class BloomEffect {
1382
1389
  return;
1383
1390
  const width = buffer.width;
1384
1391
  const height = buffer.height;
1385
- const srcFg = Float32Array.from(buffer.buffers.fg);
1386
- const srcBg = Float32Array.from(buffer.buffers.bg);
1392
+ const srcFg = Uint16Array.from(buffer.buffers.fg);
1393
+ const srcBg = Uint16Array.from(buffer.buffers.bg);
1387
1394
  const destFg = buffer.buffers.fg;
1388
1395
  const destBg = buffer.buffers.bg;
1389
1396
  const brightPixels = [];
1390
1397
  for (let y = 0;y < height; y++) {
1391
1398
  for (let x = 0;x < width; x++) {
1392
1399
  const index = (y * width + x) * 4;
1393
- const fgLum = 0.299 * srcFg[index] + 0.587 * srcFg[index + 1] + 0.114 * srcFg[index + 2];
1394
- const bgLum = 0.299 * srcBg[index] + 0.587 * srcBg[index + 1] + 0.114 * srcBg[index + 2];
1400
+ const fgLum = 0.299 * channel2(srcFg, index) + 0.587 * channel2(srcFg, index + 1) + 0.114 * channel2(srcFg, index + 2);
1401
+ const bgLum = 0.299 * channel2(srcBg, index) + 0.587 * channel2(srcBg, index + 1) + 0.114 * channel2(srcBg, index + 2);
1395
1402
  const lum = Math.max(fgLum, bgLum);
1396
1403
  if (lum > threshold) {
1397
1404
  const intensity = (lum - threshold) / (1 - threshold + 0.000001);
@@ -1417,12 +1424,8 @@ class BloomEffect {
1417
1424
  const falloff = 1 - distSq / radiusSq;
1418
1425
  const bloomAmount = bright.intensity * strength * falloff;
1419
1426
  const destIndex = (sampleY * width + sampleX) * 4;
1420
- destFg[destIndex] = Math.min(1, destFg[destIndex] + bloomAmount);
1421
- destFg[destIndex + 1] = Math.min(1, destFg[destIndex + 1] + bloomAmount);
1422
- destFg[destIndex + 2] = Math.min(1, destFg[destIndex + 2] + bloomAmount);
1423
- destBg[destIndex] = Math.min(1, destBg[destIndex] + bloomAmount);
1424
- destBg[destIndex + 1] = Math.min(1, destBg[destIndex + 1] + bloomAmount);
1425
- destBg[destIndex + 2] = Math.min(1, destBg[destIndex + 2] + bloomAmount);
1427
+ setRgb2(destFg, destIndex, Math.min(1, channel2(destFg, destIndex) + bloomAmount), Math.min(1, channel2(destFg, destIndex + 1) + bloomAmount), Math.min(1, channel2(destFg, destIndex + 2) + bloomAmount));
1428
+ setRgb2(destBg, destIndex, Math.min(1, channel2(destBg, destIndex) + bloomAmount), Math.min(1, channel2(destBg, destIndex + 1) + bloomAmount), Math.min(1, channel2(destBg, destIndex + 2) + bloomAmount));
1426
1429
  }
1427
1430
  }
1428
1431
  }
@@ -6146,7 +6149,15 @@ class TextTableRenderable extends Renderable {
6146
6149
  for (let colIdx = 0;colIdx < this._columnCount; colIdx++) {
6147
6150
  const cellX = (colOffsets[colIdx] ?? 0) + 1;
6148
6151
  const colWidth = colWidths[colIdx] ?? 1;
6149
- buffer.fillRect(cellX, cellY, colWidth, rowHeight, this._backgroundColor);
6152
+ if (this._backgroundColor.a < 1) {
6153
+ for (let y = cellY;y < cellY + rowHeight; y++) {
6154
+ for (let x = cellX;x < cellX + colWidth; x++) {
6155
+ buffer.setCell(x, y, " ", this._defaultFg, this._backgroundColor, this._defaultAttributes);
6156
+ }
6157
+ }
6158
+ } else {
6159
+ buffer.fillRect(cellX, cellY, colWidth, rowHeight, this._backgroundColor);
6160
+ }
6150
6161
  }
6151
6162
  }
6152
6163
  }
@@ -6186,6 +6197,11 @@ class TextTableRenderable extends Renderable {
6186
6197
  return { rowIdx, colIdx };
6187
6198
  }
6188
6199
  applySelectionToCells(localSelection, isStart) {
6200
+ if (localSelection.anchorX === localSelection.focusX && localSelection.anchorY === localSelection.focusY) {
6201
+ this.resetCellSelections();
6202
+ this._lastSelectionMode = null;
6203
+ return;
6204
+ }
6189
6205
  const minSelY = Math.min(localSelection.anchorY, localSelection.focusY);
6190
6206
  const maxSelY = Math.max(localSelection.anchorY, localSelection.focusY);
6191
6207
  const firstRow = this.findRowForLocalY(minSelY);
@@ -6216,6 +6232,10 @@ class TextTableRenderable extends Renderable {
6216
6232
  focusY: localSelection.focusY - cellTop
6217
6233
  };
6218
6234
  const isAnchorCell = selection.anchorCell !== null && selection.anchorCell.rowIdx === rowIdx && selection.anchorCell.colIdx === colIdx;
6235
+ if (selection.mode === "single-cell" && !isAnchorCell) {
6236
+ cell.textBufferView.resetLocalSelection();
6237
+ continue;
6238
+ }
6219
6239
  const forceSet = isAnchorCell && selection.mode !== "single-cell";
6220
6240
  if (forceSet) {
6221
6241
  coords = this.getFullCellSelectionCoords(rowIdx, colIdx);
@@ -10754,5 +10774,5 @@ class TimeToFirstDrawRenderable extends Renderable {
10754
10774
  }
10755
10775
  export { DistortionEffect, VignetteEffect, CloudsEffect, FlamesEffect, CRTRollingBarEffect, RainbowTextEffect, applyScanlines, applyInvert, applyNoise, applyChromaticAberration, applyAsciiArt, applyBrightness, applyGain, applySaturation, BloomEffect, SEPIA_MATRIX, PROTANOPIA_SIM_MATRIX, DEUTERANOPIA_SIM_MATRIX, TRITANOPIA_SIM_MATRIX, ACHROMATOPSIA_MATRIX, PROTANOPIA_COMP_MATRIX, DEUTERANOPIA_COMP_MATRIX, TRITANOPIA_COMP_MATRIX, TECHNICOLOR_MATRIX, SOLARIZATION_MATRIX, SYNTHWAVE_MATRIX, GREENSCALE_MATRIX, GRAYSCALE_MATRIX, INVERT_MATRIX, Timeline, engine, createTimeline, SlotRegistry, createSlotRegistry, createCoreSlotRegistry, registerCorePlugin, resolveCoreSlot, SlotRenderable, NativeSpanFeed, FrameBufferRenderable, ASCIIFontRenderable, Generic, Box, Text, ASCIIFont, Input, Select, TabSelect, FrameBuffer, Code, ScrollBox, vstyles, VRenderable, LineNumberRenderable, DiffRenderable, defaultTextareaKeyBindings, TextareaRenderable, InputRenderableEvents, InputRenderable, TextTableRenderable, MarkdownRenderable, SliderRenderable, ScrollBarRenderable, ArrowRenderable, ScrollBoxRenderable, SelectRenderableEvents, SelectRenderable, TabSelectRenderableEvents, TabSelectRenderable, TimeToFirstDrawRenderable, exports_src2 as exports_src };
10756
10776
 
10757
- //# debugId=6608E532EE6A69FA64756E2164756E21
10758
- //# sourceMappingURL=index-jfshts6b.js.map
10777
+ //# debugId=1EC456BC9A30AA3564756E2164756E21
10778
+ //# sourceMappingURL=index-mch6dv67.js.map