restty 0.1.16 → 0.1.18

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.
Files changed (53) hide show
  1. package/README.md +4 -9
  2. package/dist/app/atlas-builder.d.ts +38 -0
  3. package/dist/app/font-sources.d.ts +2 -0
  4. package/dist/app/pane-app-manager.d.ts +43 -0
  5. package/dist/app/panes-context-menu.d.ts +10 -0
  6. package/dist/app/panes-styles.d.ts +5 -0
  7. package/dist/app/panes-types.d.ts +89 -0
  8. package/dist/app/panes.d.ts +10 -0
  9. package/dist/app/restty.d.ts +20 -0
  10. package/dist/app/session.d.ts +6 -0
  11. package/dist/app/types.d.ts +123 -0
  12. package/dist/{app/index.js → chunk-53vdvhe3.js} +24014 -23787
  13. package/dist/fonts/manager.d.ts +24 -0
  14. package/dist/fonts/nerd-constraints.d.ts +4 -0
  15. package/dist/fonts/nerd-ranges.d.ts +2 -0
  16. package/dist/fonts/types.d.ts +51 -0
  17. package/dist/grid/grid.d.ts +22 -0
  18. package/dist/grid/types.d.ts +32 -0
  19. package/dist/ime/ime.d.ts +13 -0
  20. package/dist/ime/types.d.ts +8 -0
  21. package/dist/input/ansi.d.ts +3 -0
  22. package/dist/input/mouse.d.ts +10 -0
  23. package/dist/input/output.d.ts +11 -0
  24. package/dist/input/types.d.ts +7 -0
  25. package/dist/internal.js +105 -56213
  26. package/dist/pty/kitty-media.d.ts +3 -0
  27. package/dist/pty/pty.d.ts +11 -0
  28. package/dist/pty/types.d.ts +49 -0
  29. package/dist/renderer/box-drawing-map.d.ts +4 -0
  30. package/dist/renderer/shaders.d.ts +7 -0
  31. package/dist/renderer/shapes.d.ts +42 -1
  32. package/dist/renderer/types.d.ts +43 -0
  33. package/dist/renderer/webgpu.d.ts +11 -0
  34. package/dist/restty.js +20 -0
  35. package/dist/selection/selection.d.ts +24 -0
  36. package/dist/selection/types.d.ts +13 -0
  37. package/dist/theme/catalog.d.ts +5 -0
  38. package/dist/theme/ghostty.d.ts +18 -0
  39. package/dist/unicode/ghostty-symbol-ranges.d.ts +1 -0
  40. package/dist/unicode/symbols.d.ts +6 -0
  41. package/dist/wasm/embedded.d.ts +1 -0
  42. package/dist/wasm/runtime.d.ts +29 -0
  43. package/package.json +8 -61
  44. package/dist/fonts/index.js +0 -5332
  45. package/dist/grid/index.js +0 -71
  46. package/dist/ime/index.js +0 -84
  47. package/dist/index.js +0 -56210
  48. package/dist/input/index.js +0 -1047
  49. package/dist/pty/index.js +0 -338
  50. package/dist/renderer/index.js +0 -1612
  51. package/dist/selection/index.js +0 -226
  52. package/dist/theme/index.js +0 -11218
  53. package/dist/wasm/index.js +0 -6003
