@simon_he/vue-tui 1.0.0 → 1.0.2

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.
@@ -31,11 +31,11 @@ export declare function createGridBuffer(cols: number, rows: number, options?: R
31
31
  }>): GridBuffer;
32
32
  export declare function clamp(n: number, min: number, max: number): number;
33
33
  /**
34
- * Register a fingerprint function on the buffer. This enables SoA fingerprint
34
+ * Register or clear a fingerprint function on the buffer. This enables SoA fingerprint
35
35
  * pre-computation: cell writes will update fingerprints inline, and the renderer
36
36
  * can read them via getRowFingerprints() instead of per-cell hash computation.
37
37
  */
38
- export declare function setFingerprintFn(buffer: GridBuffer, fn: CellFingerprintFn): void;
38
+ export declare function setFingerprintFn(buffer: GridBuffer, fn: CellFingerprintFn | null): void;
39
39
  /**
40
40
  * Get pre-computed fingerprints for a logical row as a TypedArray slice.
41
41
  * Returns null if fingerprinting is not enabled on this buffer.
@@ -100,8 +100,4 @@ export interface Terminal {
100
100
  getRow: (y: number) => readonly Cell[];
101
101
  setScrollbackLimit: (limit: number) => void;
102
102
  getScrollbackLines: (count?: number) => readonly string[];
103
- /** Register fingerprint function for SoA pre-computation on the composite buffer. */
104
- setFingerprintFn: (fn: (ch: string, style: Style) => number) => void;
105
- /** Get pre-computed fingerprints for a composite buffer row (null if not enabled). */
106
- getRowFingerprints: (y: number) => Uint32Array | null;
107
103
  }
