@opentui/core 0.1.88 → 0.1.89
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 +5 -3
- package/{index-nkrr8a4c.js → index-e89anq5x.js} +743 -123
- package/{index-nkrr8a4c.js.map → index-e89anq5x.js.map} +13 -13
- package/{index-nyw5p3ep.js → index-rs5zwr4j.js} +272 -518
- package/{index-nyw5p3ep.js.map → index-rs5zwr4j.js.map} +4 -4
- package/index-tae5jwnc.js +188 -0
- package/index-tae5jwnc.js.map +10 -0
- package/index.js +17 -15
- package/index.js.map +1 -1
- package/lib/stdin-parser.d.ts +10 -0
- package/lib/tree-sitter/default-parsers.d.ts +1 -1
- package/lib/tree-sitter/parsers-config.d.ts +15 -0
- package/lib/tree-sitter/resolve-ft.d.ts +3 -0
- package/lib/tree-sitter/types.d.ts +1 -0
- package/package.json +7 -7
- package/parser.worker.js +52 -18
- package/parser.worker.js.map +3 -3
- package/post/effects.d.ts +147 -0
- package/post/filters.d.ts +27 -67
- package/post/matrices.d.ts +20 -0
- package/renderables/Markdown.d.ts +9 -1
- package/renderer.d.ts +12 -1
- package/runtime-plugin-support.js +3 -3
- package/runtime-plugin.js +3 -3
- package/testing/manual-clock.d.ts +1 -0
- package/testing.js +1 -1
- package/types.d.ts +5 -0
- package/zig.d.ts +3 -1
- package/index-e4hzc2j2.js +0 -113
- package/index-e4hzc2j2.js.map +0 -10
|
@@ -37,6 +37,7 @@ import {
|
|
|
37
37
|
StdinParser,
|
|
38
38
|
StyledText,
|
|
39
39
|
SystemClock,
|
|
40
|
+
TargetChannel,
|
|
40
41
|
TerminalConsole,
|
|
41
42
|
TerminalPalette,
|
|
42
43
|
TextAttributes,
|
|
@@ -45,6 +46,7 @@ import {
|
|
|
45
46
|
__export,
|
|
46
47
|
addDefaultParsers,
|
|
47
48
|
attributesWithLink,
|
|
49
|
+
basenameToFiletype,
|
|
48
50
|
bg,
|
|
49
51
|
bgBlack,
|
|
50
52
|
bgBlue,
|
|
@@ -87,6 +89,7 @@ import {
|
|
|
87
89
|
envRegistry,
|
|
88
90
|
exports_src,
|
|
89
91
|
extToFiletype,
|
|
92
|
+
extensionToFiletype,
|
|
90
93
|
fg,
|
|
91
94
|
fonts,
|
|
92
95
|
generateEnvColored,
|
|
@@ -105,6 +108,7 @@ import {
|
|
|
105
108
|
hastToStyledText,
|
|
106
109
|
hexToRgb,
|
|
107
110
|
hsvToRgb,
|
|
111
|
+
infoStringToFiletype,
|
|
108
112
|
instantiate,
|
|
109
113
|
isRenderable,
|
|
110
114
|
isStyledText,
|
|
@@ -158,7 +162,7 @@ import {
|
|
|
158
162
|
white,
|
|
159
163
|
wrapWithDelegates,
|
|
160
164
|
yellow
|
|
161
|
-
} from "./index-
|
|
165
|
+
} from "./index-e89anq5x.js";
|
|
162
166
|
|
|
163
167
|
// src/index.ts
|
|
164
168
|
var exports_src2 = {};
|
|
@@ -217,6 +221,7 @@ __export(exports_src2, {
|
|
|
217
221
|
isStyledText: () => isStyledText,
|
|
218
222
|
isRenderable: () => isRenderable,
|
|
219
223
|
instantiate: () => instantiate,
|
|
224
|
+
infoStringToFiletype: () => infoStringToFiletype,
|
|
220
225
|
hsvToRgb: () => hsvToRgb,
|
|
221
226
|
hexToRgb: () => hexToRgb,
|
|
222
227
|
hastToStyledText: () => hastToStyledText,
|
|
@@ -233,6 +238,7 @@ __export(exports_src2, {
|
|
|
233
238
|
generateEnvColored: () => generateEnvColored,
|
|
234
239
|
fonts: () => fonts,
|
|
235
240
|
fg: () => fg,
|
|
241
|
+
extensionToFiletype: () => extensionToFiletype,
|
|
236
242
|
extToFiletype: () => extToFiletype,
|
|
237
243
|
envRegistry: () => envRegistry,
|
|
238
244
|
env: () => env,
|
|
@@ -277,17 +283,18 @@ __export(exports_src2, {
|
|
|
277
283
|
bgBlue: () => bgBlue,
|
|
278
284
|
bgBlack: () => bgBlack,
|
|
279
285
|
bg: () => bg,
|
|
286
|
+
basenameToFiletype: () => basenameToFiletype,
|
|
280
287
|
attributesWithLink: () => attributesWithLink,
|
|
281
|
-
applySepia: () => applySepia,
|
|
282
288
|
applyScanlines: () => applyScanlines,
|
|
289
|
+
applySaturation: () => applySaturation,
|
|
283
290
|
applyNoise: () => applyNoise,
|
|
284
291
|
applyInvert: () => applyInvert,
|
|
285
|
-
|
|
292
|
+
applyGain: () => applyGain,
|
|
286
293
|
applyChromaticAberration: () => applyChromaticAberration,
|
|
294
|
+
applyBrightness: () => applyBrightness,
|
|
287
295
|
applyAsciiArt: () => applyAsciiArt,
|
|
288
296
|
addDefaultParsers: () => addDefaultParsers,
|
|
289
297
|
Yoga: () => exports_src,
|
|
290
|
-
VignetteEffect: () => VignetteEffect,
|
|
291
298
|
VRenderable: () => VRenderable,
|
|
292
299
|
TreeSitterClient: () => TreeSitterClient,
|
|
293
300
|
Timeline: () => Timeline,
|
|
@@ -303,6 +310,7 @@ __export(exports_src2, {
|
|
|
303
310
|
Text: () => Text,
|
|
304
311
|
TerminalPalette: () => TerminalPalette,
|
|
305
312
|
TerminalConsole: () => TerminalConsole,
|
|
313
|
+
TargetChannel: () => TargetChannel,
|
|
306
314
|
TabSelectRenderableEvents: () => TabSelectRenderableEvents,
|
|
307
315
|
TabSelectRenderable: () => TabSelectRenderable,
|
|
308
316
|
TabSelect: () => TabSelect,
|
|
@@ -350,7 +358,6 @@ __export(exports_src2, {
|
|
|
350
358
|
ExtmarksController: () => ExtmarksController,
|
|
351
359
|
EditorView: () => EditorView,
|
|
352
360
|
EditBuffer: () => EditBuffer,
|
|
353
|
-
DistortionEffect: () => DistortionEffect,
|
|
354
361
|
DiffRenderable: () => DiffRenderable,
|
|
355
362
|
DebugOverlayCorner: () => DebugOverlayCorner,
|
|
356
363
|
DataPathsManager: () => DataPathsManager,
|
|
@@ -359,12 +366,10 @@ __export(exports_src2, {
|
|
|
359
366
|
Code: () => Code,
|
|
360
367
|
CliRenderer: () => CliRenderer,
|
|
361
368
|
CliRenderEvents: () => CliRenderEvents,
|
|
362
|
-
BrightnessEffect: () => BrightnessEffect,
|
|
363
369
|
BoxRenderable: () => BoxRenderable,
|
|
364
370
|
Box: () => Box,
|
|
365
371
|
BorderChars: () => BorderChars,
|
|
366
372
|
BorderCharArrays: () => BorderCharArrays,
|
|
367
|
-
BlurEffect: () => BlurEffect,
|
|
368
373
|
BloomEffect: () => BloomEffect,
|
|
369
374
|
BaseRenderable: () => BaseRenderable,
|
|
370
375
|
ArrowRenderable: () => ArrowRenderable,
|
|
@@ -1199,94 +1204,100 @@ class SyntaxStyle {
|
|
|
1199
1204
|
}
|
|
1200
1205
|
// src/post/filters.ts
|
|
1201
1206
|
function applyScanlines(buffer, strength = 0.8, step = 2) {
|
|
1207
|
+
if (strength === 1 || step < 1)
|
|
1208
|
+
return;
|
|
1202
1209
|
const width = buffer.width;
|
|
1203
1210
|
const height = buffer.height;
|
|
1204
|
-
const
|
|
1211
|
+
const affectedRows = Math.ceil(height / step);
|
|
1212
|
+
const cellCount = width * affectedRows;
|
|
1213
|
+
const cellMask = new Float32Array(cellCount * 3);
|
|
1214
|
+
let maskIdx = 0;
|
|
1205
1215
|
for (let y = 0;y < height; y += step) {
|
|
1206
1216
|
for (let x = 0;x < width; x++) {
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1217
|
+
cellMask[maskIdx++] = x;
|
|
1218
|
+
cellMask[maskIdx++] = y;
|
|
1219
|
+
cellMask[maskIdx++] = 1;
|
|
1220
|
+
}
|
|
1221
|
+
}
|
|
1222
|
+
const s = strength;
|
|
1223
|
+
const matrix = new Float32Array([
|
|
1224
|
+
s,
|
|
1225
|
+
0,
|
|
1226
|
+
0,
|
|
1227
|
+
0,
|
|
1228
|
+
0,
|
|
1229
|
+
s,
|
|
1230
|
+
0,
|
|
1231
|
+
0,
|
|
1232
|
+
0,
|
|
1233
|
+
0,
|
|
1234
|
+
s,
|
|
1235
|
+
0,
|
|
1236
|
+
0,
|
|
1237
|
+
0,
|
|
1238
|
+
0,
|
|
1239
|
+
1
|
|
1240
|
+
]);
|
|
1241
|
+
buffer.colorMatrix(matrix, cellMask, 1, 2);
|
|
1213
1242
|
}
|
|
1214
|
-
function
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
const
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
function applySepia(buffer) {
|
|
1237
|
-
const size = buffer.width * buffer.height;
|
|
1238
|
-
const fg2 = buffer.buffers.fg;
|
|
1239
|
-
const bg2 = buffer.buffers.bg;
|
|
1240
|
-
for (let i = 0;i < size; i++) {
|
|
1241
|
-
const colorIndex = i * 4;
|
|
1242
|
-
let fgR = fg2[colorIndex];
|
|
1243
|
-
let fgG = fg2[colorIndex + 1];
|
|
1244
|
-
let fgB = fg2[colorIndex + 2];
|
|
1245
|
-
let newFgR = Math.min(1, fgR * 0.393 + fgG * 0.769 + fgB * 0.189);
|
|
1246
|
-
let newFgG = Math.min(1, fgR * 0.349 + fgG * 0.686 + fgB * 0.168);
|
|
1247
|
-
let newFgB = Math.min(1, fgR * 0.272 + fgG * 0.534 + fgB * 0.131);
|
|
1248
|
-
fg2[colorIndex] = newFgR;
|
|
1249
|
-
fg2[colorIndex + 1] = newFgG;
|
|
1250
|
-
fg2[colorIndex + 2] = newFgB;
|
|
1251
|
-
let bgR = bg2[colorIndex];
|
|
1252
|
-
let bgG = bg2[colorIndex + 1];
|
|
1253
|
-
let bgB = bg2[colorIndex + 2];
|
|
1254
|
-
let newBgR = Math.min(1, bgR * 0.393 + bgG * 0.769 + bgB * 0.189);
|
|
1255
|
-
let newBgG = Math.min(1, bgR * 0.349 + bgG * 0.686 + bgB * 0.168);
|
|
1256
|
-
let newBgB = Math.min(1, bgR * 0.272 + bgG * 0.534 + bgB * 0.131);
|
|
1257
|
-
bg2[colorIndex] = newBgR;
|
|
1258
|
-
bg2[colorIndex + 1] = newBgG;
|
|
1259
|
-
bg2[colorIndex + 2] = newBgB;
|
|
1260
|
-
}
|
|
1261
|
-
}
|
|
1262
|
-
function applyInvert(buffer) {
|
|
1263
|
-
const size = buffer.width * buffer.height;
|
|
1264
|
-
const fg2 = buffer.buffers.fg;
|
|
1265
|
-
const bg2 = buffer.buffers.bg;
|
|
1266
|
-
for (let i = 0;i < size; i++) {
|
|
1267
|
-
const colorIndex = i * 4;
|
|
1268
|
-
fg2[colorIndex] = 1 - fg2[colorIndex];
|
|
1269
|
-
fg2[colorIndex + 1] = 1 - fg2[colorIndex + 1];
|
|
1270
|
-
fg2[colorIndex + 2] = 1 - fg2[colorIndex + 2];
|
|
1271
|
-
bg2[colorIndex] = 1 - bg2[colorIndex];
|
|
1272
|
-
bg2[colorIndex + 1] = 1 - bg2[colorIndex + 1];
|
|
1273
|
-
bg2[colorIndex + 2] = 1 - bg2[colorIndex + 2];
|
|
1274
|
-
}
|
|
1243
|
+
function applyInvert(buffer, strength = 1) {
|
|
1244
|
+
if (strength === 0)
|
|
1245
|
+
return;
|
|
1246
|
+
const matrix = new Float32Array([
|
|
1247
|
+
-1,
|
|
1248
|
+
0,
|
|
1249
|
+
0,
|
|
1250
|
+
1,
|
|
1251
|
+
0,
|
|
1252
|
+
-1,
|
|
1253
|
+
0,
|
|
1254
|
+
1,
|
|
1255
|
+
0,
|
|
1256
|
+
0,
|
|
1257
|
+
-1,
|
|
1258
|
+
1,
|
|
1259
|
+
0,
|
|
1260
|
+
0,
|
|
1261
|
+
0,
|
|
1262
|
+
1
|
|
1263
|
+
]);
|
|
1264
|
+
buffer.colorMatrixUniform(matrix, strength, 3);
|
|
1275
1265
|
}
|
|
1276
1266
|
function applyNoise(buffer, strength = 0.1) {
|
|
1277
|
-
const
|
|
1278
|
-
const
|
|
1279
|
-
const
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1267
|
+
const width = buffer.width;
|
|
1268
|
+
const height = buffer.height;
|
|
1269
|
+
const size = width * height;
|
|
1270
|
+
if (strength === 0)
|
|
1271
|
+
return;
|
|
1272
|
+
const cellMask = new Float32Array(size * 3);
|
|
1273
|
+
let cellMaskIndex = 0;
|
|
1274
|
+
for (let y = 0;y < height; y++) {
|
|
1275
|
+
for (let x = 0;x < width; x++) {
|
|
1276
|
+
cellMask[cellMaskIndex++] = x;
|
|
1277
|
+
cellMask[cellMaskIndex++] = y;
|
|
1278
|
+
cellMask[cellMaskIndex++] = (Math.random() - 0.5) * 2;
|
|
1279
|
+
}
|
|
1280
|
+
}
|
|
1281
|
+
const b = 1 + strength;
|
|
1282
|
+
const matrix = new Float32Array([
|
|
1283
|
+
b,
|
|
1284
|
+
0,
|
|
1285
|
+
0,
|
|
1286
|
+
0,
|
|
1287
|
+
0,
|
|
1288
|
+
b,
|
|
1289
|
+
0,
|
|
1290
|
+
0,
|
|
1291
|
+
0,
|
|
1292
|
+
0,
|
|
1293
|
+
b,
|
|
1294
|
+
0,
|
|
1295
|
+
0,
|
|
1296
|
+
0,
|
|
1297
|
+
0,
|
|
1298
|
+
1
|
|
1299
|
+
]);
|
|
1300
|
+
buffer.colorMatrix(matrix, cellMask, 1, 3);
|
|
1290
1301
|
}
|
|
1291
1302
|
function applyChromaticAberration(buffer, strength = 1) {
|
|
1292
1303
|
const width = buffer.width;
|
|
@@ -1312,7 +1323,7 @@ function applyChromaticAberration(buffer, strength = 1) {
|
|
|
1312
1323
|
}
|
|
1313
1324
|
}
|
|
1314
1325
|
}
|
|
1315
|
-
function applyAsciiArt(buffer, ramp =
|
|
1326
|
+
function applyAsciiArt(buffer, ramp = ' .\'`^"",:;Il!i><~+_-?][}{1)(|\\/tfjrxnuvczXYUJCLQ0OZmwqpdbkhao*#MW&8%B@$', fgColor = { r: 1, g: 1, b: 1 }, bgColor = { r: 0, g: 0, b: 0 }) {
|
|
1316
1327
|
const width = buffer.width;
|
|
1317
1328
|
const height = buffer.height;
|
|
1318
1329
|
const chars = buffer.buffers.char;
|
|
@@ -1330,437 +1341,143 @@ function applyAsciiArt(buffer, ramp = " .:-=+*#%@") {
|
|
|
1330
1341
|
chars[index] = ramp[rampIndex].charCodeAt(0);
|
|
1331
1342
|
}
|
|
1332
1343
|
}
|
|
1344
|
+
const fgMatrix = new Float32Array([
|
|
1345
|
+
0,
|
|
1346
|
+
0,
|
|
1347
|
+
0,
|
|
1348
|
+
fgColor.r,
|
|
1349
|
+
0,
|
|
1350
|
+
0,
|
|
1351
|
+
0,
|
|
1352
|
+
fgColor.g,
|
|
1353
|
+
0,
|
|
1354
|
+
0,
|
|
1355
|
+
0,
|
|
1356
|
+
fgColor.b,
|
|
1357
|
+
0,
|
|
1358
|
+
0,
|
|
1359
|
+
0,
|
|
1360
|
+
1
|
|
1361
|
+
]);
|
|
1362
|
+
const bgMatrix = new Float32Array([
|
|
1363
|
+
0,
|
|
1364
|
+
0,
|
|
1365
|
+
0,
|
|
1366
|
+
bgColor.r,
|
|
1367
|
+
0,
|
|
1368
|
+
0,
|
|
1369
|
+
0,
|
|
1370
|
+
bgColor.g,
|
|
1371
|
+
0,
|
|
1372
|
+
0,
|
|
1373
|
+
0,
|
|
1374
|
+
bgColor.b,
|
|
1375
|
+
0,
|
|
1376
|
+
0,
|
|
1377
|
+
0,
|
|
1378
|
+
1
|
|
1379
|
+
]);
|
|
1380
|
+
buffer.colorMatrixUniform(fgMatrix, 1, 1);
|
|
1381
|
+
buffer.colorMatrixUniform(bgMatrix, 1, 2);
|
|
1333
1382
|
}
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
if (this.activeGlitches.length === 0 && Math.random() < this.glitchChancePerSecond * deltaTime) {
|
|
1361
|
-
this.lastGlitchTime = 0;
|
|
1362
|
-
this.glitchDuration = this.minGlitchDuration + Math.random() * (this.maxGlitchDuration - this.minGlitchDuration);
|
|
1363
|
-
const numGlitches = 1 + Math.floor(Math.random() * this.maxGlitchLines);
|
|
1364
|
-
for (let i = 0;i < numGlitches; i++) {
|
|
1365
|
-
const y = Math.floor(Math.random() * height);
|
|
1366
|
-
let type;
|
|
1367
|
-
let amount = 0;
|
|
1368
|
-
const typeRoll = Math.random();
|
|
1369
|
-
if (typeRoll < this.colorGlitchChance) {
|
|
1370
|
-
type = "color";
|
|
1371
|
-
} else {
|
|
1372
|
-
const shiftRoll = (typeRoll - this.colorGlitchChance) / (1 - this.colorGlitchChance);
|
|
1373
|
-
if (shiftRoll < this.shiftFlipRatio) {
|
|
1374
|
-
type = "shift";
|
|
1375
|
-
amount = Math.floor((Math.random() - 0.5) * 2 * this.maxShiftAmount);
|
|
1376
|
-
} else {
|
|
1377
|
-
type = "flip";
|
|
1378
|
-
}
|
|
1379
|
-
}
|
|
1380
|
-
if (!this.activeGlitches.some((g) => g.y === y)) {
|
|
1381
|
-
this.activeGlitches.push({ y, type, amount });
|
|
1382
|
-
}
|
|
1383
|
-
}
|
|
1384
|
-
}
|
|
1385
|
-
if (this.activeGlitches.length > 0) {
|
|
1386
|
-
let tempChar = null;
|
|
1387
|
-
let tempFg = null;
|
|
1388
|
-
let tempBg = null;
|
|
1389
|
-
let tempAttr = null;
|
|
1390
|
-
for (const glitch of this.activeGlitches) {
|
|
1391
|
-
const y = glitch.y;
|
|
1392
|
-
if (y < 0 || y >= height)
|
|
1393
|
-
continue;
|
|
1394
|
-
const baseIndex = y * width;
|
|
1395
|
-
if (glitch.type === "shift" || glitch.type === "flip") {
|
|
1396
|
-
if (!tempChar) {
|
|
1397
|
-
tempChar = new Uint32Array(width);
|
|
1398
|
-
tempFg = new Float32Array(width * 4);
|
|
1399
|
-
tempBg = new Float32Array(width * 4);
|
|
1400
|
-
tempAttr = new Uint8Array(width);
|
|
1401
|
-
}
|
|
1402
|
-
try {
|
|
1403
|
-
tempChar.set(buf.char.subarray(baseIndex, baseIndex + width));
|
|
1404
|
-
tempFg.set(buf.fg.subarray(baseIndex * 4, (baseIndex + width) * 4));
|
|
1405
|
-
tempBg.set(buf.bg.subarray(baseIndex * 4, (baseIndex + width) * 4));
|
|
1406
|
-
tempAttr.set(buf.attributes.subarray(baseIndex, baseIndex + width));
|
|
1407
|
-
} catch (e) {
|
|
1408
|
-
console.error(`Error copying row ${y} for distortion:`, e);
|
|
1409
|
-
continue;
|
|
1410
|
-
}
|
|
1411
|
-
if (glitch.type === "shift") {
|
|
1412
|
-
const shift = glitch.amount;
|
|
1413
|
-
for (let x = 0;x < width; x++) {
|
|
1414
|
-
const srcX = (x - shift + width) % width;
|
|
1415
|
-
const destIndex = baseIndex + x;
|
|
1416
|
-
const srcTempIndex = srcX;
|
|
1417
|
-
buf.char[destIndex] = tempChar[srcTempIndex];
|
|
1418
|
-
buf.attributes[destIndex] = tempAttr[srcTempIndex];
|
|
1419
|
-
const destColorIndex = destIndex * 4;
|
|
1420
|
-
const srcTempColorIndex = srcTempIndex * 4;
|
|
1421
|
-
buf.fg.set(tempFg.subarray(srcTempColorIndex, srcTempColorIndex + 4), destColorIndex);
|
|
1422
|
-
buf.bg.set(tempBg.subarray(srcTempColorIndex, srcTempColorIndex + 4), destColorIndex);
|
|
1423
|
-
}
|
|
1424
|
-
} else {
|
|
1425
|
-
for (let x = 0;x < width; x++) {
|
|
1426
|
-
const srcX = width - 1 - x;
|
|
1427
|
-
const destIndex = baseIndex + x;
|
|
1428
|
-
const srcTempIndex = srcX;
|
|
1429
|
-
buf.char[destIndex] = tempChar[srcTempIndex];
|
|
1430
|
-
buf.attributes[destIndex] = tempAttr[srcTempIndex];
|
|
1431
|
-
const destColorIndex = destIndex * 4;
|
|
1432
|
-
const srcTempColorIndex = srcTempIndex * 4;
|
|
1433
|
-
buf.fg.set(tempFg.subarray(srcTempColorIndex, srcTempColorIndex + 4), destColorIndex);
|
|
1434
|
-
buf.bg.set(tempBg.subarray(srcTempColorIndex, srcTempColorIndex + 4), destColorIndex);
|
|
1435
|
-
}
|
|
1436
|
-
}
|
|
1437
|
-
} else if (glitch.type === "color") {
|
|
1438
|
-
const glitchStart = Math.floor(Math.random() * width);
|
|
1439
|
-
const maxPossibleLength = width - glitchStart;
|
|
1440
|
-
let glitchLength = Math.floor(Math.random() * maxPossibleLength) + 1;
|
|
1441
|
-
if (Math.random() < 0.2) {
|
|
1442
|
-
glitchLength = Math.floor(Math.random() * (width / 4)) + 1;
|
|
1443
|
-
}
|
|
1444
|
-
glitchLength = Math.min(glitchLength, maxPossibleLength);
|
|
1445
|
-
for (let x = glitchStart;x < glitchStart + glitchLength; x++) {
|
|
1446
|
-
if (x >= width)
|
|
1447
|
-
break;
|
|
1448
|
-
const destIndex = baseIndex + x;
|
|
1449
|
-
const destColorIndex = destIndex * 4;
|
|
1450
|
-
let rFg, gFg, bFg, rBg, gBg, bBg;
|
|
1451
|
-
const colorMode = Math.random();
|
|
1452
|
-
if (colorMode < 0.33) {
|
|
1453
|
-
rFg = Math.random();
|
|
1454
|
-
gFg = Math.random();
|
|
1455
|
-
bFg = Math.random();
|
|
1456
|
-
rBg = Math.random();
|
|
1457
|
-
gBg = Math.random();
|
|
1458
|
-
bBg = Math.random();
|
|
1459
|
-
} else if (colorMode < 0.66) {
|
|
1460
|
-
const emphasis = Math.random();
|
|
1461
|
-
if (emphasis < 0.25) {
|
|
1462
|
-
rFg = Math.random();
|
|
1463
|
-
gFg = 0;
|
|
1464
|
-
bFg = 0;
|
|
1465
|
-
} else if (emphasis < 0.5) {
|
|
1466
|
-
rFg = 0;
|
|
1467
|
-
gFg = Math.random();
|
|
1468
|
-
bFg = 0;
|
|
1469
|
-
} else if (emphasis < 0.75) {
|
|
1470
|
-
rFg = 0;
|
|
1471
|
-
gFg = 0;
|
|
1472
|
-
bFg = Math.random();
|
|
1473
|
-
} else {
|
|
1474
|
-
const glitchColorRoll = Math.random();
|
|
1475
|
-
if (glitchColorRoll < 0.33) {
|
|
1476
|
-
rFg = 1;
|
|
1477
|
-
gFg = 0;
|
|
1478
|
-
bFg = 1;
|
|
1479
|
-
} else if (glitchColorRoll < 0.66) {
|
|
1480
|
-
rFg = 0;
|
|
1481
|
-
gFg = 1;
|
|
1482
|
-
bFg = 1;
|
|
1483
|
-
} else {
|
|
1484
|
-
rFg = 1;
|
|
1485
|
-
gFg = 1;
|
|
1486
|
-
bFg = 0;
|
|
1487
|
-
}
|
|
1488
|
-
}
|
|
1489
|
-
if (Math.random() < 0.5) {
|
|
1490
|
-
rBg = 1 - rFg;
|
|
1491
|
-
gBg = 1 - gFg;
|
|
1492
|
-
bBg = 1 - bFg;
|
|
1493
|
-
} else {
|
|
1494
|
-
rBg = rFg * (Math.random() * 0.5 + 0.2);
|
|
1495
|
-
gBg = gFg * (Math.random() * 0.5 + 0.2);
|
|
1496
|
-
bBg = bFg * (Math.random() * 0.5 + 0.2);
|
|
1497
|
-
}
|
|
1498
|
-
} else {
|
|
1499
|
-
rFg = Math.random() > 0.5 ? 1 : 0;
|
|
1500
|
-
gFg = Math.random() > 0.5 ? 1 : 0;
|
|
1501
|
-
bFg = Math.random() > 0.5 ? 1 : 0;
|
|
1502
|
-
rBg = 1 - rFg;
|
|
1503
|
-
gBg = 1 - gFg;
|
|
1504
|
-
bBg = 1 - bFg;
|
|
1505
|
-
}
|
|
1506
|
-
buf.fg[destColorIndex] = rFg;
|
|
1507
|
-
buf.fg[destColorIndex + 1] = gFg;
|
|
1508
|
-
buf.fg[destColorIndex + 2] = bFg;
|
|
1509
|
-
buf.bg[destColorIndex] = rBg;
|
|
1510
|
-
buf.bg[destColorIndex + 1] = gBg;
|
|
1511
|
-
buf.bg[destColorIndex + 2] = bBg;
|
|
1512
|
-
}
|
|
1513
|
-
}
|
|
1514
|
-
}
|
|
1515
|
-
}
|
|
1383
|
+
function applyBrightness(buffer, brightness = 0, cellMask) {
|
|
1384
|
+
if (brightness === 0)
|
|
1385
|
+
return;
|
|
1386
|
+
const b = brightness;
|
|
1387
|
+
const matrix = new Float32Array([
|
|
1388
|
+
1,
|
|
1389
|
+
0,
|
|
1390
|
+
0,
|
|
1391
|
+
b,
|
|
1392
|
+
0,
|
|
1393
|
+
1,
|
|
1394
|
+
0,
|
|
1395
|
+
b,
|
|
1396
|
+
0,
|
|
1397
|
+
0,
|
|
1398
|
+
1,
|
|
1399
|
+
b,
|
|
1400
|
+
0,
|
|
1401
|
+
0,
|
|
1402
|
+
0,
|
|
1403
|
+
1
|
|
1404
|
+
]);
|
|
1405
|
+
if (!cellMask || cellMask.length === 0) {
|
|
1406
|
+
buffer.colorMatrixUniform(matrix, 1, 3);
|
|
1407
|
+
} else {
|
|
1408
|
+
buffer.colorMatrix(matrix, cellMask, 1, 3);
|
|
1516
1409
|
}
|
|
1517
1410
|
}
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
const distSq = dx * dx + dySq;
|
|
1545
|
-
const baseAttenuation = Math.min(1, distSq / safeMaxDistSq);
|
|
1546
|
-
const index = y * width + x;
|
|
1547
|
-
this.precomputedBaseAttenuation[index] = baseAttenuation;
|
|
1548
|
-
}
|
|
1549
|
-
}
|
|
1550
|
-
this.cachedWidth = width;
|
|
1551
|
-
this.cachedHeight = height;
|
|
1552
|
-
}
|
|
1553
|
-
apply(buffer) {
|
|
1554
|
-
const width = buffer.width;
|
|
1555
|
-
const height = buffer.height;
|
|
1556
|
-
const buf = buffer.buffers;
|
|
1557
|
-
const size = width * height;
|
|
1558
|
-
if (width !== this.cachedWidth || height !== this.cachedHeight || !this.precomputedBaseAttenuation) {
|
|
1559
|
-
this._computeFactors(width, height);
|
|
1560
|
-
}
|
|
1561
|
-
for (let i = 0;i < size; i++) {
|
|
1562
|
-
const factor = Math.max(0, 1 - this.precomputedBaseAttenuation[i] * this._strength);
|
|
1563
|
-
const colorIndex = i * 4;
|
|
1564
|
-
buf.fg[colorIndex] *= factor;
|
|
1565
|
-
buf.fg[colorIndex + 1] *= factor;
|
|
1566
|
-
buf.fg[colorIndex + 2] *= factor;
|
|
1567
|
-
buf.bg[colorIndex] *= factor;
|
|
1568
|
-
buf.bg[colorIndex + 1] *= factor;
|
|
1569
|
-
buf.bg[colorIndex + 2] *= factor;
|
|
1570
|
-
}
|
|
1411
|
+
function applyGain(buffer, gain = 1, cellMask) {
|
|
1412
|
+
if (gain === 1)
|
|
1413
|
+
return;
|
|
1414
|
+
const g = Math.max(0, gain);
|
|
1415
|
+
const matrix = new Float32Array([
|
|
1416
|
+
g,
|
|
1417
|
+
0,
|
|
1418
|
+
0,
|
|
1419
|
+
0,
|
|
1420
|
+
0,
|
|
1421
|
+
g,
|
|
1422
|
+
0,
|
|
1423
|
+
0,
|
|
1424
|
+
0,
|
|
1425
|
+
0,
|
|
1426
|
+
g,
|
|
1427
|
+
0,
|
|
1428
|
+
0,
|
|
1429
|
+
0,
|
|
1430
|
+
0,
|
|
1431
|
+
1
|
|
1432
|
+
]);
|
|
1433
|
+
if (!cellMask || cellMask.length === 0) {
|
|
1434
|
+
buffer.colorMatrixUniform(matrix, 1, 3);
|
|
1435
|
+
} else {
|
|
1436
|
+
buffer.colorMatrix(matrix, cellMask, 1, 3);
|
|
1571
1437
|
}
|
|
1572
1438
|
}
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1439
|
+
function createSaturationMatrix(saturation) {
|
|
1440
|
+
const s = Math.max(0, saturation);
|
|
1441
|
+
const sr = 0.299 * (1 - s);
|
|
1442
|
+
const sg = 0.587 * (1 - s);
|
|
1443
|
+
const sb = 0.114 * (1 - s);
|
|
1444
|
+
const m00 = sr + s;
|
|
1445
|
+
const m01 = sg;
|
|
1446
|
+
const m02 = sb;
|
|
1447
|
+
const m10 = sr;
|
|
1448
|
+
const m11 = sg + s;
|
|
1449
|
+
const m12 = sb;
|
|
1450
|
+
const m20 = sr;
|
|
1451
|
+
const m21 = sg;
|
|
1452
|
+
const m22 = sb + s;
|
|
1453
|
+
return new Float32Array([
|
|
1454
|
+
m00,
|
|
1455
|
+
m01,
|
|
1456
|
+
m02,
|
|
1457
|
+
0,
|
|
1458
|
+
m10,
|
|
1459
|
+
m11,
|
|
1460
|
+
m12,
|
|
1461
|
+
0,
|
|
1462
|
+
m20,
|
|
1463
|
+
m21,
|
|
1464
|
+
m22,
|
|
1465
|
+
0,
|
|
1466
|
+
0,
|
|
1467
|
+
0,
|
|
1468
|
+
0,
|
|
1469
|
+
1
|
|
1470
|
+
]);
|
|
1603
1471
|
}
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
constructor(radius = 1) {
|
|
1608
|
-
this._radius = Math.max(0, Math.round(radius));
|
|
1609
|
-
}
|
|
1610
|
-
set radius(newRadius) {
|
|
1611
|
-
this._radius = Math.max(0, Math.round(newRadius));
|
|
1612
|
-
}
|
|
1613
|
-
get radius() {
|
|
1614
|
-
return this._radius;
|
|
1472
|
+
function applySaturation(buffer, cellMask, strength = 1) {
|
|
1473
|
+
if (strength === 1 || strength === 0) {
|
|
1474
|
+
return;
|
|
1615
1475
|
}
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
const height = buffer.height;
|
|
1622
|
-
const buf = buffer.buffers;
|
|
1623
|
-
const srcFg = buf.fg;
|
|
1624
|
-
const srcBg = buf.bg;
|
|
1625
|
-
const destFg = buf.fg;
|
|
1626
|
-
const destBg = buf.bg;
|
|
1627
|
-
const chars = buf.char;
|
|
1628
|
-
const size = width * height;
|
|
1629
|
-
const numChannels = 4;
|
|
1630
|
-
const tempBufferFg = new Float32Array(size * numChannels);
|
|
1631
|
-
const tempBufferBg = new Float32Array(size * numChannels);
|
|
1632
|
-
const windowSize = radius * 2 + 1;
|
|
1633
|
-
for (let y = 0;y < height; y++) {
|
|
1634
|
-
let sumR = 0, sumG = 0, sumB = 0, sumA = 0;
|
|
1635
|
-
const baseRowIndex = y * width;
|
|
1636
|
-
for (let x = -radius;x <= radius; x++) {
|
|
1637
|
-
const sampleX = Math.max(0, Math.min(width - 1, x));
|
|
1638
|
-
const srcIndex = (baseRowIndex + sampleX) * numChannels;
|
|
1639
|
-
sumR += srcFg[srcIndex];
|
|
1640
|
-
sumG += srcFg[srcIndex + 1];
|
|
1641
|
-
sumB += srcFg[srcIndex + 2];
|
|
1642
|
-
sumA += srcFg[srcIndex + 3];
|
|
1643
|
-
}
|
|
1644
|
-
for (let x = 0;x < width; x++) {
|
|
1645
|
-
const destIndex = (baseRowIndex + x) * numChannels;
|
|
1646
|
-
tempBufferFg[destIndex] = sumR / windowSize;
|
|
1647
|
-
tempBufferFg[destIndex + 1] = sumG / windowSize;
|
|
1648
|
-
tempBufferFg[destIndex + 2] = sumB / windowSize;
|
|
1649
|
-
tempBufferFg[destIndex + 3] = sumA / windowSize;
|
|
1650
|
-
const leavingX = Math.max(0, Math.min(width - 1, x - radius));
|
|
1651
|
-
const leavingIndex = (baseRowIndex + leavingX) * numChannels;
|
|
1652
|
-
sumR -= srcFg[leavingIndex];
|
|
1653
|
-
sumG -= srcFg[leavingIndex + 1];
|
|
1654
|
-
sumB -= srcFg[leavingIndex + 2];
|
|
1655
|
-
sumA -= srcFg[leavingIndex + 3];
|
|
1656
|
-
const enteringX = Math.max(0, Math.min(width - 1, x + radius + 1));
|
|
1657
|
-
const enteringIndex = (baseRowIndex + enteringX) * numChannels;
|
|
1658
|
-
sumR += srcFg[enteringIndex];
|
|
1659
|
-
sumG += srcFg[enteringIndex + 1];
|
|
1660
|
-
sumB += srcFg[enteringIndex + 2];
|
|
1661
|
-
sumA += srcFg[enteringIndex + 3];
|
|
1662
|
-
}
|
|
1663
|
-
}
|
|
1664
|
-
for (let y = 0;y < height; y++) {
|
|
1665
|
-
let sumR = 0, sumG = 0, sumB = 0, sumA = 0;
|
|
1666
|
-
const baseRowIndex = y * width;
|
|
1667
|
-
for (let x = -radius;x <= radius; x++) {
|
|
1668
|
-
const sampleX = Math.max(0, Math.min(width - 1, x));
|
|
1669
|
-
const srcIndex = (baseRowIndex + sampleX) * numChannels;
|
|
1670
|
-
sumR += srcBg[srcIndex];
|
|
1671
|
-
sumG += srcBg[srcIndex + 1];
|
|
1672
|
-
sumB += srcBg[srcIndex + 2];
|
|
1673
|
-
sumA += srcBg[srcIndex + 3];
|
|
1674
|
-
}
|
|
1675
|
-
for (let x = 0;x < width; x++) {
|
|
1676
|
-
const destIndex = (baseRowIndex + x) * numChannels;
|
|
1677
|
-
tempBufferBg[destIndex] = sumR / windowSize;
|
|
1678
|
-
tempBufferBg[destIndex + 1] = sumG / windowSize;
|
|
1679
|
-
tempBufferBg[destIndex + 2] = sumB / windowSize;
|
|
1680
|
-
tempBufferBg[destIndex + 3] = sumA / windowSize;
|
|
1681
|
-
const leavingX = Math.max(0, Math.min(width - 1, x - radius));
|
|
1682
|
-
const leavingIndex = (baseRowIndex + leavingX) * numChannels;
|
|
1683
|
-
sumR -= srcBg[leavingIndex];
|
|
1684
|
-
sumG -= srcBg[leavingIndex + 1];
|
|
1685
|
-
sumB -= srcBg[leavingIndex + 2];
|
|
1686
|
-
sumA -= srcBg[leavingIndex + 3];
|
|
1687
|
-
const enteringX = Math.max(0, Math.min(width - 1, x + radius + 1));
|
|
1688
|
-
const enteringIndex = (baseRowIndex + enteringX) * numChannels;
|
|
1689
|
-
sumR += srcBg[enteringIndex];
|
|
1690
|
-
sumG += srcBg[enteringIndex + 1];
|
|
1691
|
-
sumB += srcBg[enteringIndex + 2];
|
|
1692
|
-
sumA += srcBg[enteringIndex + 3];
|
|
1693
|
-
}
|
|
1694
|
-
}
|
|
1695
|
-
for (let x = 0;x < width; x++) {
|
|
1696
|
-
let sumR = 0, sumG = 0, sumB = 0, sumA = 0;
|
|
1697
|
-
for (let y = -radius;y <= radius; y++) {
|
|
1698
|
-
const sampleY = Math.max(0, Math.min(height - 1, y));
|
|
1699
|
-
const srcIndex = (sampleY * width + x) * numChannels;
|
|
1700
|
-
sumR += tempBufferFg[srcIndex];
|
|
1701
|
-
sumG += tempBufferFg[srcIndex + 1];
|
|
1702
|
-
sumB += tempBufferFg[srcIndex + 2];
|
|
1703
|
-
sumA += tempBufferFg[srcIndex + 3];
|
|
1704
|
-
}
|
|
1705
|
-
for (let y = 0;y < height; y++) {
|
|
1706
|
-
const destIndex = (y * width + x) * numChannels;
|
|
1707
|
-
destFg[destIndex] = sumR / windowSize;
|
|
1708
|
-
destFg[destIndex + 1] = sumG / windowSize;
|
|
1709
|
-
destFg[destIndex + 2] = sumB / windowSize;
|
|
1710
|
-
destFg[destIndex + 3] = sumA / windowSize;
|
|
1711
|
-
const leavingY = Math.max(0, Math.min(height - 1, y - radius));
|
|
1712
|
-
const leavingIndex = (leavingY * width + x) * numChannels;
|
|
1713
|
-
sumR -= tempBufferFg[leavingIndex];
|
|
1714
|
-
sumG -= tempBufferFg[leavingIndex + 1];
|
|
1715
|
-
sumB -= tempBufferFg[leavingIndex + 2];
|
|
1716
|
-
sumA -= tempBufferFg[leavingIndex + 3];
|
|
1717
|
-
const enteringY = Math.max(0, Math.min(height - 1, y + radius + 1));
|
|
1718
|
-
const enteringIndex = (enteringY * width + x) * numChannels;
|
|
1719
|
-
sumR += tempBufferFg[enteringIndex];
|
|
1720
|
-
sumG += tempBufferFg[enteringIndex + 1];
|
|
1721
|
-
sumB += tempBufferFg[enteringIndex + 2];
|
|
1722
|
-
sumA += tempBufferFg[enteringIndex + 3];
|
|
1723
|
-
}
|
|
1724
|
-
}
|
|
1725
|
-
for (let x = 0;x < width; x++) {
|
|
1726
|
-
let sumR = 0, sumG = 0, sumB = 0, sumA = 0;
|
|
1727
|
-
for (let y = -radius;y <= radius; y++) {
|
|
1728
|
-
const sampleY = Math.max(0, Math.min(height - 1, y));
|
|
1729
|
-
const srcIndex = (sampleY * width + x) * numChannels;
|
|
1730
|
-
sumR += tempBufferBg[srcIndex];
|
|
1731
|
-
sumG += tempBufferBg[srcIndex + 1];
|
|
1732
|
-
sumB += tempBufferBg[srcIndex + 2];
|
|
1733
|
-
sumA += tempBufferBg[srcIndex + 3];
|
|
1734
|
-
}
|
|
1735
|
-
for (let y = 0;y < height; y++) {
|
|
1736
|
-
const destIndex = (y * width + x) * numChannels;
|
|
1737
|
-
destBg[destIndex] = sumR / windowSize;
|
|
1738
|
-
destBg[destIndex + 1] = sumG / windowSize;
|
|
1739
|
-
destBg[destIndex + 2] = sumB / windowSize;
|
|
1740
|
-
destBg[destIndex + 3] = sumA / windowSize;
|
|
1741
|
-
const leavingY = Math.max(0, Math.min(height - 1, y - radius));
|
|
1742
|
-
const leavingIndex = (leavingY * width + x) * numChannels;
|
|
1743
|
-
sumR -= tempBufferBg[leavingIndex];
|
|
1744
|
-
sumG -= tempBufferBg[leavingIndex + 1];
|
|
1745
|
-
sumB -= tempBufferBg[leavingIndex + 2];
|
|
1746
|
-
sumA -= tempBufferBg[leavingIndex + 3];
|
|
1747
|
-
const enteringY = Math.max(0, Math.min(height - 1, y + radius + 1));
|
|
1748
|
-
const enteringIndex = (enteringY * width + x) * numChannels;
|
|
1749
|
-
sumR += tempBufferBg[enteringIndex];
|
|
1750
|
-
sumG += tempBufferBg[enteringIndex + 1];
|
|
1751
|
-
sumB += tempBufferBg[enteringIndex + 2];
|
|
1752
|
-
sumA += tempBufferBg[enteringIndex + 3];
|
|
1753
|
-
}
|
|
1754
|
-
}
|
|
1755
|
-
const charRamp = [" ", "\u2591", "\u2592", "\u2593", " "];
|
|
1756
|
-
const rampLength = charRamp.length;
|
|
1757
|
-
for (let i = 0;i < size; i++) {
|
|
1758
|
-
const alphaIndex = i * numChannels + 3;
|
|
1759
|
-
const fgAlpha = destFg[alphaIndex];
|
|
1760
|
-
const clampedAlpha = Math.max(0, Math.min(1, fgAlpha));
|
|
1761
|
-
const rampIndex = Math.min(rampLength - 1, Math.floor(clampedAlpha * rampLength));
|
|
1762
|
-
chars[i] = charRamp[rampIndex].charCodeAt(0);
|
|
1763
|
-
}
|
|
1476
|
+
const matrix = createSaturationMatrix(strength);
|
|
1477
|
+
if (!cellMask || cellMask.length === 0) {
|
|
1478
|
+
buffer.colorMatrixUniform(matrix, 1, 3);
|
|
1479
|
+
} else {
|
|
1480
|
+
buffer.colorMatrix(matrix, cellMask, 1, 3);
|
|
1764
1481
|
}
|
|
1765
1482
|
}
|
|
1766
1483
|
|
|
@@ -9780,10 +9497,17 @@ function parseMarkdownIncremental(newContent, prevState, trailingUnstable = 2) {
|
|
|
9780
9497
|
|
|
9781
9498
|
// src/renderables/Markdown.ts
|
|
9782
9499
|
var TRAILING_MARKDOWN_BLOCK_BREAKS_RE = /(?:\r?\n){2,}$/;
|
|
9500
|
+
function colorsEqual(left, right) {
|
|
9501
|
+
if (!left || !right)
|
|
9502
|
+
return left === right;
|
|
9503
|
+
return left.equals(right);
|
|
9504
|
+
}
|
|
9783
9505
|
|
|
9784
9506
|
class MarkdownRenderable extends Renderable {
|
|
9785
9507
|
_content = "";
|
|
9786
9508
|
_syntaxStyle;
|
|
9509
|
+
_fg;
|
|
9510
|
+
_bg;
|
|
9787
9511
|
_conceal;
|
|
9788
9512
|
_concealCode;
|
|
9789
9513
|
_treeSitterClient;
|
|
@@ -9810,6 +9534,8 @@ class MarkdownRenderable extends Renderable {
|
|
|
9810
9534
|
flexShrink: options.flexShrink ?? 0
|
|
9811
9535
|
});
|
|
9812
9536
|
this._syntaxStyle = options.syntaxStyle;
|
|
9537
|
+
this._fg = options.fg ? parseColor(options.fg) : undefined;
|
|
9538
|
+
this._bg = options.bg ? parseColor(options.bg) : undefined;
|
|
9813
9539
|
this._conceal = options.conceal ?? this._contentDefaultOptions.conceal;
|
|
9814
9540
|
this._concealCode = options.concealCode ?? this._contentDefaultOptions.concealCode;
|
|
9815
9541
|
this._content = options.content ?? this._contentDefaultOptions.content;
|
|
@@ -9840,6 +9566,26 @@ class MarkdownRenderable extends Renderable {
|
|
|
9840
9566
|
this._styleDirty = true;
|
|
9841
9567
|
}
|
|
9842
9568
|
}
|
|
9569
|
+
get fg() {
|
|
9570
|
+
return this._fg;
|
|
9571
|
+
}
|
|
9572
|
+
set fg(value) {
|
|
9573
|
+
const next = value ? parseColor(value) : undefined;
|
|
9574
|
+
if (!colorsEqual(this._fg, next)) {
|
|
9575
|
+
this._fg = next;
|
|
9576
|
+
this._styleDirty = true;
|
|
9577
|
+
}
|
|
9578
|
+
}
|
|
9579
|
+
get bg() {
|
|
9580
|
+
return this._bg;
|
|
9581
|
+
}
|
|
9582
|
+
set bg(value) {
|
|
9583
|
+
const next = value ? parseColor(value) : undefined;
|
|
9584
|
+
if (!colorsEqual(this._bg, next)) {
|
|
9585
|
+
this._bg = next;
|
|
9586
|
+
this._styleDirty = true;
|
|
9587
|
+
}
|
|
9588
|
+
}
|
|
9843
9589
|
get conceal() {
|
|
9844
9590
|
return this._conceal;
|
|
9845
9591
|
}
|
|
@@ -10034,6 +9780,8 @@ class MarkdownRenderable extends Renderable {
|
|
|
10034
9780
|
content,
|
|
10035
9781
|
filetype: "markdown",
|
|
10036
9782
|
syntaxStyle: this._syntaxStyle,
|
|
9783
|
+
fg: this._fg,
|
|
9784
|
+
bg: this._bg,
|
|
10037
9785
|
conceal: this._conceal,
|
|
10038
9786
|
drawUnstyledText: false,
|
|
10039
9787
|
streaming: true,
|
|
@@ -10047,8 +9795,10 @@ class MarkdownRenderable extends Renderable {
|
|
|
10047
9795
|
return new CodeRenderable(this.ctx, {
|
|
10048
9796
|
id,
|
|
10049
9797
|
content: token.text,
|
|
10050
|
-
filetype: token.lang
|
|
9798
|
+
filetype: infoStringToFiletype(token.lang ?? ""),
|
|
10051
9799
|
syntaxStyle: this._syntaxStyle,
|
|
9800
|
+
fg: this._fg,
|
|
9801
|
+
bg: this._bg,
|
|
10052
9802
|
conceal: this._concealCode,
|
|
10053
9803
|
drawUnstyledText: !(this._streaming && this._concealCode),
|
|
10054
9804
|
streaming: this._streaming,
|
|
@@ -10061,6 +9811,8 @@ class MarkdownRenderable extends Renderable {
|
|
|
10061
9811
|
renderable.content = content;
|
|
10062
9812
|
renderable.filetype = "markdown";
|
|
10063
9813
|
renderable.syntaxStyle = this._syntaxStyle;
|
|
9814
|
+
renderable.fg = this._fg;
|
|
9815
|
+
renderable.bg = this._bg;
|
|
10064
9816
|
renderable.conceal = this._conceal;
|
|
10065
9817
|
renderable.drawUnstyledText = false;
|
|
10066
9818
|
renderable.streaming = true;
|
|
@@ -10068,8 +9820,10 @@ class MarkdownRenderable extends Renderable {
|
|
|
10068
9820
|
}
|
|
10069
9821
|
applyCodeBlockRenderable(renderable, token, marginBottom) {
|
|
10070
9822
|
renderable.content = token.text;
|
|
10071
|
-
renderable.filetype = token.lang
|
|
9823
|
+
renderable.filetype = infoStringToFiletype(token.lang ?? "");
|
|
10072
9824
|
renderable.syntaxStyle = this._syntaxStyle;
|
|
9825
|
+
renderable.fg = this._fg;
|
|
9826
|
+
renderable.bg = this._bg;
|
|
10073
9827
|
renderable.conceal = this._concealCode;
|
|
10074
9828
|
renderable.drawUnstyledText = !(this._streaming && this._concealCode);
|
|
10075
9829
|
renderable.streaming = this._streaming;
|
|
@@ -12613,7 +12367,7 @@ class TimeToFirstDrawRenderable extends Renderable {
|
|
|
12613
12367
|
return Math.max(0, Math.floor(value));
|
|
12614
12368
|
}
|
|
12615
12369
|
}
|
|
12616
|
-
export { TextBufferView, EditBuffer, EditorView, convertThemeToStyles, SyntaxStyle, applyScanlines,
|
|
12370
|
+
export { TextBufferView, EditBuffer, EditorView, convertThemeToStyles, SyntaxStyle, applyScanlines, applyInvert, applyNoise, applyChromaticAberration, applyAsciiArt, applyBrightness, applyGain, applySaturation, BloomEffect, Timeline, engine, createTimeline, SlotRegistry, createSlotRegistry, createCoreSlotRegistry, registerCorePlugin, resolveCoreSlot, SlotRenderable, NativeSpanFeed, FrameBufferRenderable, ASCIIFontRenderable, BoxRenderable, TextBufferRenderable, CodeRenderable, isTextNodeRenderable, TextNodeRenderable, RootTextNodeRenderable, Generic, Box, Text, ASCIIFont, Input, Select, TabSelect, FrameBuffer, Code, ScrollBox, vstyles, VRenderable, LineNumberRenderable, TextRenderable, DiffRenderable, TextareaRenderable, InputRenderableEvents, InputRenderable, TextTableRenderable, MarkdownRenderable, SliderRenderable, ScrollBarRenderable, ArrowRenderable, ScrollBoxRenderable, SelectRenderableEvents, SelectRenderable, TabSelectRenderableEvents, TabSelectRenderable, TimeToFirstDrawRenderable, exports_src2 as exports_src };
|
|
12617
12371
|
|
|
12618
|
-
//# debugId=
|
|
12619
|
-
//# sourceMappingURL=index-
|
|
12372
|
+
//# debugId=DC05962D46EF296364756E2164756E21
|
|
12373
|
+
//# sourceMappingURL=index-rs5zwr4j.js.map
|