@@ -1,226 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __export = (target, all) => {
3
- for (var name in all)
4
- __defProp(target, name, {
5
- get: all[name],
6
- enumerable: true,
7
- configurable: true,
8
- set: (newValue) => all[name] = () => newValue
9
- });
10
- };
11
- // src/grid/grid.ts
12
- function fontHeightUnits(font) {
13
- if (!font)
14
- return 0;
15
- const height = font.height;
16
- if (height !== undefined && Number.isFinite(height) && height > 0)
17
- return height;
18
- const asc = font.ascender ?? 0;
19
- const desc = font.descender ?? 0;
20
- const fallback = asc - desc;
21
- if (Number.isFinite(fallback) && fallback > 0)
22
- return fallback;
23
- return font.upem || 1000;
24
- }
25
- function computeCellMetrics(font, config, dpr, shapeCluster) {
26
- if (!font)
27
- return null;
28
- const fontSizePx = Math.max(1, Math.round(config.fontSize * dpr));
29
- const scale = font.scaleForSize(fontSizePx, config.sizeMode);
30
- const glyphId = font.glyphIdForChar("M");
31
- const advanceUnits = glyphId !== undefined && glyphId !== null ? font.advanceWidth(glyphId) : shapeCluster("M").advance;
32
- const cellW = Math.max(1, Math.round(advanceUnits * scale));
33
- const lineHeight = fontHeightUnits(font) * scale;
34
- const cellH = Math.max(1, Math.round(lineHeight));
35
- const baselineOffset = font.ascender * scale;
36
- const yPad = Math.max(0, (cellH - lineHeight) * 0.5);
37
- return { cellW, cellH, fontSizePx, scale, lineHeight, baselineOffset, yPad };
38
- }
39
- function createGridState() {
40
- return {
41
- cols: 0,
42
- rows: 0,
43
- cellW: 0,
44
- cellH: 0,
45
- fontSizePx: 0,
46
- scale: 1,
47
- lineHeight: 0,
48
- baselineOffset: 0,
49
- yPad: 0
50
- };
51
- }
52
- function updateGridState(state, metrics, canvasWidth, canvasHeight) {
53
- const cols = Math.max(1, Math.floor(canvasWidth / metrics.cellW));
54
- const rows = Math.max(1, Math.floor(canvasHeight / metrics.cellH));
55
- if (!Number.isFinite(cols) || !Number.isFinite(rows)) {
56
- return { changed: false, cols: state.cols, rows: state.rows };
57
- }
58
- const changed = cols !== state.cols || rows !== state.rows || metrics.fontSizePx !== state.fontSizePx || metrics.cellW !== state.cellW || metrics.cellH !== state.cellH;
59
- Object.assign(state, metrics, { cols, rows });
60
- return { changed, cols, rows };
61
- }
62
- function clamp(value, min, max) {
63
- return Math.max(min, Math.min(max, value));
64
- }
65
-
66
- // src/selection/selection.ts
67
- function createSelectionState() {
68
- return {
69
- active: false,
70
- dragging: false,
71
- anchor: null,
72
- focus: null
73
- };
74
- }
75
- function clearSelection(state) {
76
- state.active = false;
77
- state.dragging = false;
78
- state.anchor = null;
79
- state.focus = null;
80
- }
81
- function startSelection(state, cell) {
82
- state.active = true;
83
- state.dragging = true;
84
- state.anchor = cell;
85
- state.focus = cell;
86
- }
87
- function updateSelection(state, cell) {
88
- if (!state.dragging)
89
- return;
90
- state.focus = cell;
91
- }
92
- function endSelection(state, cell) {
93
- if (!state.dragging)
94
- return false;
95
- state.dragging = false;
96
- state.focus = cell;
97
- if (state.anchor && state.focus && state.anchor.row === state.focus.row && state.anchor.col === state.focus.col) {
98
- clearSelection(state);
99
- return false;
100
- }
101
- return true;
102
- }
103
- function selectionForRow(state, row, cols) {
104
- if (!state.active || !state.anchor || !state.focus)
105
- return null;
106
- const a = state.anchor;
107
- const f = state.focus;
108
- const forward = f.row > a.row || f.row === a.row && f.col >= a.col;
109
- const start = forward ? a : f;
110
- const end = forward ? f : a;
111
- if (start.row === end.row && row === start.row) {
112
- const left = Math.min(start.col, end.col);
113
- const right = Math.max(start.col, end.col) + 1;
114
- return { start: clamp(left, 0, cols), end: clamp(right, 0, cols) };
115
- }
116
- if (row < start.row || row > end.row)
117
- return null;
118
- if (row === start.row) {
119
- return { start: clamp(start.col, 0, cols), end: cols };
120
- }
121
- if (row === end.row) {
122
- return { start: 0, end: clamp(end.col + 1, 0, cols) };
123
- }
124
- return { start: 0, end: cols };
125
- }
126
- function getSelectionText(state, rows, cols, getCellText) {
127
- if (!state.active || !state.anchor || !state.focus)
128
- return "";
129
- if (!rows || !cols)
130
- return "";
131
- const a = state.anchor;
132
- const f = state.focus;
133
- const forward = f.row > a.row || f.row === a.row && f.col >= a.col;
134
- const startRow = forward ? a.row : f.row;
135
- const endRow = forward ? f.row : a.row;
136
- const lines = [];
137
- for (let row = startRow;row <= endRow; row += 1) {
138
- const range = selectionForRow(state, row, cols);
139
- if (!range)
140
- continue;
141
- let line = "";
142
- for (let col = range.start;col < range.end; col += 1) {
143
- const idx = row * cols + col;
144
- line += getCellText(idx);
145
- }
146
- line = line.replace(/[ \t]+$/g, "");
147
- lines.push(line);
148
- }
149
- return lines.join(`
150
- `);
151
- }
152
- function normalizeSelectionCell(cell, rows, cols, wideFlags) {
153
- if (!cell)
154
- return cell;
155
- if (!rows || !cols)
156
- return cell;
157
- const row = clamp(cell.row, 0, rows - 1);
158
- const col = clamp(cell.col, 0, cols - 1);
159
- if (!wideFlags)
160
- return { row, col };
161
- const idx = row * cols + col;
162
- const flag = wideFlags[idx] ?? 0;
163
- if (flag === 2) {
164
- const left = col > 0 ? col - 1 : col;
165
- return { row, col: left };
166
- }
167
- if (flag === 3 && row > 0) {
168
- const prevRow = row - 1;
169
- for (let c = cols - 1;c >= 0; c -= 1) {
170
- const f = wideFlags[prevRow * cols + c] ?? 0;
171
- if (f !== 2 && f !== 3)
172
- return { row: prevRow, col: c };
173
- }
174
- }
175
- return { row, col };
176
- }
177
- function positionToCell(clientX, clientY, canvasRect, dpr, cellW, cellH, cols, rows) {
178
- const x = (clientX - canvasRect.left) * dpr;
179
- const y = (clientY - canvasRect.top) * dpr;
180
- const col = clamp(Math.floor(x / (cellW || 1)), 0, (cols || 1) - 1);
181
- const row = clamp(Math.floor(y / (cellH || 1)), 0, (rows || 1) - 1);
182
- return { row, col };
183
- }
184
- async function copyToClipboard(text) {
185
- if (!text)
186
- return false;
187
- try {
188
- await navigator.clipboard.writeText(text);
189
- return true;
190
- } catch {
191
- const temp = document.createElement("textarea");
192
- temp.value = text;
193
- temp.style.position = "fixed";
194
- temp.style.opacity = "0";
195
- document.body.appendChild(temp);
196
- temp.select();
197
- try {
198
- document.execCommand("copy");
199
- return true;
200
- } catch {
201
- return false;
202
- } finally {
203
- document.body.removeChild(temp);
204
- }
205
- }
206
- }
207
- async function pasteFromClipboard() {
208
- try {
209
- return await navigator.clipboard.readText();
210
- } catch {
211
- return null;
212
- }
213
- }
214
- export {
215
- updateSelection,
216
- startSelection,
217
- selectionForRow,
218
- positionToCell,
219
- pasteFromClipboard,
220
- normalizeSelectionCell,
221
- getSelectionText,
222
- endSelection,
223
- createSelectionState,
224
- copyToClipboard,
225
- clearSelection
226
- };