package/dist/core.cjs CHANGED
@@ -1246,7 +1246,7 @@ function clamp(n, min, max) {
1246
1246
  function setFingerprintFn(buffer, fn) {
1247
1247
  buffer.fingerprintFn = fn;
1248
1248
  const len = buffer.rows * buffer.cols;
1249
- if (!len) {
1249
+ if (!fn || !len) {
1250
1250
  buffer.soaFingerprints = null;
1251
1251
  return;
1252
1252
  }
@@ -1264,7 +1264,12 @@ function setFingerprintFn(buffer, fn) {
1264
1264
  function getRowFingerprints(buffer, y) {
1265
1265
  if (!buffer.soaFingerprints)
1266
1266
  return null;
1267
- const physY = physicalRowIndex(buffer, y);
1267
+ if (buffer.rows <= 0 || buffer.cols <= 0)
1268
+ return null;
1269
+ const yy = Math.floor(y);
1270
+ if (!Number.isFinite(yy) || yy < 0 || yy >= buffer.rows)
1271
+ return null;
1272
+ const physY = physicalRowIndex(buffer, yy);
1268
1273
  const base = physY * buffer.cols;
1269
1274
  return buffer.soaFingerprints.subarray(base, base + buffer.cols);
1270
1275
  }
@@ -2535,11 +2540,17 @@ function createTerminal(opts) {
2535
2540
  },
2536
2541
  setFingerprintFn(fn) {
2537
2542
  assertNotDisposed();
2538
- base.setFingerprintFn(fn);
2543
+ const state = getPlaneState(plane);
2544
+ setFingerprintFn(state.buffer, fn);
2539
2545
  },
2540
2546
  getRowFingerprints(y) {
2541
2547
  assertNotDisposed();
2542
- return base.getRowFingerprints(y);
2548
+ const yy = Math.floor(y);
2549
+ const state = getPlaneState(plane);
2550
+ if (!Number.isFinite(yy) || yy < 0 || yy >= state.buffer.rows) {
2551
+ throw new RangeError("Row out of bounds");
2552
+ }
2553
+ return getRowFingerprints(state.buffer, yy);
2543
2554
  }
2544
2555
  };
2545
2556
  planeTerminals.set(plane, api);
@@ -2733,7 +2744,11 @@ function createTerminal(opts) {
2733
2744
  },
2734
2745
  getRowFingerprints(y) {
2735
2746
  assertNotDisposed();
2736
- return getRowFingerprints(compositeBuffer, y);
2747
+ const yy = Math.floor(y);
2748
+ if (!Number.isFinite(yy) || yy < 0 || yy >= compositeBuffer.rows) {
2749
+ throw new RangeError("Row out of bounds");
2750
+ }
2751
+ return getRowFingerprints(compositeBuffer, yy);
2737
2752
  }
2738
2753
  };
2739
2754
  base[TERMINAL_PLANE_INTERNALS] = {
package/dist/core.js CHANGED
@@ -1,4 +1,4 @@
1
- import { TERMINAL_RENDER_PLANES, createTerminal } from "./create-terminal-C2oiWFJU.js";
1
+ import { TERMINAL_RENDER_PLANES, createTerminal } from "./create-terminal-DBFNYr8f.js";
2
2
  import { charCellWidth, isSafeRelativeHref, sanitizeDomHref, sanitizeTerminalHref } from "./hyperlink-Bn02UXJb.js";
3
3
  import { parseAnsiSgr } from "./sgr-BmzxEjAO.js";
4
4
  import { ansiColorRgb } from "./ansi-palette-CNXqFciC.js";
@@ -106,14 +106,14 @@ function clamp(n, min, max) {
106
106
  return Math.max(min, Math.min(max, n));
107
107
  }
108
108
  /**
109
- * Register a fingerprint function on the buffer. This enables SoA fingerprint
109
+ * Register or clear a fingerprint function on the buffer. This enables SoA fingerprint
110
110
  * pre-computation: cell writes will update fingerprints inline, and the renderer
111
111
  * can read them via getRowFingerprints() instead of per-cell hash computation.
112
112
  */
113
113
  function setFingerprintFn(buffer, fn) {
114
114
  buffer.fingerprintFn = fn;
115
115
  const len = buffer.rows * buffer.cols;
116
- if (!len) {
116
+ if (!fn || !len) {
117
117
  buffer.soaFingerprints = null;
118
118
  return;
119
119
  }
@@ -134,7 +134,10 @@ function setFingerprintFn(buffer, fn) {
134
134
  */
135
135
  function getRowFingerprints(buffer, y) {
136
136
  if (!buffer.soaFingerprints) return null;
137
- const physY = physicalRowIndex(buffer, y);
137
+ if (buffer.rows <= 0 || buffer.cols <= 0) return null;
138
+ const yy = Math.floor(y);
139
+ if (!Number.isFinite(yy) || yy < 0 || yy >= buffer.rows) return null;
140
+ const physY = physicalRowIndex(buffer, yy);
138
141
  const base = physY * buffer.cols;
139
142
  return buffer.soaFingerprints.subarray(base, base + buffer.cols);
140
143
  }
@@ -1219,11 +1222,15 @@ function createTerminal(opts) {
1219
1222
  },
1220
1223
  setFingerprintFn(fn) {
1221
1224
  assertNotDisposed();
1222
- base.setFingerprintFn(fn);
1225
+ const state = getPlaneState(plane);
1226
+ setFingerprintFn(state.buffer, fn);
1223
1227
  },
1224
1228
  getRowFingerprints(y) {
1225
1229
  assertNotDisposed();
1226
- return base.getRowFingerprints(y);
1230
+ const yy = Math.floor(y);
1231
+ const state = getPlaneState(plane);
1232
+ if (!Number.isFinite(yy) || yy < 0 || yy >= state.buffer.rows) throw new RangeError("Row out of bounds");
1233
+ return getRowFingerprints(state.buffer, yy);
1227
1234
  }
1228
1235
  };
1229
1236
  planeTerminals.set(plane, api);
@@ -1397,7 +1404,9 @@ function createTerminal(opts) {
1397
1404
  },
1398
1405
  getRowFingerprints(y) {
1399
1406
  assertNotDisposed();
1400
- return getRowFingerprints(compositeBuffer, y);
1407
+ const yy = Math.floor(y);
1408
+ if (!Number.isFinite(yy) || yy < 0 || yy >= compositeBuffer.rows) throw new RangeError("Row out of bounds");
1409
+ return getRowFingerprints(compositeBuffer, yy);
1401
1410
  }
1402
1411
  };
1403
1412
  base[TERMINAL_PLANE_INTERNALS] = {
@@ -1,4 +1,4 @@
1
- import { TERMINAL_RENDER_PLANES, getPlaneTerminal } from "./create-terminal-C2oiWFJU.js";
1
+ import { TERMINAL_RENDER_PLANES, getPlaneTerminal } from "./create-terminal-DBFNYr8f.js";
2
2
  import { sanitizeDomHref } from "./hyperlink-Bn02UXJb.js";
3
3
  import { ansiColorHex, ansiCssVar, installAnsiPaletteCssVars, isAnsiColorName } from "./ansi-palette-CNXqFciC.js";
4
4