restty 0.1.33 → 0.1.34

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.
@@ -19634,11 +19634,18 @@ function normalizeSelectionCell(cell, rows, cols, wideFlags) {
19634
19634
  }
19635
19635
  return { row, col };
19636
19636
  }
19637
- function positionToCell(clientX, clientY, canvasRect, dpr, cellW, cellH, cols, rows) {
19638
- const x = (clientX - canvasRect.left) * dpr;
19639
- const y = (clientY - canvasRect.top) * dpr;
19640
- const col = clamp(Math.floor(x / (cellW || 1)), 0, (cols || 1) - 1);
19641
- const row = clamp(Math.floor(y / (cellH || 1)), 0, (rows || 1) - 1);
19637
+ function positionToCell(clientX, clientY, canvasRect, dpr, cellW, cellH, cols, rows, canvasWidth, canvasHeight) {
19638
+ const safeDpr = dpr || 1;
19639
+ const safeCols = cols || 1;
19640
+ const safeRows = rows || 1;
19641
+ const safeCellW = cellW || 1;
19642
+ const safeCellH = cellH || 1;
19643
+ const scaleX = canvasRect.width > 0 ? (canvasWidth && canvasWidth > 0 ? canvasWidth : safeDpr) / canvasRect.width : safeDpr;
19644
+ const scaleY = canvasRect.height > 0 ? (canvasHeight && canvasHeight > 0 ? canvasHeight : safeDpr) / canvasRect.height : safeDpr;
19645
+ const x = (clientX - canvasRect.left) * scaleX;
19646
+ const y = (clientY - canvasRect.top) * scaleY;
19647
+ const col = clamp(Math.floor(x / safeCellW), 0, safeCols - 1);
19648
+ const row = clamp(Math.floor(y / safeCellH), 0, safeRows - 1);
19642
19649
  return { row, col };
19643
19650
  }
19644
19651
 
@@ -59506,13 +59513,16 @@ function createRuntimeInteraction(options) {
59506
59513
  const canvas = getCanvas();
59507
59514
  const rect2 = canvas.getBoundingClientRect();
59508
59515
  const { cellW, cellH, cols, rows } = getGridState();
59509
- return positionToCell(event.clientX, event.clientY, rect2, getCurrentDpr(), cellW || 1, cellH || 1, cols || 1, rows || 1);
59516
+ return positionToCell(event.clientX, event.clientY, rect2, getCurrentDpr(), cellW || 1, cellH || 1, cols || 1, rows || 1, canvas.width, canvas.height);
59510
59517
  };
59511
59518
  const positionToPixel = (event) => {
59512
59519
  const canvas = getCanvas();
59513
59520
  const rect2 = canvas.getBoundingClientRect();
59514
- const x3 = (event.clientX - rect2.left) * getCurrentDpr();
59515
- const y = (event.clientY - rect2.top) * getCurrentDpr();
59521
+ const fallbackScale = getCurrentDpr() || 1;
59522
+ const scaleX = rect2.width > 0 ? canvas.width / rect2.width : fallbackScale;
59523
+ const scaleY = rect2.height > 0 ? canvas.height / rect2.height : fallbackScale;
59524
+ const x3 = (event.clientX - rect2.left) * scaleX;
59525
+ const y = (event.clientY - rect2.top) * scaleY;
59516
59526
  return {
59517
59527
  x: Math.max(1, Math.round(x3 + 1)),
59518
59528
  y: Math.max(1, Math.round(y + 1))
package/dist/internal.js CHANGED
@@ -100,7 +100,7 @@ import {
100
100
  updateGridState,
101
101
  updateImePosition,
102
102
  updateSelection
103
- } from "./chunk-p8wzkwjt.js";
103
+ } from "./chunk-meqn8xtd.js";
104
104
  export {
105
105
  updateSelection,
106
106
  updateImePosition,
package/dist/restty.js CHANGED
@@ -8,7 +8,7 @@ import {
8
8
  isBuiltinThemeName,
9
9
  listBuiltinThemeNames,
10
10
  parseGhosttyTheme
11
- } from "./chunk-p8wzkwjt.js";
11
+ } from "./chunk-meqn8xtd.js";
12
12
  export {
13
13
  parseGhosttyTheme,
14
14
  listBuiltinThemeNames,
@@ -23,4 +23,4 @@ export declare function selectionForRow(state: SelectionState, row: number, cols
23
23
  */
24
24
  export declare function normalizeSelectionCell(cell: CellPosition | null, rows: number, cols: number, wideFlags?: Uint8Array | null): CellPosition | null;
25
25
  /** Convert client pixel coordinates to a grid cell position. */
26
- export declare function positionToCell(clientX: number, clientY: number, canvasRect: DOMRect, dpr: number, cellW: number, cellH: number, cols: number, rows: number): CellPosition;
26
+ export declare function positionToCell(clientX: number, clientY: number, canvasRect: DOMRect, dpr: number, cellW: number, cellH: number, cols: number, rows: number, canvasWidth?: number, canvasHeight?: number): CellPosition;
package/dist/xterm.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  createRestty
3
- } from "./chunk-p8wzkwjt.js";
3
+ } from "./chunk-meqn8xtd.js";
4
4
 
5
5
  // src/xterm/app-options.ts
6
6
  function createCompatAppOptions(userAppOptions, emitData) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "restty",
3
- "version": "0.1.33",
3
+ "version": "0.1.34",
4
4
  "description": "Browser terminal rendering library powered by WASM, WebGPU/WebGL2, and TypeScript text shaping.",
5
5
  "keywords": [
6
6
  "terminal",