@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 +1 -1
- package/buffer.d.ts +2 -4
- package/{index-h1ewdzdj.js → index-epp5y71w.js} +3 -3
- package/{index-jfshts6b.js → index-mch6dv67.js} +70 -50
- package/{index-jfshts6b.js.map → index-mch6dv67.js.map} +5 -5
- package/{index-jct3zgy3.js → index-mw2x3082.js} +128 -176
- package/{index-jct3zgy3.js.map → index-mw2x3082.js.map} +9 -9
- package/index.js +3 -9
- package/index.js.map +1 -1
- package/lib/RGBA.d.ts +10 -17
- package/package.json +10 -8
- package/platform/ffi.d.ts +64 -0
- package/platform/runtime.d.ts +8 -0
- package/platform/worker.d.ts +4 -0
- package/runtime-plugin-support.js +3 -3
- package/runtime-plugin.js +3 -3
- package/syntax-style.d.ts +10 -2
- package/testing/test-recorder.d.ts +2 -2
- package/testing.js +4 -4
- package/testing.js.map +3 -3
- package/zig-structs.d.ts +0 -6
- package/zig.d.ts +0 -2
- /package/{index-h1ewdzdj.js.map → index-epp5y71w.js.map} +0 -0
package/3d.js
CHANGED
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:
|
|
26
|
-
bg:
|
|
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-
|
|
4
|
+
} from "./index-mch6dv67.js";
|
|
5
5
|
import {
|
|
6
6
|
__require
|
|
7
|
-
} from "./index-
|
|
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-
|
|
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-
|
|
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
|
|
506
|
-
tempBg = new
|
|
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
|
|
614
|
-
buf.
|
|
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
|
|
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
|
|
952
|
-
|
|
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
|
|
1056
|
-
const g = fg2
|
|
1057
|
-
const b = fg2
|
|
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
|
|
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 =
|
|
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
|
|
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
|
|
1203
|
-
const bgG = bg2
|
|
1204
|
-
const bgB = bg2
|
|
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 =
|
|
1386
|
-
const srcBg =
|
|
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
|
|
1394
|
-
const bgLum = 0.299 * srcBg
|
|
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
|
|
1421
|
-
|
|
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
|
-
|
|
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=
|
|
10758
|
-
//# sourceMappingURL=index-
|
|
10777
|
+
//# debugId=1EC456BC9A30AA3564756E2164756E21
|
|
10778
|
+
//# sourceMappingURL=index-mch6dv67.js.map
|