@seflless/ghosttown 1.6.2 → 2.0.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.
@@ -101,8 +101,8 @@ class Z {
101
101
  );
102
102
  if (w !== 0)
103
103
  throw this.exports.ghostty_wasm_free_u8_array(D, I), this.exports.ghostty_wasm_free_usize(i), this.exports.ghostty_key_event_free(C), new Error(`Failed to encode key: ${w}`);
104
- const t = E.getUint32(i, !0), h = new Uint8Array(this.exports.memory.buffer, D, t).slice();
105
- return this.exports.ghostty_wasm_free_u8_array(D, I), this.exports.ghostty_wasm_free_usize(i), this.exports.ghostty_key_event_free(C), h;
104
+ const t = E.getUint32(i, !0), M = new Uint8Array(this.exports.memory.buffer, D, t).slice();
105
+ return this.exports.ghostty_wasm_free_u8_array(D, I), this.exports.ghostty_wasm_free_usize(i), this.exports.ghostty_key_event_free(C), M;
106
106
  }
107
107
  dispose() {
108
108
  this.encoder && (this.exports.ghostty_key_encoder_free(this.encoder), this.encoder = 0);
@@ -118,9 +118,10 @@ const V = class K {
118
118
  try {
119
119
  const i = new DataView(this.memory.buffer);
120
120
  let w = D;
121
- i.setUint32(w, C.scrollbackLimit ?? 1e4, !0), w += 4, i.setUint32(w, C.fgColor ?? 0, !0), w += 4, i.setUint32(w, C.bgColor ?? 0, !0), w += 4, i.setUint32(w, C.cursorColor ?? 0, !0), w += 4;
122
- for (let t = 0; t < 16; t++)
123
- i.setUint32(w, ((I = C.palette) == null ? void 0 : I[t]) ?? 0, !0), w += 4;
121
+ const M = (C.scrollbackLimit ?? 1e4) * 1e3;
122
+ i.setUint32(w, M, !0), w += 4, i.setUint32(w, C.fgColor ?? 0, !0), w += 4, i.setUint32(w, C.bgColor ?? 0, !0), w += 4, i.setUint32(w, C.cursorColor ?? 0, !0), w += 4;
123
+ for (let s = 0; s < 16; s++)
124
+ i.setUint32(w, ((I = C.palette) == null ? void 0 : I[s]) ?? 0, !0), w += 4;
124
125
  this.handle = this.exports.ghostty_terminal_new_with_config(g, E, D);
125
126
  } finally {
126
127
  this.exports.ghostty_wasm_free_u8_array(D, m);
@@ -1217,8 +1218,8 @@ class $ {
1217
1218
  if (g) {
1218
1219
  const D = g.getCell(B.x);
1219
1220
  if (!D) {
1220
- const { start: w, end: t } = A.range, h = `r${w.y}:${w.x}-${t.x}`;
1221
- this.linkCache.set(h, A);
1221
+ const { start: w, end: t } = A.range, M = `r${w.y}:${w.x}-${t.x}`;
1222
+ this.linkCache.set(M, A);
1222
1223
  return;
1223
1224
  }
1224
1225
  const i = D.getHyperlinkId();
@@ -1299,8 +1300,8 @@ class AA {
1299
1300
  t && g.push({
1300
1301
  text: t,
1301
1302
  range: w,
1302
- activate: (h) => {
1303
- (h.ctrlKey || h.metaKey) && window.open(t, "_blank", "noopener,noreferrer");
1303
+ activate: (M) => {
1304
+ (M.ctrlKey || M.metaKey) && window.open(t, "_blank", "noopener,noreferrer");
1304
1305
  }
1305
1306
  });
1306
1307
  }
@@ -1317,23 +1318,23 @@ class AA {
1317
1318
  const t = E.getLine(C);
1318
1319
  if (!t)
1319
1320
  break;
1320
- const h = t.getCell(I - 1);
1321
- if (!h || h.getHyperlinkId() !== A)
1321
+ const M = t.getCell(I - 1);
1322
+ if (!M || M.getHyperlinkId() !== A)
1322
1323
  break;
1323
1324
  I--;
1324
1325
  }
1325
1326
  if (I === 0 && C > 0) {
1326
1327
  let t = C - 1;
1327
1328
  for (; t >= 0; ) {
1328
- const h = E.getLine(t);
1329
- if (!h || h.length === 0)
1329
+ const M = E.getLine(t);
1330
+ if (!M || M.length === 0)
1330
1331
  break;
1331
- const s = h.getCell(h.length - 1);
1332
+ const s = M.getCell(M.length - 1);
1332
1333
  if (!s || s.getHyperlinkId() !== A)
1333
1334
  break;
1334
1335
  C = t, I = 0;
1335
- for (let a = h.length - 1; a >= 0; a--) {
1336
- const k = h.getCell(a);
1336
+ for (let a = M.length - 1; a >= 0; a--) {
1337
+ const k = M.getCell(a);
1337
1338
  if (!k || k.getHyperlinkId() !== A) {
1338
1339
  I = a + 1;
1339
1340
  break;
@@ -1356,8 +1357,8 @@ class AA {
1356
1357
  }
1357
1358
  if (i === w.length - 1) {
1358
1359
  let t = D + 1;
1359
- const h = E.length;
1360
- for (; t < h; ) {
1360
+ const M = E.length;
1361
+ for (; t < M; ) {
1361
1362
  const s = E.getLine(t);
1362
1363
  if (!s || s.length === 0)
1363
1364
  break;
@@ -1417,8 +1418,8 @@ const p = class Y {
1417
1418
  start: { x: i, y: A },
1418
1419
  end: { x: w, y: A }
1419
1420
  },
1420
- activate: (h) => {
1421
- (h.ctrlKey || h.metaKey) && window.open(D, "_blank", "noopener,noreferrer");
1421
+ activate: (M) => {
1422
+ (M.ctrlKey || M.metaKey) && window.open(D, "_blank", "noopener,noreferrer");
1422
1423
  }
1423
1424
  }), I = Y.URL_REGEX.exec(C);
1424
1425
  }
@@ -1833,46 +1834,46 @@ class IA {
1833
1834
  const t = I.x !== this.lastCursorPosition.x || I.y !== this.lastCursorPosition.y;
1834
1835
  if (t || this.cursorBlink) {
1835
1836
  if (!B && !A.isRowDirty(I.y)) {
1836
- const M = A.getLine(I.y);
1837
- M && this.renderLine(M, I.y, D.cols);
1837
+ const h = A.getLine(I.y);
1838
+ h && this.renderLine(h, I.y, D.cols);
1838
1839
  }
1839
1840
  if (t && this.lastCursorPosition.y !== I.y && !B && !A.isRowDirty(this.lastCursorPosition.y)) {
1840
- const M = A.getLine(this.lastCursorPosition.y);
1841
- M && this.renderLine(M, this.lastCursorPosition.y, D.cols);
1841
+ const h = A.getLine(this.lastCursorPosition.y);
1842
+ h && this.renderLine(h, this.lastCursorPosition.y, D.cols);
1842
1843
  }
1843
1844
  }
1844
- const h = this.selectionManager && this.selectionManager.hasSelection(), s = /* @__PURE__ */ new Set();
1845
- if (this.currentSelectionCoords = h ? this.selectionManager.getSelectionCoords() : null, this.currentSelectionCoords) {
1846
- const M = this.currentSelectionCoords;
1847
- for (let e = M.startRow; e <= M.endRow; e++)
1845
+ const M = this.selectionManager && this.selectionManager.hasSelection(), s = /* @__PURE__ */ new Set();
1846
+ if (this.currentSelectionCoords = M ? this.selectionManager.getSelectionCoords() : null, this.currentSelectionCoords) {
1847
+ const h = this.currentSelectionCoords;
1848
+ for (let e = h.startRow; e <= h.endRow; e++)
1848
1849
  s.add(e);
1849
1850
  }
1850
1851
  if (this.selectionManager) {
1851
- const M = this.selectionManager.getDirtySelectionRows();
1852
- if (M.size > 0) {
1853
- for (const e of M)
1852
+ const h = this.selectionManager.getDirtySelectionRows();
1853
+ if (h.size > 0) {
1854
+ for (const e of h)
1854
1855
  s.add(e);
1855
1856
  this.selectionManager.clearDirtySelectionRows();
1856
1857
  }
1857
1858
  }
1858
1859
  const a = /* @__PURE__ */ new Set(), k = this.hoveredHyperlinkId !== this.previousHoveredHyperlinkId, N = JSON.stringify(this.hoveredLinkRange) !== JSON.stringify(this.previousHoveredLinkRange);
1859
1860
  if (k) {
1860
- for (let M = 0; M < D.rows; M++) {
1861
+ for (let h = 0; h < D.rows; h++) {
1861
1862
  let e = null;
1862
1863
  if (g > 0)
1863
- if (M < g && E) {
1864
- const F = i - Math.floor(g) + M;
1864
+ if (h < g && E) {
1865
+ const F = i - Math.floor(g) + h;
1865
1866
  e = E.getScrollbackLine(F);
1866
1867
  } else {
1867
- const F = M - Math.floor(g);
1868
+ const F = h - Math.floor(g);
1868
1869
  e = A.getLine(F);
1869
1870
  }
1870
1871
  else
1871
- e = A.getLine(M);
1872
+ e = A.getLine(h);
1872
1873
  if (e) {
1873
1874
  for (const F of e)
1874
1875
  if (F.hyperlink_id === this.hoveredHyperlinkId || F.hyperlink_id === this.previousHoveredHyperlinkId) {
1875
- a.add(M);
1876
+ a.add(h);
1876
1877
  break;
1877
1878
  }
1878
1879
  }
@@ -1881,31 +1882,31 @@ class IA {
1881
1882
  }
1882
1883
  if (N) {
1883
1884
  if (this.previousHoveredLinkRange)
1884
- for (let M = this.previousHoveredLinkRange.startY; M <= this.previousHoveredLinkRange.endY; M++)
1885
- a.add(M);
1885
+ for (let h = this.previousHoveredLinkRange.startY; h <= this.previousHoveredLinkRange.endY; h++)
1886
+ a.add(h);
1886
1887
  if (this.hoveredLinkRange)
1887
- for (let M = this.hoveredLinkRange.startY; M <= this.hoveredLinkRange.endY; M++)
1888
- a.add(M);
1888
+ for (let h = this.hoveredLinkRange.startY; h <= this.hoveredLinkRange.endY; h++)
1889
+ a.add(h);
1889
1890
  this.previousHoveredLinkRange = this.hoveredLinkRange;
1890
1891
  }
1891
1892
  const c = /* @__PURE__ */ new Set();
1892
- for (let M = 0; M < D.rows; M++)
1893
- (g > 0 ? !0 : B || A.isRowDirty(M) || s.has(M) || a.has(M)) && (c.add(M), M > 0 && c.add(M - 1), M < D.rows - 1 && c.add(M + 1));
1894
- for (let M = 0; M < D.rows; M++) {
1895
- if (!c.has(M))
1893
+ for (let h = 0; h < D.rows; h++)
1894
+ (g > 0 ? !0 : B || A.isRowDirty(h) || s.has(h) || a.has(h)) && (c.add(h), h > 0 && c.add(h - 1), h < D.rows - 1 && c.add(h + 1));
1895
+ for (let h = 0; h < D.rows; h++) {
1896
+ if (!c.has(h))
1896
1897
  continue;
1897
1898
  let e = null;
1898
1899
  if (g > 0)
1899
- if (M < g && E) {
1900
- const F = i - Math.floor(g) + M;
1900
+ if (h < g && E) {
1901
+ const F = i - Math.floor(g) + h;
1901
1902
  e = E.getScrollbackLine(F);
1902
1903
  } else {
1903
- const F = g > 0 ? M - Math.floor(g) : M;
1904
+ const F = g > 0 ? h - Math.floor(g) : h;
1904
1905
  e = A.getLine(F);
1905
1906
  }
1906
1907
  else
1907
- e = A.getLine(M);
1908
- e && this.renderLine(e, M, D.cols);
1908
+ e = A.getLine(h);
1909
+ e && this.renderLine(e, h, D.cols);
1909
1910
  }
1910
1911
  g === 0 && I.visible && this.cursorVisible && this.renderCursor(I.x, I.y), E && C > 0 && this.renderScrollbar(g, i, D.rows, C), this.lastCursorPosition = { x: I.x, y: I.y }, A.clearDirty();
1911
1912
  }
@@ -1951,7 +1952,7 @@ class IA {
1951
1952
  * Selection foreground color is applied here to match the selection background.
1952
1953
  */
1953
1954
  renderCellText(A, B, g) {
1954
- var h;
1955
+ var M;
1955
1956
  const E = B * this.metrics.width, C = g * this.metrics.height, I = this.metrics.width * A.width;
1956
1957
  if (A.flags & G.INVISIBLE)
1957
1958
  return;
@@ -1983,7 +1984,7 @@ class IA {
1983
1984
  else {
1984
1985
  const a = E, k = C + this.metrics.baseline;
1985
1986
  let N;
1986
- A.grapheme_len > 0 && ((h = this.currentBuffer) != null && h.getGraphemeString) ? N = this.currentBuffer.getGraphemeString(g, B) : N = String.fromCodePoint(w), this.ctx.fillText(N, a, k);
1987
+ A.grapheme_len > 0 && ((M = this.currentBuffer) != null && M.getGraphemeString) ? N = this.currentBuffer.getGraphemeString(g, B) : N = String.fromCodePoint(w), this.ctx.fillText(N, a, k);
1987
1988
  }
1988
1989
  }
1989
1990
  if (A.flags & G.FAINT && (this.ctx.globalAlpha = 1), A.flags & G.UNDERLINE) {
@@ -2108,11 +2109,11 @@ class IA {
2108
2109
  * @param opacity Opacity level (0-1) for fade in/out effect
2109
2110
  */
2110
2111
  renderScrollbar(A, B, g, E = 1) {
2111
- const C = this.ctx, I = this.canvas.height / this.devicePixelRatio, D = this.canvas.width / this.devicePixelRatio, i = 8, w = D - i - 4, t = 4, h = I - t * 2;
2112
+ const C = this.ctx, I = this.canvas.height / this.devicePixelRatio, D = this.canvas.width / this.devicePixelRatio, i = 8, w = D - i - 4, t = 4, M = I - t * 2;
2112
2113
  if (C.fillStyle = this.theme.background, C.fillRect(w - 2, 0, i + 6, I), E <= 0 || B === 0)
2113
2114
  return;
2114
- const s = B + g, a = Math.max(20, g / s * h), k = A / B, N = t + (h - a) * (1 - k);
2115
- C.fillStyle = `rgba(128, 128, 128, ${0.1 * E})`, C.fillRect(w, t, i, h);
2115
+ const s = B + g, a = Math.max(20, g / s * M), k = A / B, N = t + (M - a) * (1 - k);
2116
+ C.fillStyle = `rgba(128, 128, 128, ${0.1 * E})`, C.fillRect(w, t, i, M);
2116
2117
  const U = A > 0 ? 0.5 : 0.3;
2117
2118
  C.fillStyle = `rgba(128, 128, 128, ${U * E})`, C.fillRect(w, N, i, a);
2118
2119
  }
@@ -2232,9 +2233,9 @@ const l = class n {
2232
2233
  if (!i)
2233
2234
  continue;
2234
2235
  let w = -1;
2235
- const t = D === B ? A : 0, h = D === E ? g : i.length - 1;
2236
+ const t = D === B ? A : 0, M = D === E ? g : i.length - 1;
2236
2237
  let s = "";
2237
- for (let a = t; a <= h; a++) {
2238
+ for (let a = t; a <= M; a++) {
2238
2239
  const k = i[a];
2239
2240
  if (k && k.codepoint !== 0) {
2240
2241
  let N;
@@ -2642,12 +2643,12 @@ class MA {
2642
2643
  return;
2643
2644
  const E = this.canvas.getBoundingClientRect(), C = Math.floor((g.clientX - E.left) / this.renderer.charWidth), D = Math.floor((g.clientY - E.top) / this.renderer.charHeight), i = this.wasmTerm.getScrollbackLength();
2644
2645
  let w;
2645
- const t = this.getViewportY(), h = Math.max(0, Math.floor(t));
2646
- if (h > 0)
2647
- if (D < h)
2648
- w = i - h + D;
2646
+ const t = this.getViewportY(), M = Math.max(0, Math.floor(t));
2647
+ if (M > 0)
2648
+ if (D < M)
2649
+ w = i - M + D;
2649
2650
  else {
2650
- const a = D - h;
2651
+ const a = D - M;
2651
2652
  w = i + a;
2652
2653
  }
2653
2654
  else
@@ -2680,11 +2681,11 @@ class MA {
2680
2681
  const E = this.wasmTerm.getScrollbackLength();
2681
2682
  if (E === 0)
2682
2683
  return;
2683
- const C = this.canvas.getBoundingClientRect(), I = g.clientX - C.left, D = g.clientY - C.top, i = C.width, w = C.height, t = 8, h = i - t - 4, s = 4;
2684
- if (I >= h && I <= h + t) {
2684
+ const C = this.canvas.getBoundingClientRect(), I = g.clientX - C.left, D = g.clientY - C.top, i = C.width, w = C.height, t = 8, M = i - t - 4, s = 4;
2685
+ if (I >= M && I <= M + t) {
2685
2686
  g.preventDefault(), g.stopPropagation(), g.stopImmediatePropagation();
2686
- const a = w - s * 2, k = this.rows, N = E + k, c = Math.max(20, k / N * a), U = this.viewportY / E, M = s + (a - c) * (1 - U);
2687
- if (D >= M && D <= M + c)
2687
+ const a = w - s * 2, k = this.rows, N = E + k, c = Math.max(20, k / N * a), U = this.viewportY / E, h = s + (a - c) * (1 - U);
2688
+ if (D >= h && D <= h + c)
2688
2689
  this.isDraggingScrollbar = !0, this.scrollbarDragStart = D, this.scrollbarDragStartViewportY = this.viewportY, this.canvas && (this.canvas.style.userSelect = "none", this.canvas.style.webkitUserSelect = "none");
2689
2690
  else {
2690
2691
  const F = 1 - (D - s) / a, S = Math.round(F * E);
@@ -2857,8 +2858,8 @@ class MA {
2857
2858
  const w = i.touches[0];
2858
2859
  if (!w)
2859
2860
  return;
2860
- const t = w.clientX - C, h = w.clientY - I;
2861
- if (!D && Math.hypot(t, h) >= 8 && (D = !0), Math.abs(h) >= Math.abs(t) - 2 && (this.touchScrollActive = !0), this.touchScrollActive) {
2861
+ const t = w.clientX - C, M = w.clientY - I;
2862
+ if (!D && Math.hypot(t, M) >= 8 && (D = !0), Math.abs(M) >= Math.abs(t) - 2 && (this.touchScrollActive = !0), this.touchScrollActive) {
2862
2863
  i.preventDefault();
2863
2864
  const s = w.clientY - this.touchScrollLastY;
2864
2865
  this.touchScrollLastY = w.clientY, this.handleTouchScrollPixels(s);
@@ -3254,21 +3255,21 @@ class MA {
3254
3255
  D && g >= 0 && g < D.length && (I = D[g].hyperlink_id);
3255
3256
  const t = this.renderer.hoveredHyperlinkId || 0;
3256
3257
  I !== t && this.renderer.setHoveredHyperlinkId(I);
3257
- const h = this.wasmTerm.getScrollbackLength();
3258
+ const M = this.wasmTerm.getScrollbackLength();
3258
3259
  let s;
3259
3260
  const a = this.getViewportY(), k = Math.max(0, Math.floor(a));
3260
3261
  if (k > 0)
3261
3262
  if (C < k)
3262
- s = h - k + C;
3263
+ s = M - k + C;
3263
3264
  else {
3264
3265
  const N = C - k;
3265
- s = h + N;
3266
+ s = M + N;
3266
3267
  }
3267
3268
  else
3268
- s = h + C;
3269
+ s = M + C;
3269
3270
  this.linkDetector.getLinkAt(g, s).then((N) => {
3270
- var c, U, M, e;
3271
- if (N !== this.currentHoveredLink && ((U = (c = this.currentHoveredLink) == null ? void 0 : c.hover) == null || U.call(c, !1), this.currentHoveredLink = N, (M = N == null ? void 0 : N.hover) == null || M.call(N, !0), this.element && (this.element.style.cursor = N ? "pointer" : "text"), this.renderer))
3271
+ var c, U, h, e;
3272
+ if (N !== this.currentHoveredLink && ((U = (c = this.currentHoveredLink) == null ? void 0 : c.hover) == null || U.call(c, !1), this.currentHoveredLink = N, (h = N == null ? void 0 : N.hover) == null || h.call(N, !0), this.element && (this.element.style.cursor = N ? "pointer" : "text"), this.renderer))
3272
3273
  if (N) {
3273
3274
  const F = ((e = this.wasmTerm) == null ? void 0 : e.getScrollbackLength()) || 0, S = this.getViewportY(), T = Math.max(0, Math.floor(S)), d = N.range.start.y - F + T, f = N.range.end.y - F + T;
3274
3275
  d < this.rows && f >= 0 ? this.renderer.setHoveredLinkRange({
@@ -3292,7 +3293,7 @@ class MA {
3292
3293
  const B = this.wasmTerm.getScrollbackLength();
3293
3294
  if (B === 0)
3294
3295
  return;
3295
- const g = this.canvas.getBoundingClientRect(), C = A.clientY - g.top - this.scrollbarDragStart, i = g.height - 4 * 2, w = this.rows, t = B + w, h = Math.max(20, w / t * i), s = -C / (i - h), a = Math.round(s * B), k = this.scrollbarDragStartViewportY + a;
3296
+ const g = this.canvas.getBoundingClientRect(), C = A.clientY - g.top - this.scrollbarDragStart, i = g.height - 4 * 2, w = this.rows, t = B + w, M = Math.max(20, w / t * i), s = -C / (i - M), a = Math.round(s * B), k = this.scrollbarDragStartViewportY + a;
3296
3297
  this.scrollToLine(Math.max(0, Math.min(B, k)));
3297
3298
  }
3298
3299
  /**
@@ -3471,10 +3472,10 @@ class hA {
3471
3472
  const E = this._terminal.element;
3472
3473
  if (typeof E.clientWidth > "u")
3473
3474
  return;
3474
- const C = window.getComputedStyle(E), I = Number.parseInt(C.getPropertyValue("padding-top")) || 0, D = Number.parseInt(C.getPropertyValue("padding-bottom")) || 0, i = Number.parseInt(C.getPropertyValue("padding-left")) || 0, w = Number.parseInt(C.getPropertyValue("padding-right")) || 0, t = E.clientWidth, h = E.clientHeight;
3475
- if (t === 0 || h === 0)
3475
+ const C = window.getComputedStyle(E), I = Number.parseInt(C.getPropertyValue("padding-top")) || 0, D = Number.parseInt(C.getPropertyValue("padding-bottom")) || 0, i = Number.parseInt(C.getPropertyValue("padding-left")) || 0, w = Number.parseInt(C.getPropertyValue("padding-right")) || 0, t = E.clientWidth, M = E.clientHeight;
3476
+ if (t === 0 || M === 0)
3476
3477
  return;
3477
- const s = t - i - w - wA, a = h - I - D, k = Math.max(oA, Math.floor(s / g.width)), N = Math.max(iA, Math.floor(a / g.height));
3478
+ const s = t - i - w - wA, a = M - I - D, k = Math.max(oA, Math.floor(s / g.width)), N = Math.max(iA, Math.floor(a / g.height));
3478
3479
  return { cols: k, rows: N };
3479
3480
  }
3480
3481
  /**