@opentui/core 0.5.8 → 0.5.9

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/index.node.js CHANGED
@@ -43,7 +43,7 @@ import {
43
43
  mergeKeyAliases,
44
44
  mergeKeyBindings,
45
45
  wrapWithDelegates
46
- } from "./chunk-node-kr27pp2p.js";
46
+ } from "./chunk-node-dcyj0dm5.js";
47
47
  import {
48
48
  ASCIIFontSelectionHelper,
49
49
  ATTRIBUTE_BASE_BITS,
@@ -203,7 +203,7 @@ import {
203
203
  visualizeRenderableTree,
204
204
  white,
205
205
  yellow
206
- } from "./chunk-node-mfda59vq.js";
206
+ } from "./chunk-node-zcz10bhr.js";
207
207
  // src/post/effects.ts
208
208
  function toU8(value) {
209
209
  return Math.round(Math.max(0, Math.min(1, Number.isFinite(value) ? value : 0)) * 255);
@@ -218,6 +218,9 @@ function setRgb(buffer, base, r, g, b) {
218
218
  buffer[base + 2] = toU8(b);
219
219
  buffer[base + 3] = a;
220
220
  }
221
+ function isGraphemeCell(char) {
222
+ return char >>> 30 >= 2;
223
+ }
221
224
 
222
225
  class DistortionEffect {
223
226
  glitchChancePerSecond = 0.5;
@@ -402,6 +405,7 @@ class DistortionEffect {
402
405
  class VignetteEffect {
403
406
  _strength;
404
407
  precomputedAttenuationCellMask = null;
408
+ precomputedAttenuation = null;
405
409
  cachedWidth = -1;
406
410
  cachedHeight = -1;
407
411
  static zeroMatrix = new Float32Array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]);
@@ -413,12 +417,14 @@ class VignetteEffect {
413
417
  this.cachedWidth = -1;
414
418
  this.cachedHeight = -1;
415
419
  this.precomputedAttenuationCellMask = null;
420
+ this.precomputedAttenuation = null;
416
421
  }
417
422
  get strength() {
418
423
  return this._strength;
419
424
  }
420
425
  _computeFactors(width, height) {
421
426
  this.precomputedAttenuationCellMask = new Float32Array(width * height * 3);
427
+ this.precomputedAttenuation = new Float32Array(width * height);
422
428
  const centerX = width / 2;
423
429
  const centerY = height / 2;
424
430
  const maxDistSq = centerX * centerX + centerY * centerY;
@@ -436,17 +442,42 @@ class VignetteEffect {
436
442
  this.precomputedAttenuationCellMask[i++] = x;
437
443
  this.precomputedAttenuationCellMask[i++] = y;
438
444
  this.precomputedAttenuationCellMask[i++] = attenuation;
445
+ this.precomputedAttenuation[y * width + x] = attenuation;
439
446
  }
440
447
  }
441
448
  this.cachedWidth = width;
442
449
  this.cachedHeight = height;
443
450
  }
451
+ _preserveGraphemeRuns(buffer) {
452
+ const baseAttenuation = this.precomputedAttenuation;
453
+ const cellMask = this.precomputedAttenuationCellMask;
454
+ const chars = buffer.buffers.char;
455
+ const width = buffer.width;
456
+ for (let y = 0;y < buffer.height; y++) {
457
+ let x = 0;
458
+ while (x < width) {
459
+ const cell = y * width + x;
460
+ if (!isGraphemeCell(chars[cell])) {
461
+ cellMask[cell * 3 + 2] = baseAttenuation[cell];
462
+ x++;
463
+ continue;
464
+ }
465
+ const start = x;
466
+ while (x < width && isGraphemeCell(chars[y * width + x]))
467
+ x++;
468
+ const attenuation = baseAttenuation[y * width + start + Math.floor((x - start) / 2)];
469
+ for (let runX = start;runX < x; runX++)
470
+ cellMask[(y * width + runX) * 3 + 2] = attenuation;
471
+ }
472
+ }
473
+ }
444
474
  apply(buffer) {
445
475
  const width = buffer.width;
446
476
  const height = buffer.height;
447
477
  if (width !== this.cachedWidth || height !== this.cachedHeight || !this.precomputedAttenuationCellMask) {
448
478
  this._computeFactors(width, height);
449
479
  }
480
+ this._preserveGraphemeRuns(buffer);
450
481
  buffer.colorMatrix(VignetteEffect.zeroMatrix, this.precomputedAttenuationCellMask, 1, 3);
451
482
  }
452
483
  }
@@ -8320,12 +8351,13 @@ class EmbeddedTerminalRenderable extends Renderable {
8320
8351
  if (!this.handle)
8321
8352
  return new Uint8Array;
8322
8353
  const text = textualKey(key);
8354
+ const physical = physicalKey(key);
8323
8355
  return this.lib.embeddedTerminalEncodeKey(this.handle, {
8324
8356
  action: key.eventType === "release" ? "release" : key.repeated ? "repeat" : "press",
8325
- key: physicalKey(key),
8357
+ key: physical,
8326
8358
  mods: modifiers(key),
8327
8359
  text,
8328
- unshiftedCodepoint: key.baseCode ?? physicalUnshiftedCodepoint(key.code)
8360
+ unshiftedCodepoint: key.baseCode ?? physicalUnshiftedCodepoint(physical)
8329
8361
  });
8330
8362
  }
8331
8363
  encodePaste(bytes) {
@@ -8352,6 +8384,8 @@ class EmbeddedTerminalRenderable extends Renderable {
8352
8384
  this.requestRender();
8353
8385
  return false;
8354
8386
  }
8387
+ if (!this.selection && local.behavior === "cell" && local.anchorX === local.focusX && local.anchorY === local.focusY)
8388
+ return false;
8355
8389
  const point = (x, y) => {
8356
8390
  if (y < 0)
8357
8391
  return { x: 0, y: 0 };
@@ -8542,8 +8576,12 @@ function modifiers(input) {
8542
8576
  return value;
8543
8577
  }
8544
8578
  function physicalKey(key) {
8545
- if (key.code)
8579
+ if (key.code && !key.code.startsWith("["))
8546
8580
  return key.code;
8581
+ if (/^[a-z]$/i.test(key.name))
8582
+ return `Key${key.name.toUpperCase()}`;
8583
+ if (/^[0-9]$/.test(key.name))
8584
+ return `Digit${key.name}`;
8547
8585
  return {
8548
8586
  backspace: "Backspace",
8549
8587
  enter: "Enter",
@@ -15569,5 +15607,5 @@ export {
15569
15607
  ACHROMATOPSIA_MATRIX
15570
15608
  };
15571
15609
 
15572
- //# debugId=9542D2256201683264756E2164756E21
15610
+ //# debugId=9F5430F160FB010564756E2164756E21
15573
15611
  //# sourceMappingURL=index.node.js.map