tmex-cli 0.4.0 → 0.4.1
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/dist/runtime/server.js +718 -186
- package/package.json +1 -1
- package/resources/fe-dist/assets/DevicePage-n4JoyDed.js +26 -0
- package/resources/fe-dist/assets/DevicePage-n4JoyDed.js.map +1 -0
- package/resources/fe-dist/assets/DevicesPage-BwLKaiUR.js +17 -0
- package/resources/fe-dist/assets/{DevicesPage-CtNzaW_c.js.map → DevicesPage-BwLKaiUR.js.map} +1 -1
- package/resources/fe-dist/assets/SettingsPage-hS99lHcp.js +17 -0
- package/resources/fe-dist/assets/SettingsPage-hS99lHcp.js.map +1 -0
- package/resources/fe-dist/assets/index-CJaX5rlK.css +1 -4527
- package/resources/fe-dist/assets/index-CJyFlAt8.js +449 -0
- package/resources/fe-dist/assets/index-CJyFlAt8.js.map +1 -0
- package/resources/fe-dist/assets/select-DGBwxGiK.js +17 -0
- package/resources/fe-dist/assets/{select-BNsiC9zT.js.map → select-DGBwxGiK.js.map} +1 -1
- package/resources/fe-dist/assets/switch-CWUBjs7N.js +12 -0
- package/resources/fe-dist/assets/{switch-CIU4AisU.js.map → switch-CWUBjs7N.js.map} +1 -1
- package/resources/fe-dist/assets/useValueChanged-DwJ_SDCu.js +7 -0
- package/resources/fe-dist/assets/{useValueChanged-V23H0VpC.js.map → useValueChanged-DwJ_SDCu.js.map} +1 -1
- package/resources/fe-dist/index.html +1 -1
- package/resources/gateway-drizzle/0002_broad_vengeance.sql +3 -0
- package/resources/gateway-drizzle/meta/0000_snapshot.json +17 -6
- package/resources/gateway-drizzle/meta/0001_snapshot.json +17 -6
- package/resources/gateway-drizzle/meta/0002_snapshot.json +535 -0
- package/resources/gateway-drizzle/meta/_journal.json +8 -1
- package/resources/fe-dist/assets/DevicePage-iSkEDEpS.js +0 -4570
- package/resources/fe-dist/assets/DevicePage-iSkEDEpS.js.map +0 -1
- package/resources/fe-dist/assets/DevicesPage-CtNzaW_c.js +0 -2143
- package/resources/fe-dist/assets/SettingsPage-D25_d6j9.js +0 -1144
- package/resources/fe-dist/assets/SettingsPage-D25_d6j9.js.map +0 -1
- package/resources/fe-dist/assets/index-dsVN7rgz.js +0 -200
- package/resources/fe-dist/assets/index-dsVN7rgz.js.map +0 -1
- package/resources/fe-dist/assets/select-BNsiC9zT.js +0 -2805
- package/resources/fe-dist/assets/switch-CIU4AisU.js +0 -234
- package/resources/fe-dist/assets/useValueChanged-V23H0VpC.js +0 -351
|
@@ -1,4570 +0,0 @@
|
|
|
1
|
-
var Xt = Object.defineProperty;
|
|
2
|
-
var Jt = (n, e, t) =>
|
|
3
|
-
e in n ? Xt(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : (n[e] = t);
|
|
4
|
-
var w = (n, e, t) => Jt(n, typeof e != 'symbol' ? e + '' : e, t);
|
|
5
|
-
import {
|
|
6
|
-
u as Dt,
|
|
7
|
-
c as Fe,
|
|
8
|
-
f as Ke,
|
|
9
|
-
bz as Qt,
|
|
10
|
-
e as Zt,
|
|
11
|
-
r as d,
|
|
12
|
-
bB as ge,
|
|
13
|
-
bA as it,
|
|
14
|
-
bw as j,
|
|
15
|
-
j as m,
|
|
16
|
-
by as rt,
|
|
17
|
-
b as st,
|
|
18
|
-
d as ue,
|
|
19
|
-
bx as ut,
|
|
20
|
-
B as we,
|
|
21
|
-
} from './index-dsVN7rgz.js';
|
|
22
|
-
import { L as We, S as dn, a as ht } from './switch-CIU4AisU.js'; /**
|
|
23
|
-
* @license lucide-react v0.564.0 - ISC
|
|
24
|
-
*
|
|
25
|
-
* This source code is licensed under the ISC license.
|
|
26
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
27
|
-
*/
|
|
28
|
-
import {
|
|
29
|
-
f as an,
|
|
30
|
-
g as cn,
|
|
31
|
-
T as en,
|
|
32
|
-
e as ln,
|
|
33
|
-
a as nn,
|
|
34
|
-
d as on,
|
|
35
|
-
c as rn,
|
|
36
|
-
b as sn,
|
|
37
|
-
A as tn,
|
|
38
|
-
} from './useValueChanged-V23H0VpC.js';
|
|
39
|
-
const un = [
|
|
40
|
-
['path', { d: 'M12 17V3', key: '1cwfxf' }],
|
|
41
|
-
['path', { d: 'm6 11 6 6 6-6', key: '12ii2o' }],
|
|
42
|
-
['path', { d: 'M19 21H5', key: '150jfl' }],
|
|
43
|
-
],
|
|
44
|
-
hn = Fe('arrow-down-to-line', un); /**
|
|
45
|
-
* @license lucide-react v0.564.0 - ISC
|
|
46
|
-
*
|
|
47
|
-
* This source code is licensed under the ISC license.
|
|
48
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
49
|
-
*/
|
|
50
|
-
const fn = [
|
|
51
|
-
['path', { d: 'M10 8h.01', key: '1r9ogq' }],
|
|
52
|
-
['path', { d: 'M12 12h.01', key: '1mp3jc' }],
|
|
53
|
-
['path', { d: 'M14 8h.01', key: '1primd' }],
|
|
54
|
-
['path', { d: 'M16 12h.01', key: '1l6xoz' }],
|
|
55
|
-
['path', { d: 'M18 8h.01', key: 'emo2bl' }],
|
|
56
|
-
['path', { d: 'M6 8h.01', key: 'x9i8wu' }],
|
|
57
|
-
['path', { d: 'M7 16h10', key: 'wp8him' }],
|
|
58
|
-
['path', { d: 'M8 12h.01', key: 'czm47f' }],
|
|
59
|
-
['rect', { width: '20', height: '16', x: '2', y: '4', rx: '2', key: '18n3k1' }],
|
|
60
|
-
],
|
|
61
|
-
mn = Fe('keyboard', fn); /**
|
|
62
|
-
* @license lucide-react v0.564.0 - ISC
|
|
63
|
-
*
|
|
64
|
-
* This source code is licensed under the ISC license.
|
|
65
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
66
|
-
*/
|
|
67
|
-
const pn = [
|
|
68
|
-
['path', { d: 'M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8', key: 'v9h5vc' }],
|
|
69
|
-
['path', { d: 'M21 3v5h-5', key: '1q7to0' }],
|
|
70
|
-
['path', { d: 'M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16', key: '3uifl3' }],
|
|
71
|
-
['path', { d: 'M8 16H3v5', key: '1cv678' }],
|
|
72
|
-
],
|
|
73
|
-
wn = Fe('refresh-cw', pn); /**
|
|
74
|
-
* @license lucide-react v0.564.0 - ISC
|
|
75
|
-
*
|
|
76
|
-
* This source code is licensed under the ISC license.
|
|
77
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
78
|
-
*/
|
|
79
|
-
const gn = [
|
|
80
|
-
['rect', { width: '14', height: '20', x: '5', y: '2', rx: '2', ry: '2', key: '1yt0o3' }],
|
|
81
|
-
['path', { d: 'M12 18h.01', key: 'mhygvu' }],
|
|
82
|
-
],
|
|
83
|
-
yn = Fe('smartphone', gn);
|
|
84
|
-
function Sn(n) {
|
|
85
|
-
return `rgb(${n.r} ${n.g} ${n.b})`;
|
|
86
|
-
}
|
|
87
|
-
function je(n) {
|
|
88
|
-
const e = n.getContext('2d');
|
|
89
|
-
if (!e) throw new Error('2d canvas context unavailable');
|
|
90
|
-
return e;
|
|
91
|
-
}
|
|
92
|
-
class _n {
|
|
93
|
-
constructor(e) {
|
|
94
|
-
w(this, 'kind', 'canvas');
|
|
95
|
-
w(this, 'mainCanvas');
|
|
96
|
-
w(this, 'selectionCanvas');
|
|
97
|
-
w(this, 'cursorCanvas');
|
|
98
|
-
w(this, 'mainContext');
|
|
99
|
-
w(this, 'selectionContext');
|
|
100
|
-
w(this, 'cursorContext');
|
|
101
|
-
w(this, 'theme');
|
|
102
|
-
w(this, 'fontFamily');
|
|
103
|
-
w(this, 'fontSize');
|
|
104
|
-
w(this, 'cellDimensions', { width: 9, height: 17 });
|
|
105
|
-
w(this, 'cols', 0);
|
|
106
|
-
w(this, 'rows', 0);
|
|
107
|
-
w(this, 'lastCursor', null);
|
|
108
|
-
w(this, 'frameCount', 0);
|
|
109
|
-
w(this, 'lastDrawnRows', []);
|
|
110
|
-
w(this, 'colorCache', new Map());
|
|
111
|
-
w(this, 'fontCache', new Map());
|
|
112
|
-
w(this, 'cursorBlinkVisible', !0);
|
|
113
|
-
w(this, 'cursorBlinkTimer', null);
|
|
114
|
-
(this.theme = e.theme),
|
|
115
|
-
(this.fontFamily = e.fontFamily),
|
|
116
|
-
(this.fontSize = e.fontSize),
|
|
117
|
-
(e.screenElement.style.position = 'relative'),
|
|
118
|
-
(e.screenElement.style.overflow = 'hidden'),
|
|
119
|
-
(this.mainCanvas = document.createElement('canvas')),
|
|
120
|
-
(this.selectionCanvas = document.createElement('canvas')),
|
|
121
|
-
(this.cursorCanvas = document.createElement('canvas'));
|
|
122
|
-
for (const [t, s] of [
|
|
123
|
-
[this.mainCanvas, 'main'],
|
|
124
|
-
[this.selectionCanvas, 'selection'],
|
|
125
|
-
[this.cursorCanvas, 'cursor'],
|
|
126
|
-
])
|
|
127
|
-
(t.dataset.layer = s),
|
|
128
|
-
(t.style.position = 'absolute'),
|
|
129
|
-
(t.style.inset = '0'),
|
|
130
|
-
(t.style.width = '100%'),
|
|
131
|
-
(t.style.height = '100%'),
|
|
132
|
-
(t.style.pointerEvents = 'none'),
|
|
133
|
-
e.screenElement.appendChild(t);
|
|
134
|
-
(this.mainContext = je(this.mainCanvas)),
|
|
135
|
-
(this.selectionContext = je(this.selectionCanvas)),
|
|
136
|
-
(this.cursorContext = je(this.cursorCanvas));
|
|
137
|
-
}
|
|
138
|
-
setTheme(e) {
|
|
139
|
-
(this.theme = e), this.colorCache.clear();
|
|
140
|
-
}
|
|
141
|
-
render(e) {
|
|
142
|
-
if (
|
|
143
|
-
((this.frameCount += 1),
|
|
144
|
-
(this.lastDrawnRows = []),
|
|
145
|
-
(this.cellDimensions = e.cellDimensions),
|
|
146
|
-
this.resize(e.meta.cols, e.meta.rows),
|
|
147
|
-
this.drawSelection(
|
|
148
|
-
e.selectionRects ?? [],
|
|
149
|
-
e.selectionColor ?? this.theme.selectionBackground
|
|
150
|
-
),
|
|
151
|
-
e.meta.dirty === 'clean')
|
|
152
|
-
) {
|
|
153
|
-
this.drawCursor(e.meta);
|
|
154
|
-
return;
|
|
155
|
-
}
|
|
156
|
-
const s = e.meta.dirty === 'full' ? e.rows : e.rows.filter((r) => r.dirty);
|
|
157
|
-
for (const r of s) this.drawRow(r, e.meta.colors), this.lastDrawnRows.push(r.y);
|
|
158
|
-
this.drawCursor(e.meta);
|
|
159
|
-
}
|
|
160
|
-
getDebugState() {
|
|
161
|
-
return { kind: this.kind, frameCount: this.frameCount, lastDrawnRows: [...this.lastDrawnRows] };
|
|
162
|
-
}
|
|
163
|
-
dispose() {
|
|
164
|
-
this.mainCanvas.remove(),
|
|
165
|
-
this.selectionCanvas.remove(),
|
|
166
|
-
this.cursorCanvas.remove(),
|
|
167
|
-
this.colorCache.clear(),
|
|
168
|
-
this.fontCache.clear(),
|
|
169
|
-
(this.lastCursor = null),
|
|
170
|
-
this.stopCursorBlink();
|
|
171
|
-
}
|
|
172
|
-
startCursorBlink() {
|
|
173
|
-
this.cursorBlinkTimer ||
|
|
174
|
-
(this.cursorBlinkTimer = setInterval(() => {
|
|
175
|
-
(this.cursorBlinkVisible = !this.cursorBlinkVisible),
|
|
176
|
-
(this.cursorCanvas.style.opacity = this.cursorBlinkVisible ? '1' : '0');
|
|
177
|
-
}, 1e3));
|
|
178
|
-
}
|
|
179
|
-
stopCursorBlink() {
|
|
180
|
-
this.cursorBlinkTimer && (clearInterval(this.cursorBlinkTimer), (this.cursorBlinkTimer = null)),
|
|
181
|
-
(this.cursorBlinkVisible = !0),
|
|
182
|
-
(this.cursorCanvas.style.opacity = '1');
|
|
183
|
-
}
|
|
184
|
-
resize(e, t) {
|
|
185
|
-
const s = Math.max(1, e),
|
|
186
|
-
r = Math.max(1, t),
|
|
187
|
-
i = s * this.cellDimensions.width,
|
|
188
|
-
o = r * this.cellDimensions.height,
|
|
189
|
-
l = Math.max(1, globalThis.devicePixelRatio ?? 1);
|
|
190
|
-
if (this.cols === s && this.rows === r) {
|
|
191
|
-
const u = `${i}px`,
|
|
192
|
-
c = `${o}px`;
|
|
193
|
-
if (this.mainCanvas.style.width === u && this.mainCanvas.style.height === c) return;
|
|
194
|
-
}
|
|
195
|
-
(this.cols = s), (this.rows = r);
|
|
196
|
-
for (const u of [this.mainCanvas, this.selectionCanvas, this.cursorCanvas])
|
|
197
|
-
(u.width = Math.max(1, Math.ceil(i * l))),
|
|
198
|
-
(u.height = Math.max(1, Math.ceil(o * l))),
|
|
199
|
-
(u.style.width = `${i}px`),
|
|
200
|
-
(u.style.height = `${o}px`);
|
|
201
|
-
for (const u of [this.mainContext, this.selectionContext, this.cursorContext])
|
|
202
|
-
u.setTransform(l, 0, 0, l, 0, 0), (u.textBaseline = 'top'), (u.imageSmoothingEnabled = !1);
|
|
203
|
-
}
|
|
204
|
-
drawSelection(e, t) {
|
|
205
|
-
if (
|
|
206
|
-
(this.selectionContext.clearRect(
|
|
207
|
-
0,
|
|
208
|
-
0,
|
|
209
|
-
this.cols * this.cellDimensions.width,
|
|
210
|
-
this.rows * this.cellDimensions.height
|
|
211
|
-
),
|
|
212
|
-
e.length !== 0)
|
|
213
|
-
) {
|
|
214
|
-
this.selectionContext.fillStyle = t;
|
|
215
|
-
for (const s of e)
|
|
216
|
-
this.selectionContext.fillRect(
|
|
217
|
-
s.x * this.cellDimensions.width,
|
|
218
|
-
s.row * this.cellDimensions.height,
|
|
219
|
-
s.width * this.cellDimensions.width,
|
|
220
|
-
this.cellDimensions.height
|
|
221
|
-
);
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
drawRow(e, t) {
|
|
225
|
-
const s = e.y * this.cellDimensions.height,
|
|
226
|
-
r = this.cols * this.cellDimensions.width,
|
|
227
|
-
i = this.toCss(t.background);
|
|
228
|
-
this.mainContext.clearRect(0, s, r, this.cellDimensions.height),
|
|
229
|
-
(this.mainContext.fillStyle = i),
|
|
230
|
-
this.mainContext.fillRect(0, s, r, this.cellDimensions.height);
|
|
231
|
-
for (const o of e.cells) {
|
|
232
|
-
if (o.widthKind === 'spacer-tail' || o.widthKind === 'spacer-head') continue;
|
|
233
|
-
const l = o.x * this.cellDimensions.width,
|
|
234
|
-
u = o.style.inverse ? (o.fgColor ?? t.foreground) : (o.bgColor ?? t.background),
|
|
235
|
-
c = o.style.inverse ? (o.bgColor ?? t.background) : (o.fgColor ?? t.foreground),
|
|
236
|
-
y = o.widthKind === 'wide' ? this.cellDimensions.width * 2 : this.cellDimensions.width;
|
|
237
|
-
(u.r !== t.background.r || u.g !== t.background.g || u.b !== t.background.b) &&
|
|
238
|
-
((this.mainContext.fillStyle = this.toCss(u)),
|
|
239
|
-
this.mainContext.fillRect(l, s, y, this.cellDimensions.height)),
|
|
240
|
-
!(!o.text || o.style.invisible) &&
|
|
241
|
-
((this.mainContext.font = this.resolveFont(o.style)),
|
|
242
|
-
(this.mainContext.fillStyle = this.toCss(c)),
|
|
243
|
-
this.mainContext.fillText(o.text, l, s),
|
|
244
|
-
o.style.underline > 0 &&
|
|
245
|
-
this.mainContext.fillRect(l, s + this.cellDimensions.height - 2, Math.max(y - 1, 1), 1),
|
|
246
|
-
o.style.strikethrough &&
|
|
247
|
-
this.mainContext.fillRect(
|
|
248
|
-
l,
|
|
249
|
-
s + this.cellDimensions.height * 0.55,
|
|
250
|
-
Math.max(y - 1, 1),
|
|
251
|
-
1
|
|
252
|
-
),
|
|
253
|
-
o.style.overline && this.mainContext.fillRect(l, s + 1, Math.max(y - 1, 1), 1));
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
drawCursor(e) {
|
|
257
|
-
const t = e.colors,
|
|
258
|
-
s = e.cursor,
|
|
259
|
-
r = this.lastCursor;
|
|
260
|
-
if (
|
|
261
|
-
(this.cursorContext.clearRect(
|
|
262
|
-
0,
|
|
263
|
-
0,
|
|
264
|
-
this.cols * this.cellDimensions.width,
|
|
265
|
-
this.rows * this.cellDimensions.height
|
|
266
|
-
),
|
|
267
|
-
!s.visible || s.x === null || s.y === null)
|
|
268
|
-
) {
|
|
269
|
-
(this.lastCursor = null), this.stopCursorBlink();
|
|
270
|
-
return;
|
|
271
|
-
}
|
|
272
|
-
const i = s.x * this.cellDimensions.width,
|
|
273
|
-
o = s.y * this.cellDimensions.height,
|
|
274
|
-
l = s.wideTail ? this.cellDimensions.width * 2 : this.cellDimensions.width,
|
|
275
|
-
u = t.cursor ?? t.foreground,
|
|
276
|
-
c = this.toCss(u);
|
|
277
|
-
(this.cursorContext.fillStyle = c),
|
|
278
|
-
(this.cursorContext.strokeStyle = c),
|
|
279
|
-
(this.cursorContext.globalAlpha = 0.7),
|
|
280
|
-
this.cursorContext.fillRect(i, o + this.cellDimensions.height - 2, Math.max(l - 1, 1), 2),
|
|
281
|
-
(this.cursorContext.globalAlpha = 1),
|
|
282
|
-
this.startCursorBlink(),
|
|
283
|
-
(this.lastCursor = { x: s.x, y: s.y, style: s.style }),
|
|
284
|
-
r &&
|
|
285
|
-
(r.x !== this.lastCursor.x ||
|
|
286
|
-
r.y !== this.lastCursor.y ||
|
|
287
|
-
r.style !== this.lastCursor.style) &&
|
|
288
|
-
this.lastDrawnRows.push(r.y);
|
|
289
|
-
}
|
|
290
|
-
resolveFont(e) {
|
|
291
|
-
const t = [
|
|
292
|
-
e.italic ? 'italic' : 'normal',
|
|
293
|
-
e.bold ? '700' : '400',
|
|
294
|
-
`${this.fontSize}px`,
|
|
295
|
-
this.fontFamily,
|
|
296
|
-
].join('|'),
|
|
297
|
-
s = this.fontCache.get(t);
|
|
298
|
-
if (s) return s;
|
|
299
|
-
const r = `${e.italic ? 'italic ' : ''}${e.bold ? '700 ' : ''}${this.fontSize}px ${this.fontFamily}`;
|
|
300
|
-
return this.fontCache.set(t, r), r;
|
|
301
|
-
}
|
|
302
|
-
toCss(e) {
|
|
303
|
-
const t = `${e.r},${e.g},${e.b}`,
|
|
304
|
-
s = this.colorCache.get(t);
|
|
305
|
-
if (s) return s;
|
|
306
|
-
const r = Sn(e);
|
|
307
|
-
return this.colorCache.set(t, r), r;
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
const Tn = 0,
|
|
311
|
-
bn = {
|
|
312
|
-
Backquote: 1,
|
|
313
|
-
Backslash: 2,
|
|
314
|
-
BracketLeft: 3,
|
|
315
|
-
BracketRight: 4,
|
|
316
|
-
Comma: 5,
|
|
317
|
-
Digit0: 6,
|
|
318
|
-
Digit1: 7,
|
|
319
|
-
Digit2: 8,
|
|
320
|
-
Digit3: 9,
|
|
321
|
-
Digit4: 10,
|
|
322
|
-
Digit5: 11,
|
|
323
|
-
Digit6: 12,
|
|
324
|
-
Digit7: 13,
|
|
325
|
-
Digit8: 14,
|
|
326
|
-
Digit9: 15,
|
|
327
|
-
Equal: 16,
|
|
328
|
-
IntlBackslash: 17,
|
|
329
|
-
IntlRo: 18,
|
|
330
|
-
IntlYen: 19,
|
|
331
|
-
KeyA: 20,
|
|
332
|
-
KeyB: 21,
|
|
333
|
-
KeyC: 22,
|
|
334
|
-
KeyD: 23,
|
|
335
|
-
KeyE: 24,
|
|
336
|
-
KeyF: 25,
|
|
337
|
-
KeyG: 26,
|
|
338
|
-
KeyH: 27,
|
|
339
|
-
KeyI: 28,
|
|
340
|
-
KeyJ: 29,
|
|
341
|
-
KeyK: 30,
|
|
342
|
-
KeyL: 31,
|
|
343
|
-
KeyM: 32,
|
|
344
|
-
KeyN: 33,
|
|
345
|
-
KeyO: 34,
|
|
346
|
-
KeyP: 35,
|
|
347
|
-
KeyQ: 36,
|
|
348
|
-
KeyR: 37,
|
|
349
|
-
KeyS: 38,
|
|
350
|
-
KeyT: 39,
|
|
351
|
-
KeyU: 40,
|
|
352
|
-
KeyV: 41,
|
|
353
|
-
KeyW: 42,
|
|
354
|
-
KeyX: 43,
|
|
355
|
-
KeyY: 44,
|
|
356
|
-
KeyZ: 45,
|
|
357
|
-
Minus: 46,
|
|
358
|
-
Period: 47,
|
|
359
|
-
Quote: 48,
|
|
360
|
-
Semicolon: 49,
|
|
361
|
-
Slash: 50,
|
|
362
|
-
AltLeft: 51,
|
|
363
|
-
AltRight: 52,
|
|
364
|
-
Backspace: 53,
|
|
365
|
-
CapsLock: 54,
|
|
366
|
-
ContextMenu: 55,
|
|
367
|
-
ControlLeft: 56,
|
|
368
|
-
ControlRight: 57,
|
|
369
|
-
Enter: 58,
|
|
370
|
-
MetaLeft: 59,
|
|
371
|
-
MetaRight: 60,
|
|
372
|
-
ShiftLeft: 61,
|
|
373
|
-
ShiftRight: 62,
|
|
374
|
-
Space: 63,
|
|
375
|
-
Tab: 64,
|
|
376
|
-
Convert: 65,
|
|
377
|
-
KanaMode: 66,
|
|
378
|
-
NonConvert: 67,
|
|
379
|
-
Delete: 68,
|
|
380
|
-
End: 69,
|
|
381
|
-
Help: 70,
|
|
382
|
-
Home: 71,
|
|
383
|
-
Insert: 72,
|
|
384
|
-
PageDown: 73,
|
|
385
|
-
PageUp: 74,
|
|
386
|
-
ArrowDown: 75,
|
|
387
|
-
ArrowLeft: 76,
|
|
388
|
-
ArrowRight: 77,
|
|
389
|
-
ArrowUp: 78,
|
|
390
|
-
NumLock: 79,
|
|
391
|
-
Numpad0: 80,
|
|
392
|
-
Numpad1: 81,
|
|
393
|
-
Numpad2: 82,
|
|
394
|
-
Numpad3: 83,
|
|
395
|
-
Numpad4: 84,
|
|
396
|
-
Numpad5: 85,
|
|
397
|
-
Numpad6: 86,
|
|
398
|
-
Numpad7: 87,
|
|
399
|
-
Numpad8: 88,
|
|
400
|
-
Numpad9: 89,
|
|
401
|
-
NumpadAdd: 90,
|
|
402
|
-
NumpadBackspace: 91,
|
|
403
|
-
NumpadClear: 92,
|
|
404
|
-
NumpadClearEntry: 93,
|
|
405
|
-
NumpadComma: 94,
|
|
406
|
-
NumpadDecimal: 95,
|
|
407
|
-
NumpadDivide: 96,
|
|
408
|
-
NumpadEnter: 97,
|
|
409
|
-
NumpadEqual: 98,
|
|
410
|
-
NumpadMemoryAdd: 99,
|
|
411
|
-
NumpadMemoryClear: 100,
|
|
412
|
-
NumpadMemoryRecall: 101,
|
|
413
|
-
NumpadMemoryStore: 102,
|
|
414
|
-
NumpadMemorySubtract: 103,
|
|
415
|
-
NumpadMultiply: 104,
|
|
416
|
-
NumpadParenLeft: 105,
|
|
417
|
-
NumpadParenRight: 106,
|
|
418
|
-
NumpadSubtract: 107,
|
|
419
|
-
NumpadSeparator: 108,
|
|
420
|
-
NumpadUp: 109,
|
|
421
|
-
NumpadDown: 110,
|
|
422
|
-
NumpadRight: 111,
|
|
423
|
-
NumpadLeft: 112,
|
|
424
|
-
NumpadBegin: 113,
|
|
425
|
-
NumpadHome: 114,
|
|
426
|
-
NumpadEnd: 115,
|
|
427
|
-
NumpadInsert: 116,
|
|
428
|
-
NumpadDelete: 117,
|
|
429
|
-
NumpadPageUp: 118,
|
|
430
|
-
NumpadPageDown: 119,
|
|
431
|
-
Escape: 120,
|
|
432
|
-
F1: 121,
|
|
433
|
-
F2: 122,
|
|
434
|
-
F3: 123,
|
|
435
|
-
F4: 124,
|
|
436
|
-
F5: 125,
|
|
437
|
-
F6: 126,
|
|
438
|
-
F7: 127,
|
|
439
|
-
F8: 128,
|
|
440
|
-
F9: 129,
|
|
441
|
-
F10: 130,
|
|
442
|
-
F11: 131,
|
|
443
|
-
F12: 132,
|
|
444
|
-
F13: 133,
|
|
445
|
-
F14: 134,
|
|
446
|
-
F15: 135,
|
|
447
|
-
F16: 136,
|
|
448
|
-
F17: 137,
|
|
449
|
-
F18: 138,
|
|
450
|
-
F19: 139,
|
|
451
|
-
F20: 140,
|
|
452
|
-
F21: 141,
|
|
453
|
-
F22: 142,
|
|
454
|
-
F23: 143,
|
|
455
|
-
F24: 144,
|
|
456
|
-
F25: 145,
|
|
457
|
-
Fn: 146,
|
|
458
|
-
FnLock: 147,
|
|
459
|
-
PrintScreen: 148,
|
|
460
|
-
ScrollLock: 149,
|
|
461
|
-
Pause: 150,
|
|
462
|
-
BrowserBack: 151,
|
|
463
|
-
BrowserFavorites: 152,
|
|
464
|
-
BrowserForward: 153,
|
|
465
|
-
BrowserHome: 154,
|
|
466
|
-
BrowserRefresh: 155,
|
|
467
|
-
BrowserSearch: 156,
|
|
468
|
-
BrowserStop: 157,
|
|
469
|
-
Eject: 158,
|
|
470
|
-
LaunchApp1: 159,
|
|
471
|
-
LaunchApp2: 160,
|
|
472
|
-
LaunchMail: 161,
|
|
473
|
-
MediaPlayPause: 162,
|
|
474
|
-
MediaSelect: 163,
|
|
475
|
-
MediaStop: 164,
|
|
476
|
-
MediaTrackNext: 165,
|
|
477
|
-
MediaTrackPrevious: 166,
|
|
478
|
-
Power: 167,
|
|
479
|
-
Sleep: 168,
|
|
480
|
-
AudioVolumeDown: 169,
|
|
481
|
-
AudioVolumeMute: 170,
|
|
482
|
-
AudioVolumeUp: 171,
|
|
483
|
-
WakeUp: 172,
|
|
484
|
-
Copy: 173,
|
|
485
|
-
Cut: 174,
|
|
486
|
-
Paste: 175,
|
|
487
|
-
},
|
|
488
|
-
ot = {
|
|
489
|
-
Backquote: '`',
|
|
490
|
-
Backslash: '\\',
|
|
491
|
-
BracketLeft: '[',
|
|
492
|
-
BracketRight: ']',
|
|
493
|
-
Comma: ',',
|
|
494
|
-
Equal: '=',
|
|
495
|
-
Minus: '-',
|
|
496
|
-
Period: '.',
|
|
497
|
-
Quote: "'",
|
|
498
|
-
Semicolon: ';',
|
|
499
|
-
Slash: '/',
|
|
500
|
-
Space: ' ',
|
|
501
|
-
IntlBackslash: '\\',
|
|
502
|
-
IntlYen: '¥',
|
|
503
|
-
IntlRo: '\\',
|
|
504
|
-
};
|
|
505
|
-
for (let n = 0; n <= 9; n += 1) ot[`Digit${n}`] = String(n);
|
|
506
|
-
for (let n = 0; n < 26; n += 1) {
|
|
507
|
-
const e = String.fromCharCode(65 + n),
|
|
508
|
-
t = String.fromCharCode(97 + n);
|
|
509
|
-
ot[`Key${e}`] = t;
|
|
510
|
-
}
|
|
511
|
-
function ft(n) {
|
|
512
|
-
return bn[n] ?? Tn;
|
|
513
|
-
}
|
|
514
|
-
function xn(n) {
|
|
515
|
-
const e = ot[n];
|
|
516
|
-
return e ? (e.codePointAt(0) ?? null) : null;
|
|
517
|
-
}
|
|
518
|
-
const ye = 0,
|
|
519
|
-
En = -2,
|
|
520
|
-
Rn = 1,
|
|
521
|
-
Cn = 2,
|
|
522
|
-
vn = 3,
|
|
523
|
-
Mn = 10,
|
|
524
|
-
Dn = 11,
|
|
525
|
-
An = 12,
|
|
526
|
-
On = 13,
|
|
527
|
-
kn = 14,
|
|
528
|
-
In = 15,
|
|
529
|
-
Bn = 16,
|
|
530
|
-
Hn = 17,
|
|
531
|
-
Pn = 1,
|
|
532
|
-
Ln = 2,
|
|
533
|
-
Nn = 1,
|
|
534
|
-
Fn = 2,
|
|
535
|
-
Gn = 3,
|
|
536
|
-
Un = 4,
|
|
537
|
-
zn = 5,
|
|
538
|
-
Yn = 6,
|
|
539
|
-
Vn = 1,
|
|
540
|
-
$n = 2,
|
|
541
|
-
Kn = 3,
|
|
542
|
-
Wn = 4;
|
|
543
|
-
function lt(n) {
|
|
544
|
-
if (n.disposed || n.renderStateHandle === 0)
|
|
545
|
-
throw new Error('render state resources already disposed');
|
|
546
|
-
}
|
|
547
|
-
function jn(n) {
|
|
548
|
-
switch (n) {
|
|
549
|
-
case 2:
|
|
550
|
-
return 'full';
|
|
551
|
-
case 1:
|
|
552
|
-
return 'partial';
|
|
553
|
-
default:
|
|
554
|
-
return 'clean';
|
|
555
|
-
}
|
|
556
|
-
}
|
|
557
|
-
function qn(n) {
|
|
558
|
-
switch (n) {
|
|
559
|
-
case 0:
|
|
560
|
-
return 'bar';
|
|
561
|
-
case 2:
|
|
562
|
-
return 'underline';
|
|
563
|
-
case 3:
|
|
564
|
-
return 'block-hollow';
|
|
565
|
-
default:
|
|
566
|
-
return 'block';
|
|
567
|
-
}
|
|
568
|
-
}
|
|
569
|
-
function Xn(n) {
|
|
570
|
-
switch (n) {
|
|
571
|
-
case 1:
|
|
572
|
-
return 'wide';
|
|
573
|
-
case 2:
|
|
574
|
-
return 'spacer-tail';
|
|
575
|
-
case 3:
|
|
576
|
-
return 'spacer-head';
|
|
577
|
-
default:
|
|
578
|
-
return 'narrow';
|
|
579
|
-
}
|
|
580
|
-
}
|
|
581
|
-
function Ee(n, e) {
|
|
582
|
-
return { r: n.view().getUint8(e), g: n.view().getUint8(e + 1), b: n.view().getUint8(e + 2) };
|
|
583
|
-
}
|
|
584
|
-
function mt(n, e) {
|
|
585
|
-
const t = n.bindings.allocStruct('GhosttyColorRgb');
|
|
586
|
-
try {
|
|
587
|
-
const s = e(t.ptr);
|
|
588
|
-
if (s === En) return null;
|
|
589
|
-
if (s !== ye) throw new Error(`ghostty optional color read failed with result ${s}`);
|
|
590
|
-
return Ee(n.bindings, t.ptr);
|
|
591
|
-
} finally {
|
|
592
|
-
t.free();
|
|
593
|
-
}
|
|
594
|
-
}
|
|
595
|
-
function fe(n, e) {
|
|
596
|
-
const t = n.bindings.allocU8();
|
|
597
|
-
try {
|
|
598
|
-
const s = e(t);
|
|
599
|
-
if (typeof s == 'number' && s !== ye)
|
|
600
|
-
throw new Error(`ghostty bool read failed with result ${s}`);
|
|
601
|
-
return n.bindings.readU8(t) !== 0;
|
|
602
|
-
} finally {
|
|
603
|
-
n.bindings.freeU8(t);
|
|
604
|
-
}
|
|
605
|
-
}
|
|
606
|
-
function De(n, e) {
|
|
607
|
-
const t = n.bindings.allocBytes(2);
|
|
608
|
-
try {
|
|
609
|
-
const s = e(t);
|
|
610
|
-
if (typeof s == 'number' && s !== ye)
|
|
611
|
-
throw new Error(`ghostty u16 read failed with result ${s}`);
|
|
612
|
-
return n.bindings.view().getUint16(t, !0);
|
|
613
|
-
} finally {
|
|
614
|
-
n.bindings.freeBytes(t, 2);
|
|
615
|
-
}
|
|
616
|
-
}
|
|
617
|
-
function Jn(n, e) {
|
|
618
|
-
const t = n.bindings.allocBytes(4);
|
|
619
|
-
try {
|
|
620
|
-
const s = e(t);
|
|
621
|
-
if (typeof s == 'number' && s !== ye)
|
|
622
|
-
throw new Error(`ghostty u32 read failed with result ${s}`);
|
|
623
|
-
return n.bindings.view().getUint32(t, !0);
|
|
624
|
-
} finally {
|
|
625
|
-
n.bindings.freeBytes(t, 4);
|
|
626
|
-
}
|
|
627
|
-
}
|
|
628
|
-
function et(n, e) {
|
|
629
|
-
const t = n.bindings.allocBytes(4);
|
|
630
|
-
try {
|
|
631
|
-
const s = e(t);
|
|
632
|
-
if (typeof s == 'number' && s !== ye)
|
|
633
|
-
throw new Error(`ghostty enum read failed with result ${s}`);
|
|
634
|
-
return n.bindings.view().getInt32(t, !0);
|
|
635
|
-
} finally {
|
|
636
|
-
n.bindings.freeBytes(t, 4);
|
|
637
|
-
}
|
|
638
|
-
}
|
|
639
|
-
function pt(n, e) {
|
|
640
|
-
const t = n.bindings.allocBytes(8);
|
|
641
|
-
try {
|
|
642
|
-
const s = e(t);
|
|
643
|
-
if (typeof s == 'number' && s !== ye)
|
|
644
|
-
throw new Error(`ghostty u64 read failed with result ${s}`);
|
|
645
|
-
return n.bindings.readU64(t);
|
|
646
|
-
} finally {
|
|
647
|
-
n.bindings.freeBytes(t, 8);
|
|
648
|
-
}
|
|
649
|
-
}
|
|
650
|
-
function Qn(n) {
|
|
651
|
-
const e = n.bindings.allocStruct('GhosttyStyle');
|
|
652
|
-
try {
|
|
653
|
-
n.bindings.setField(e.view, 'GhosttyStyle', 'size', n.bindings.typeSize('GhosttyStyle')),
|
|
654
|
-
n.bindings.getRenderStateRowCellValue(n.rowCellsHandle, Fn, e.ptr);
|
|
655
|
-
const t = (s) => n.bindings.field('GhosttyStyle', s).offset;
|
|
656
|
-
return {
|
|
657
|
-
bold: e.view.getUint8(t('bold')) !== 0,
|
|
658
|
-
italic: e.view.getUint8(t('italic')) !== 0,
|
|
659
|
-
faint: e.view.getUint8(t('faint')) !== 0,
|
|
660
|
-
blink: e.view.getUint8(t('blink')) !== 0,
|
|
661
|
-
inverse: e.view.getUint8(t('inverse')) !== 0,
|
|
662
|
-
invisible: e.view.getUint8(t('invisible')) !== 0,
|
|
663
|
-
strikethrough: e.view.getUint8(t('strikethrough')) !== 0,
|
|
664
|
-
overline: e.view.getUint8(t('overline')) !== 0,
|
|
665
|
-
underline: e.view.getInt32(t('underline'), !0),
|
|
666
|
-
};
|
|
667
|
-
} finally {
|
|
668
|
-
e.free();
|
|
669
|
-
}
|
|
670
|
-
}
|
|
671
|
-
function Zn(n) {
|
|
672
|
-
const e = Jn(n, (s) => n.bindings.getRenderStateRowCellValueResult(n.rowCellsHandle, Gn, s));
|
|
673
|
-
if (e === 0) return [];
|
|
674
|
-
const t = n.bindings.allocBytes(e * 4);
|
|
675
|
-
try {
|
|
676
|
-
n.bindings.getRenderStateRowCellValue(n.rowCellsHandle, Un, t);
|
|
677
|
-
const s = [];
|
|
678
|
-
for (let r = 0; r < e; r += 1) s.push(n.bindings.view().getUint32(t + r * 4, !0));
|
|
679
|
-
return s;
|
|
680
|
-
} finally {
|
|
681
|
-
n.bindings.freeBytes(t, e * 4);
|
|
682
|
-
}
|
|
683
|
-
}
|
|
684
|
-
function es(n) {
|
|
685
|
-
if (n.length === 0) return '';
|
|
686
|
-
try {
|
|
687
|
-
return String.fromCodePoint(...n);
|
|
688
|
-
} catch {
|
|
689
|
-
return '';
|
|
690
|
-
}
|
|
691
|
-
}
|
|
692
|
-
function ts(n) {
|
|
693
|
-
let e = '';
|
|
694
|
-
for (const t of n)
|
|
695
|
-
if (!(t.widthKind === 'spacer-tail' || t.widthKind === 'spacer-head')) {
|
|
696
|
-
if (t.text) {
|
|
697
|
-
e += t.text;
|
|
698
|
-
continue;
|
|
699
|
-
}
|
|
700
|
-
t.widthKind === 'narrow' && (e += ' ');
|
|
701
|
-
}
|
|
702
|
-
return e;
|
|
703
|
-
}
|
|
704
|
-
function ns(n) {
|
|
705
|
-
const e = n.bindings.allocStruct('GhosttyRenderStateColors');
|
|
706
|
-
try {
|
|
707
|
-
n.bindings.setField(
|
|
708
|
-
e.view,
|
|
709
|
-
'GhosttyRenderStateColors',
|
|
710
|
-
'size',
|
|
711
|
-
n.bindings.typeSize('GhosttyRenderStateColors')
|
|
712
|
-
),
|
|
713
|
-
n.bindings.getRenderStateColors(n.renderStateHandle, e.ptr);
|
|
714
|
-
const t = n.bindings.field('GhosttyRenderStateColors', 'palette').offset,
|
|
715
|
-
s = [];
|
|
716
|
-
for (let o = 0; o < 256; o += 1) {
|
|
717
|
-
const l = e.ptr + t + o * 3;
|
|
718
|
-
s.push(Ee(n.bindings, l));
|
|
719
|
-
}
|
|
720
|
-
const r =
|
|
721
|
-
e.view.getUint8(n.bindings.field('GhosttyRenderStateColors', 'cursor_has_value').offset) !==
|
|
722
|
-
0,
|
|
723
|
-
i = fe(n, (o) => n.bindings.getRenderStateValueResult(n.renderStateHandle, kn, o));
|
|
724
|
-
return {
|
|
725
|
-
cols: De(n, (o) => n.bindings.getRenderStateValueResult(n.renderStateHandle, Rn, o)),
|
|
726
|
-
rows: De(n, (o) => n.bindings.getRenderStateValueResult(n.renderStateHandle, Cn, o)),
|
|
727
|
-
dirty: jn(et(n, (o) => n.bindings.getRenderStateValueResult(n.renderStateHandle, vn, o))),
|
|
728
|
-
colors: {
|
|
729
|
-
background: Ee(
|
|
730
|
-
n.bindings,
|
|
731
|
-
e.ptr + n.bindings.field('GhosttyRenderStateColors', 'background').offset
|
|
732
|
-
),
|
|
733
|
-
foreground: Ee(
|
|
734
|
-
n.bindings,
|
|
735
|
-
e.ptr + n.bindings.field('GhosttyRenderStateColors', 'foreground').offset
|
|
736
|
-
),
|
|
737
|
-
cursor: r
|
|
738
|
-
? Ee(n.bindings, e.ptr + n.bindings.field('GhosttyRenderStateColors', 'cursor').offset)
|
|
739
|
-
: null,
|
|
740
|
-
palette: s,
|
|
741
|
-
},
|
|
742
|
-
cursor: {
|
|
743
|
-
style: qn(et(n, (o) => n.bindings.getRenderStateValueResult(n.renderStateHandle, Mn, o))),
|
|
744
|
-
visible: fe(n, (o) => n.bindings.getRenderStateValueResult(n.renderStateHandle, Dn, o)),
|
|
745
|
-
blinking: fe(n, (o) => n.bindings.getRenderStateValueResult(n.renderStateHandle, An, o)),
|
|
746
|
-
passwordInput: fe(n, (o) =>
|
|
747
|
-
n.bindings.getRenderStateValueResult(n.renderStateHandle, On, o)
|
|
748
|
-
),
|
|
749
|
-
x: i
|
|
750
|
-
? De(n, (o) => n.bindings.getRenderStateValueResult(n.renderStateHandle, In, o))
|
|
751
|
-
: null,
|
|
752
|
-
y: i
|
|
753
|
-
? De(n, (o) => n.bindings.getRenderStateValueResult(n.renderStateHandle, Bn, o))
|
|
754
|
-
: null,
|
|
755
|
-
wideTail: i
|
|
756
|
-
? fe(n, (o) => n.bindings.getRenderStateValueResult(n.renderStateHandle, Hn, o))
|
|
757
|
-
: !1,
|
|
758
|
-
},
|
|
759
|
-
};
|
|
760
|
-
} finally {
|
|
761
|
-
e.free();
|
|
762
|
-
}
|
|
763
|
-
}
|
|
764
|
-
function ss(n, e) {
|
|
765
|
-
const t = pt(n, (i) => n.bindings.getRenderStateRowValueResult(n.rowIteratorHandle, Ln, i));
|
|
766
|
-
n.bindings.bindRenderStateRowCells(n.rowIteratorHandle, n.rowCellsHandle);
|
|
767
|
-
const s = [];
|
|
768
|
-
let r = 0;
|
|
769
|
-
while (n.bindings.nextRenderStateRowCell(n.rowCellsHandle)) {
|
|
770
|
-
const i = pt(n, (c) => n.bindings.getRenderStateRowCellValueResult(n.rowCellsHandle, Nn, c)),
|
|
771
|
-
o = Zn(n),
|
|
772
|
-
l = Xn(et(n, (c) => n.bindings.getRawCellValueResult(i, Kn, c))),
|
|
773
|
-
u = {
|
|
774
|
-
x: r,
|
|
775
|
-
text: es(o),
|
|
776
|
-
codepoints: o,
|
|
777
|
-
widthKind: l,
|
|
778
|
-
hasText: fe(n, (c) => n.bindings.getRawCellValueResult(i, Wn, c)),
|
|
779
|
-
style: Qn(n),
|
|
780
|
-
fgColor: mt(n, (c) => n.bindings.getRenderStateRowCellValueResult(n.rowCellsHandle, Yn, c)),
|
|
781
|
-
bgColor: mt(n, (c) => n.bindings.getRenderStateRowCellValueResult(n.rowCellsHandle, zn, c)),
|
|
782
|
-
};
|
|
783
|
-
s.push(u), (r += 1);
|
|
784
|
-
}
|
|
785
|
-
return {
|
|
786
|
-
y: e,
|
|
787
|
-
dirty: fe(n, (i) => n.bindings.getRenderStateRowValueResult(n.rowIteratorHandle, Pn, i)),
|
|
788
|
-
wrap: fe(n, (i) => n.bindings.getRawRowValueResult(t, Vn, i)),
|
|
789
|
-
wrapContinuation: fe(n, (i) => n.bindings.getRawRowValueResult(t, $n, i)),
|
|
790
|
-
text: ts(s),
|
|
791
|
-
cells: s,
|
|
792
|
-
};
|
|
793
|
-
}
|
|
794
|
-
function wt(n) {
|
|
795
|
-
return {
|
|
796
|
-
bindings: n,
|
|
797
|
-
renderStateHandle: n.createRenderState(),
|
|
798
|
-
rowIteratorHandle: n.createRenderStateRowIterator(),
|
|
799
|
-
rowCellsHandle: n.createRenderStateRowCells(),
|
|
800
|
-
snapshotVersion: 0,
|
|
801
|
-
disposed: !1,
|
|
802
|
-
cachedMeta: null,
|
|
803
|
-
};
|
|
804
|
-
}
|
|
805
|
-
function gt(n, e) {
|
|
806
|
-
lt(n),
|
|
807
|
-
n.bindings.updateRenderState(n.renderStateHandle, e),
|
|
808
|
-
n.bindings.bindRenderStateRowIterator(n.renderStateHandle, n.rowIteratorHandle),
|
|
809
|
-
(n.snapshotVersion += 1),
|
|
810
|
-
(n.cachedMeta = null);
|
|
811
|
-
}
|
|
812
|
-
function tt(n) {
|
|
813
|
-
return lt(n), n.cachedMeta || (n.cachedMeta = ns(n)), n.cachedMeta;
|
|
814
|
-
}
|
|
815
|
-
function* rs(n) {
|
|
816
|
-
lt(n);
|
|
817
|
-
const e = tt(n);
|
|
818
|
-
n.bindings.bindRenderStateRowIterator(n.renderStateHandle, n.rowIteratorHandle);
|
|
819
|
-
let t = 0;
|
|
820
|
-
while (t < e.rows && n.bindings.nextRenderStateRowIterator(n.rowIteratorHandle))
|
|
821
|
-
yield ss(n, t), (t += 1);
|
|
822
|
-
}
|
|
823
|
-
function qe(n) {
|
|
824
|
-
n.disposed ||
|
|
825
|
-
((n.disposed = !0),
|
|
826
|
-
n.rowCellsHandle !== 0 &&
|
|
827
|
-
(n.bindings.freeRenderStateRowCells(n.rowCellsHandle), (n.rowCellsHandle = 0)),
|
|
828
|
-
n.rowIteratorHandle !== 0 &&
|
|
829
|
-
(n.bindings.freeRenderStateRowIterator(n.rowIteratorHandle), (n.rowIteratorHandle = 0)),
|
|
830
|
-
n.renderStateHandle !== 0 &&
|
|
831
|
-
(n.bindings.freeRenderState(n.renderStateHandle), (n.renderStateHandle = 0)),
|
|
832
|
-
(n.cachedMeta = null));
|
|
833
|
-
}
|
|
834
|
-
function at(n, e) {
|
|
835
|
-
return Math.max(0, Math.min(Math.max(n.length - 1, 0), Math.floor(e)));
|
|
836
|
-
}
|
|
837
|
-
function is(n, e) {
|
|
838
|
-
return n.line < e.line
|
|
839
|
-
? { start: n, end: e }
|
|
840
|
-
: n.line > e.line
|
|
841
|
-
? { start: e, end: n }
|
|
842
|
-
: n.col <= e.col
|
|
843
|
-
? { start: n, end: e }
|
|
844
|
-
: { start: e, end: n };
|
|
845
|
-
}
|
|
846
|
-
function os(n, e, t) {
|
|
847
|
-
if (!t) return { start: { line: n, col: 0 }, end: { line: n, col: 0 } };
|
|
848
|
-
const s = at(t, e),
|
|
849
|
-
r = (u) => /[\p{L}\p{N}_-]/u.test(u),
|
|
850
|
-
i = t[s] ?? '';
|
|
851
|
-
if (!r(i)) return { start: { line: n, col: s }, end: { line: n, col: s } };
|
|
852
|
-
let o = s,
|
|
853
|
-
l = s;
|
|
854
|
-
while (o > 0 && r(t[o - 1] ?? '')) o -= 1;
|
|
855
|
-
while (l + 1 < t.length && r(t[l + 1] ?? '')) l += 1;
|
|
856
|
-
return { start: { line: n, col: o }, end: { line: n, col: l } };
|
|
857
|
-
}
|
|
858
|
-
function At(n, e) {
|
|
859
|
-
const t = Math.max(e.length - 1, 0);
|
|
860
|
-
return { start: { line: n, col: 0 }, end: { line: n, col: t } };
|
|
861
|
-
}
|
|
862
|
-
function Ot(n, e, t) {
|
|
863
|
-
const s = t(n.line);
|
|
864
|
-
switch (e) {
|
|
865
|
-
case 'word':
|
|
866
|
-
return os(n.line, n.col, s);
|
|
867
|
-
case 'line':
|
|
868
|
-
return At(n.line, s);
|
|
869
|
-
default: {
|
|
870
|
-
const r = at(s, n.col);
|
|
871
|
-
return { start: { line: n.line, col: r }, end: { line: n.line, col: r } };
|
|
872
|
-
}
|
|
873
|
-
}
|
|
874
|
-
}
|
|
875
|
-
function kt() {
|
|
876
|
-
return { anchor: null, focus: null, mode: 'character' };
|
|
877
|
-
}
|
|
878
|
-
function ls(n) {
|
|
879
|
-
return !!(n.anchor && n.focus);
|
|
880
|
-
}
|
|
881
|
-
function as() {
|
|
882
|
-
return kt();
|
|
883
|
-
}
|
|
884
|
-
function cs(n, e, t) {
|
|
885
|
-
const s = Ot(e, e.mode, t);
|
|
886
|
-
return { anchor: s.start, focus: s.end, mode: e.mode };
|
|
887
|
-
}
|
|
888
|
-
function yt(n, e, t) {
|
|
889
|
-
return n.anchor
|
|
890
|
-
? n.mode === 'line'
|
|
891
|
-
? { ...n, focus: At(e.line, t(e.line)).end }
|
|
892
|
-
: n.mode === 'word'
|
|
893
|
-
? { ...n, focus: Ot(e, 'word', t).end }
|
|
894
|
-
: { ...n, focus: { line: e.line, col: at(t(e.line), e.col) } }
|
|
895
|
-
: n;
|
|
896
|
-
}
|
|
897
|
-
function It(n) {
|
|
898
|
-
return !n.anchor || !n.focus ? null : is(n.anchor, n.focus);
|
|
899
|
-
}
|
|
900
|
-
function ds(n, e) {
|
|
901
|
-
const t = It(n);
|
|
902
|
-
if (!t) return null;
|
|
903
|
-
const s = [];
|
|
904
|
-
for (let r = t.start.line; r <= t.end.line; r += 1) {
|
|
905
|
-
const i = e(r);
|
|
906
|
-
if (r === t.start.line && r === t.end.line) {
|
|
907
|
-
s.push(i.slice(t.start.col, t.end.col + 1));
|
|
908
|
-
continue;
|
|
909
|
-
}
|
|
910
|
-
if (r === t.start.line) {
|
|
911
|
-
s.push(i.slice(t.start.col));
|
|
912
|
-
continue;
|
|
913
|
-
}
|
|
914
|
-
if (r === t.end.line) {
|
|
915
|
-
s.push(i.slice(0, t.end.col + 1));
|
|
916
|
-
continue;
|
|
917
|
-
}
|
|
918
|
-
s.push(i);
|
|
919
|
-
}
|
|
920
|
-
return s.join(`
|
|
921
|
-
`);
|
|
922
|
-
}
|
|
923
|
-
function us(n, e, t, s) {
|
|
924
|
-
const r = It(n);
|
|
925
|
-
if (!r) return [];
|
|
926
|
-
const i = e + t - 1,
|
|
927
|
-
o = [];
|
|
928
|
-
for (let l = Math.max(r.start.line, e); l <= Math.min(r.end.line, i); l += 1) {
|
|
929
|
-
const u = l - e;
|
|
930
|
-
if (l === r.start.line && l === r.end.line) {
|
|
931
|
-
o.push({ row: u, x: r.start.col, width: r.end.col - r.start.col + 1 });
|
|
932
|
-
continue;
|
|
933
|
-
}
|
|
934
|
-
if (l === r.start.line) {
|
|
935
|
-
const y = s ? Math.max(s(l).length - r.start.col, 0) : Number.MAX_SAFE_INTEGER;
|
|
936
|
-
o.push({ row: u, x: r.start.col, width: y });
|
|
937
|
-
continue;
|
|
938
|
-
}
|
|
939
|
-
if (l === r.end.line) {
|
|
940
|
-
o.push({ row: u, x: 0, width: r.end.col + 1 });
|
|
941
|
-
continue;
|
|
942
|
-
}
|
|
943
|
-
const c = s ? s(l).length : Number.MAX_SAFE_INTEGER;
|
|
944
|
-
o.push({ row: u, x: 0, width: c });
|
|
945
|
-
}
|
|
946
|
-
return o;
|
|
947
|
-
}
|
|
948
|
-
function hs(n) {
|
|
949
|
-
return (n.metaKey || n.ctrlKey) && !n.altKey;
|
|
950
|
-
}
|
|
951
|
-
function fs(n) {
|
|
952
|
-
return hs(n) && n.key.toLowerCase() === 'c';
|
|
953
|
-
}
|
|
954
|
-
async function ms(n) {
|
|
955
|
-
var e;
|
|
956
|
-
n &&
|
|
957
|
-
typeof navigator < 'u' &&
|
|
958
|
-
(e = navigator.clipboard) != null &&
|
|
959
|
-
e.writeText &&
|
|
960
|
-
(await navigator.clipboard.writeText(n));
|
|
961
|
-
}
|
|
962
|
-
function ps(n, e) {
|
|
963
|
-
return !e || !n.clipboardData
|
|
964
|
-
? !1
|
|
965
|
-
: (n.clipboardData.setData('text/plain', e), n.preventDefault(), !0);
|
|
966
|
-
}
|
|
967
|
-
const ws = '/assets/ghostty-vt-BKQMf-5X.wasm',
|
|
968
|
-
Be = 0,
|
|
969
|
-
St = -3,
|
|
970
|
-
gs = 11,
|
|
971
|
-
ys = 12,
|
|
972
|
-
Ss = 13,
|
|
973
|
-
_s = 14,
|
|
974
|
-
Ts = 1,
|
|
975
|
-
bs = 2,
|
|
976
|
-
xs = 9,
|
|
977
|
-
Es = 1,
|
|
978
|
-
Rs = 0,
|
|
979
|
-
Cs = 1,
|
|
980
|
-
vs = 2,
|
|
981
|
-
Ms = 0,
|
|
982
|
-
Ds = 1,
|
|
983
|
-
As = 2,
|
|
984
|
-
Os = 4,
|
|
985
|
-
ks = 2004,
|
|
986
|
-
Is = 9,
|
|
987
|
-
Bs = 1e3,
|
|
988
|
-
Hs = 1002,
|
|
989
|
-
Ps = 1003,
|
|
990
|
-
Ls = 1005,
|
|
991
|
-
_t = 1006,
|
|
992
|
-
Ns = 1015,
|
|
993
|
-
Tt = 1016;
|
|
994
|
-
let Xe = null;
|
|
995
|
-
function I(n, e) {
|
|
996
|
-
if (n !== Be) throw new Error(`${e} failed with result ${n}`);
|
|
997
|
-
}
|
|
998
|
-
function Bt(n) {
|
|
999
|
-
const e = n.trim().replace(/^#/, '');
|
|
1000
|
-
if (e.length !== 6) throw new Error(`expected #RRGGBB color, received: ${n}`);
|
|
1001
|
-
return [
|
|
1002
|
-
Number.parseInt(e.slice(0, 2), 16),
|
|
1003
|
-
Number.parseInt(e.slice(2, 4), 16),
|
|
1004
|
-
Number.parseInt(e.slice(4, 6), 16),
|
|
1005
|
-
];
|
|
1006
|
-
}
|
|
1007
|
-
function Fs(n) {
|
|
1008
|
-
const t = [
|
|
1009
|
-
...[
|
|
1010
|
-
n.black,
|
|
1011
|
-
n.red,
|
|
1012
|
-
n.green,
|
|
1013
|
-
n.yellow,
|
|
1014
|
-
n.blue,
|
|
1015
|
-
n.magenta,
|
|
1016
|
-
n.cyan,
|
|
1017
|
-
n.white,
|
|
1018
|
-
n.brightBlack,
|
|
1019
|
-
n.brightRed,
|
|
1020
|
-
n.brightGreen,
|
|
1021
|
-
n.brightYellow,
|
|
1022
|
-
n.brightBlue,
|
|
1023
|
-
n.brightMagenta,
|
|
1024
|
-
n.brightCyan,
|
|
1025
|
-
n.brightWhite,
|
|
1026
|
-
].map(Bt),
|
|
1027
|
-
],
|
|
1028
|
-
s = [0, 95, 135, 175, 215, 255];
|
|
1029
|
-
for (const r of s) for (const i of s) for (const o of s) t.push([r, i, o]);
|
|
1030
|
-
for (let r = 0; r < 24; r += 1) {
|
|
1031
|
-
const i = 8 + r * 10;
|
|
1032
|
-
t.push([i, i, i]);
|
|
1033
|
-
}
|
|
1034
|
-
return t;
|
|
1035
|
-
}
|
|
1036
|
-
function Gs(n) {
|
|
1037
|
-
let e = 0;
|
|
1038
|
-
return n & 1 && (e += 4), n & 4 && (e += 8), n & 2 && (e += 16), e;
|
|
1039
|
-
}
|
|
1040
|
-
function Je(n) {
|
|
1041
|
-
return n < 0 || n > 223 ? null : String.fromCharCode(n + 32);
|
|
1042
|
-
}
|
|
1043
|
-
function Us(n) {
|
|
1044
|
-
switch (n) {
|
|
1045
|
-
case 1:
|
|
1046
|
-
return 0;
|
|
1047
|
-
case 3:
|
|
1048
|
-
return 1;
|
|
1049
|
-
case 2:
|
|
1050
|
-
return 2;
|
|
1051
|
-
case 4:
|
|
1052
|
-
return 64;
|
|
1053
|
-
case 5:
|
|
1054
|
-
return 65;
|
|
1055
|
-
case 6:
|
|
1056
|
-
return 66;
|
|
1057
|
-
case 7:
|
|
1058
|
-
return 67;
|
|
1059
|
-
case 8:
|
|
1060
|
-
return 128;
|
|
1061
|
-
case 9:
|
|
1062
|
-
return 129;
|
|
1063
|
-
case null:
|
|
1064
|
-
case void 0:
|
|
1065
|
-
return 3;
|
|
1066
|
-
default:
|
|
1067
|
-
return null;
|
|
1068
|
-
}
|
|
1069
|
-
}
|
|
1070
|
-
function Ht(n) {
|
|
1071
|
-
var t, s;
|
|
1072
|
-
let e = 0;
|
|
1073
|
-
return (
|
|
1074
|
-
n.shiftKey && (e |= 1),
|
|
1075
|
-
n.ctrlKey && (e |= 2),
|
|
1076
|
-
n.altKey && (e |= 4),
|
|
1077
|
-
n.metaKey && (e |= 8),
|
|
1078
|
-
(t = n.getModifierState) != null && t.call(n, 'CapsLock') && (e |= 16),
|
|
1079
|
-
(s = n.getModifierState) != null && s.call(n, 'NumLock') && (e |= 32),
|
|
1080
|
-
e
|
|
1081
|
-
);
|
|
1082
|
-
}
|
|
1083
|
-
class zs {
|
|
1084
|
-
constructor(e, t, s) {
|
|
1085
|
-
(this.bindings = e), (this.typeName = t), (this.ptr = s);
|
|
1086
|
-
}
|
|
1087
|
-
get view() {
|
|
1088
|
-
return this.bindings.view(this.ptr, this.bindings.typeSize(this.typeName));
|
|
1089
|
-
}
|
|
1090
|
-
free() {
|
|
1091
|
-
this.bindings.freeBytes(this.ptr, this.bindings.typeSize(this.typeName));
|
|
1092
|
-
}
|
|
1093
|
-
}
|
|
1094
|
-
class Ys {
|
|
1095
|
-
constructor(e, t) {
|
|
1096
|
-
w(this, 'exports');
|
|
1097
|
-
w(this, 'layout');
|
|
1098
|
-
w(this, 'decoder', new TextDecoder());
|
|
1099
|
-
w(this, 'encoder', new TextEncoder());
|
|
1100
|
-
(this.exports = e), (this.layout = t);
|
|
1101
|
-
}
|
|
1102
|
-
buffer() {
|
|
1103
|
-
return this.exports.memory.buffer;
|
|
1104
|
-
}
|
|
1105
|
-
bytes(e = 0, t = this.buffer().byteLength - e) {
|
|
1106
|
-
return new Uint8Array(this.buffer(), e, t);
|
|
1107
|
-
}
|
|
1108
|
-
view(e = 0, t = this.buffer().byteLength - e) {
|
|
1109
|
-
return new DataView(this.buffer(), e, t);
|
|
1110
|
-
}
|
|
1111
|
-
typeSize(e) {
|
|
1112
|
-
const t = this.layout[e];
|
|
1113
|
-
if (!t) throw new Error(`unknown ghostty type: ${e}`);
|
|
1114
|
-
return t.size;
|
|
1115
|
-
}
|
|
1116
|
-
field(e, t) {
|
|
1117
|
-
const s = this.layout[e],
|
|
1118
|
-
r = s == null ? void 0 : s.fields[t];
|
|
1119
|
-
if (!s || !r) throw new Error(`unknown ghostty field: ${e}.${t}`);
|
|
1120
|
-
return r;
|
|
1121
|
-
}
|
|
1122
|
-
allocStruct(e) {
|
|
1123
|
-
const t = this.allocBytes(this.typeSize(e));
|
|
1124
|
-
return this.bytes(t, this.typeSize(e)).fill(0), new zs(this, e, t);
|
|
1125
|
-
}
|
|
1126
|
-
allocBytes(e) {
|
|
1127
|
-
return this.exports.ghostty_wasm_alloc_u8_array(e);
|
|
1128
|
-
}
|
|
1129
|
-
freeBytes(e, t) {
|
|
1130
|
-
this.exports.ghostty_wasm_free_u8_array(e, t);
|
|
1131
|
-
}
|
|
1132
|
-
allocOpaque() {
|
|
1133
|
-
return this.exports.ghostty_wasm_alloc_opaque();
|
|
1134
|
-
}
|
|
1135
|
-
freeOpaque(e) {
|
|
1136
|
-
this.exports.ghostty_wasm_free_opaque(e);
|
|
1137
|
-
}
|
|
1138
|
-
allocU8() {
|
|
1139
|
-
return this.exports.ghostty_wasm_alloc_u8();
|
|
1140
|
-
}
|
|
1141
|
-
freeU8(e) {
|
|
1142
|
-
this.exports.ghostty_wasm_free_u8(e);
|
|
1143
|
-
}
|
|
1144
|
-
allocUsize() {
|
|
1145
|
-
return this.exports.ghostty_wasm_alloc_usize();
|
|
1146
|
-
}
|
|
1147
|
-
freeUsize(e) {
|
|
1148
|
-
this.exports.ghostty_wasm_free_usize(e);
|
|
1149
|
-
}
|
|
1150
|
-
readPointer(e) {
|
|
1151
|
-
return this.view().getUint32(e, !0);
|
|
1152
|
-
}
|
|
1153
|
-
readU8(e) {
|
|
1154
|
-
return this.view().getUint8(e);
|
|
1155
|
-
}
|
|
1156
|
-
readUsize(e) {
|
|
1157
|
-
return this.view().getUint32(e, !0);
|
|
1158
|
-
}
|
|
1159
|
-
readU64(e) {
|
|
1160
|
-
return this.view().getBigUint64(e, !0);
|
|
1161
|
-
}
|
|
1162
|
-
setField(e, t, s, r) {
|
|
1163
|
-
const i = this.field(t, s),
|
|
1164
|
-
o = i.offset;
|
|
1165
|
-
switch (i.type) {
|
|
1166
|
-
case 'u8':
|
|
1167
|
-
case 'bool':
|
|
1168
|
-
e.setUint8(o, Number(r));
|
|
1169
|
-
return;
|
|
1170
|
-
case 'u16':
|
|
1171
|
-
e.setUint16(o, Number(r), !0);
|
|
1172
|
-
return;
|
|
1173
|
-
case 'u32':
|
|
1174
|
-
e.setUint32(o, Number(r), !0);
|
|
1175
|
-
return;
|
|
1176
|
-
case 'u64':
|
|
1177
|
-
e.setBigUint64(o, BigInt(r), !0);
|
|
1178
|
-
return;
|
|
1179
|
-
case 'usize': {
|
|
1180
|
-
e.setUint32(o, Number(r), !0);
|
|
1181
|
-
return;
|
|
1182
|
-
}
|
|
1183
|
-
case 'i32':
|
|
1184
|
-
case 'enum':
|
|
1185
|
-
e.setInt32(o, Number(r), !0);
|
|
1186
|
-
return;
|
|
1187
|
-
default:
|
|
1188
|
-
throw new Error(`unsupported field type ${t}.${s}: ${i.type}`);
|
|
1189
|
-
}
|
|
1190
|
-
}
|
|
1191
|
-
writeString(e) {
|
|
1192
|
-
const t = this.encoder.encode(e),
|
|
1193
|
-
s = this.allocBytes(t.length);
|
|
1194
|
-
return (
|
|
1195
|
-
this.bytes(s, t.length).set(t),
|
|
1196
|
-
{ ptr: s, len: t.length, free: () => this.freeBytes(s, t.length) }
|
|
1197
|
-
);
|
|
1198
|
-
}
|
|
1199
|
-
writeBytes(e) {
|
|
1200
|
-
const t = this.allocBytes(e.length);
|
|
1201
|
-
return (
|
|
1202
|
-
this.bytes(t, e.length).set(e),
|
|
1203
|
-
{ ptr: t, len: e.length, free: () => this.freeBytes(t, e.length) }
|
|
1204
|
-
);
|
|
1205
|
-
}
|
|
1206
|
-
readOwnedUtf8(e, t) {
|
|
1207
|
-
return this.decoder.decode(this.bytes(e, t));
|
|
1208
|
-
}
|
|
1209
|
-
createTerminal(e, t, s) {
|
|
1210
|
-
const r = this.allocStruct('GhosttyTerminalOptions');
|
|
1211
|
-
this.setField(r.view, 'GhosttyTerminalOptions', 'cols', e),
|
|
1212
|
-
this.setField(r.view, 'GhosttyTerminalOptions', 'rows', t),
|
|
1213
|
-
this.setField(r.view, 'GhosttyTerminalOptions', 'max_scrollback', s);
|
|
1214
|
-
const i = this.allocOpaque();
|
|
1215
|
-
try {
|
|
1216
|
-
return (
|
|
1217
|
-
I(this.exports.ghostty_terminal_new(0, i, r.ptr), 'ghostty_terminal_new'),
|
|
1218
|
-
this.readPointer(i)
|
|
1219
|
-
);
|
|
1220
|
-
} finally {
|
|
1221
|
-
r.free(), this.freeOpaque(i);
|
|
1222
|
-
}
|
|
1223
|
-
}
|
|
1224
|
-
freeTerminal(e) {
|
|
1225
|
-
this.exports.ghostty_terminal_free(e);
|
|
1226
|
-
}
|
|
1227
|
-
writeVt(e, t) {
|
|
1228
|
-
const s = typeof t == 'string' ? this.encoder.encode(t) : t,
|
|
1229
|
-
r = this.writeBytes(s);
|
|
1230
|
-
try {
|
|
1231
|
-
this.exports.ghostty_terminal_vt_write(e, r.ptr, r.len);
|
|
1232
|
-
} finally {
|
|
1233
|
-
r.free();
|
|
1234
|
-
}
|
|
1235
|
-
}
|
|
1236
|
-
resetTerminal(e) {
|
|
1237
|
-
this.exports.ghostty_terminal_reset(e);
|
|
1238
|
-
}
|
|
1239
|
-
resizeTerminal(e, t, s, r) {
|
|
1240
|
-
I(
|
|
1241
|
-
this.exports.ghostty_terminal_resize(
|
|
1242
|
-
e,
|
|
1243
|
-
t,
|
|
1244
|
-
s,
|
|
1245
|
-
Math.max(1, Math.round(r.width)),
|
|
1246
|
-
Math.max(1, Math.round(r.height))
|
|
1247
|
-
),
|
|
1248
|
-
'ghostty_terminal_resize'
|
|
1249
|
-
);
|
|
1250
|
-
}
|
|
1251
|
-
scrollViewportDelta(e, t) {
|
|
1252
|
-
const s = this.allocStruct('GhosttyTerminalScrollViewport');
|
|
1253
|
-
try {
|
|
1254
|
-
this.setField(s.view, 'GhosttyTerminalScrollViewport', 'tag', vs),
|
|
1255
|
-
s.view.setBigInt64(
|
|
1256
|
-
this.field('GhosttyTerminalScrollViewport', 'value').offset,
|
|
1257
|
-
BigInt(t),
|
|
1258
|
-
!0
|
|
1259
|
-
),
|
|
1260
|
-
this.exports.ghostty_terminal_scroll_viewport(e, s.ptr);
|
|
1261
|
-
} finally {
|
|
1262
|
-
s.free();
|
|
1263
|
-
}
|
|
1264
|
-
}
|
|
1265
|
-
scrollViewportTop(e) {
|
|
1266
|
-
const t = this.allocStruct('GhosttyTerminalScrollViewport');
|
|
1267
|
-
try {
|
|
1268
|
-
this.setField(t.view, 'GhosttyTerminalScrollViewport', 'tag', Rs),
|
|
1269
|
-
this.exports.ghostty_terminal_scroll_viewport(e, t.ptr);
|
|
1270
|
-
} finally {
|
|
1271
|
-
t.free();
|
|
1272
|
-
}
|
|
1273
|
-
}
|
|
1274
|
-
scrollViewportBottom(e) {
|
|
1275
|
-
const t = this.allocStruct('GhosttyTerminalScrollViewport');
|
|
1276
|
-
try {
|
|
1277
|
-
this.setField(t.view, 'GhosttyTerminalScrollViewport', 'tag', Cs),
|
|
1278
|
-
this.exports.ghostty_terminal_scroll_viewport(e, t.ptr);
|
|
1279
|
-
} finally {
|
|
1280
|
-
t.free();
|
|
1281
|
-
}
|
|
1282
|
-
}
|
|
1283
|
-
setTerminalTheme(e, t) {
|
|
1284
|
-
const s = this.allocStruct('GhosttyColorRgb'),
|
|
1285
|
-
r = this.allocStruct('GhosttyColorRgb'),
|
|
1286
|
-
i = this.allocStruct('GhosttyColorRgb'),
|
|
1287
|
-
o = Fs(t),
|
|
1288
|
-
l = this.allocBytes(o.length * 3),
|
|
1289
|
-
u = (y, M) => {
|
|
1290
|
-
const [O, P, x] = Bt(M);
|
|
1291
|
-
this.setField(y.view, 'GhosttyColorRgb', 'r', O),
|
|
1292
|
-
this.setField(y.view, 'GhosttyColorRgb', 'g', P),
|
|
1293
|
-
this.setField(y.view, 'GhosttyColorRgb', 'b', x);
|
|
1294
|
-
};
|
|
1295
|
-
u(s, t.foreground), u(r, t.background), u(i, t.cursor);
|
|
1296
|
-
const c = this.bytes(l, o.length * 3);
|
|
1297
|
-
o.forEach(([y, M, O], P) => {
|
|
1298
|
-
const x = P * 3;
|
|
1299
|
-
(c[x] = y), (c[x + 1] = M), (c[x + 2] = O);
|
|
1300
|
-
});
|
|
1301
|
-
try {
|
|
1302
|
-
I(this.exports.ghostty_terminal_set(e, gs, s.ptr), 'ghostty_terminal_set(foreground)'),
|
|
1303
|
-
I(this.exports.ghostty_terminal_set(e, ys, r.ptr), 'ghostty_terminal_set(background)'),
|
|
1304
|
-
I(this.exports.ghostty_terminal_set(e, Ss, i.ptr), 'ghostty_terminal_set(cursor)'),
|
|
1305
|
-
I(this.exports.ghostty_terminal_set(e, _s, l), 'ghostty_terminal_set(palette)');
|
|
1306
|
-
} finally {
|
|
1307
|
-
s.free(), r.free(), i.free(), this.freeBytes(l, o.length * 3);
|
|
1308
|
-
}
|
|
1309
|
-
}
|
|
1310
|
-
readTerminalSize(e) {
|
|
1311
|
-
const t = this.allocBytes(2),
|
|
1312
|
-
s = this.allocBytes(2);
|
|
1313
|
-
try {
|
|
1314
|
-
return (
|
|
1315
|
-
I(this.exports.ghostty_terminal_get(e, Ts, t), 'ghostty_terminal_get(cols)'),
|
|
1316
|
-
I(this.exports.ghostty_terminal_get(e, bs, s), 'ghostty_terminal_get(rows)'),
|
|
1317
|
-
{ cols: this.view().getUint16(t, !0), rows: this.view().getUint16(s, !0) }
|
|
1318
|
-
);
|
|
1319
|
-
} finally {
|
|
1320
|
-
this.freeBytes(t, 2), this.freeBytes(s, 2);
|
|
1321
|
-
}
|
|
1322
|
-
}
|
|
1323
|
-
readScrollbar(e) {
|
|
1324
|
-
const t = this.allocStruct('GhosttyTerminalScrollbar');
|
|
1325
|
-
try {
|
|
1326
|
-
return (
|
|
1327
|
-
I(this.exports.ghostty_terminal_get(e, xs, t.ptr), 'ghostty_terminal_get(scrollbar)'),
|
|
1328
|
-
{
|
|
1329
|
-
total: Number(
|
|
1330
|
-
t.view.getBigUint64(this.field('GhosttyTerminalScrollbar', 'total').offset, !0)
|
|
1331
|
-
),
|
|
1332
|
-
offset: Number(
|
|
1333
|
-
t.view.getBigUint64(this.field('GhosttyTerminalScrollbar', 'offset').offset, !0)
|
|
1334
|
-
),
|
|
1335
|
-
len: Number(
|
|
1336
|
-
t.view.getBigUint64(this.field('GhosttyTerminalScrollbar', 'len').offset, !0)
|
|
1337
|
-
),
|
|
1338
|
-
}
|
|
1339
|
-
);
|
|
1340
|
-
} finally {
|
|
1341
|
-
t.free();
|
|
1342
|
-
}
|
|
1343
|
-
}
|
|
1344
|
-
isTerminalModeEnabled(e, t) {
|
|
1345
|
-
const s = this.allocU8();
|
|
1346
|
-
try {
|
|
1347
|
-
return (
|
|
1348
|
-
I(this.exports.ghostty_terminal_mode_get(e, t, s), 'ghostty_terminal_mode_get'),
|
|
1349
|
-
this.readU8(s) !== 0
|
|
1350
|
-
);
|
|
1351
|
-
} finally {
|
|
1352
|
-
this.freeU8(s);
|
|
1353
|
-
}
|
|
1354
|
-
}
|
|
1355
|
-
setTerminalMode(e, t, s) {
|
|
1356
|
-
I(this.exports.ghostty_terminal_mode_set(e, t, s ? 1 : 0), 'ghostty_terminal_mode_set');
|
|
1357
|
-
}
|
|
1358
|
-
createFormatter(e, t, s) {
|
|
1359
|
-
const r = this.allocStruct('GhosttyFormatterTerminalOptions'),
|
|
1360
|
-
i = this.field('GhosttyFormatterTerminalOptions', 'extra').offset,
|
|
1361
|
-
o = this.view(r.ptr + i, this.typeSize('GhosttyFormatterTerminalExtra')),
|
|
1362
|
-
l = this.field('GhosttyFormatterTerminalExtra', 'screen').offset,
|
|
1363
|
-
u = this.view(r.ptr + i + l, this.typeSize('GhosttyFormatterScreenExtra')),
|
|
1364
|
-
c = this.allocOpaque();
|
|
1365
|
-
try {
|
|
1366
|
-
this.setField(
|
|
1367
|
-
r.view,
|
|
1368
|
-
'GhosttyFormatterTerminalOptions',
|
|
1369
|
-
'size',
|
|
1370
|
-
this.typeSize('GhosttyFormatterTerminalOptions')
|
|
1371
|
-
),
|
|
1372
|
-
this.setField(r.view, 'GhosttyFormatterTerminalOptions', 'emit', t),
|
|
1373
|
-
this.setField(r.view, 'GhosttyFormatterTerminalOptions', 'unwrap', s.unwrap),
|
|
1374
|
-
this.setField(r.view, 'GhosttyFormatterTerminalOptions', 'trim', s.trim),
|
|
1375
|
-
this.setField(
|
|
1376
|
-
o,
|
|
1377
|
-
'GhosttyFormatterTerminalExtra',
|
|
1378
|
-
'size',
|
|
1379
|
-
this.typeSize('GhosttyFormatterTerminalExtra')
|
|
1380
|
-
),
|
|
1381
|
-
this.setField(o, 'GhosttyFormatterTerminalExtra', 'palette', s.includePalette),
|
|
1382
|
-
this.setField(
|
|
1383
|
-
u,
|
|
1384
|
-
'GhosttyFormatterScreenExtra',
|
|
1385
|
-
'size',
|
|
1386
|
-
this.typeSize('GhosttyFormatterScreenExtra')
|
|
1387
|
-
);
|
|
1388
|
-
const y = this.field('GhosttyFormatterTerminalOptions', 'selection').offset;
|
|
1389
|
-
return (
|
|
1390
|
-
r.view.setUint32(y, s.selectionPtr ?? 0, !0),
|
|
1391
|
-
I(
|
|
1392
|
-
this.exports.ghostty_formatter_terminal_new(0, c, e, r.ptr),
|
|
1393
|
-
'ghostty_formatter_terminal_new'
|
|
1394
|
-
),
|
|
1395
|
-
this.readPointer(c)
|
|
1396
|
-
);
|
|
1397
|
-
} finally {
|
|
1398
|
-
r.free(), this.freeOpaque(c);
|
|
1399
|
-
}
|
|
1400
|
-
}
|
|
1401
|
-
freeFormatter(e) {
|
|
1402
|
-
this.exports.ghostty_formatter_free(e);
|
|
1403
|
-
}
|
|
1404
|
-
resolveViewportGridRef(e, t, s) {
|
|
1405
|
-
const r = this.allocStruct('GhosttyPoint'),
|
|
1406
|
-
i = this.allocStruct('GhosttyGridRef');
|
|
1407
|
-
try {
|
|
1408
|
-
this.setField(r.view, 'GhosttyPoint', 'tag', Es);
|
|
1409
|
-
const o = this.field('GhosttyPoint', 'value').offset,
|
|
1410
|
-
l = this.view(r.ptr + o, this.typeSize('GhosttyPointCoordinate'));
|
|
1411
|
-
return (
|
|
1412
|
-
this.setField(l, 'GhosttyPointCoordinate', 'x', t),
|
|
1413
|
-
this.setField(l, 'GhosttyPointCoordinate', 'y', s),
|
|
1414
|
-
this.exports.ghostty_terminal_grid_ref(e, r.ptr, i.ptr) !== Be ? (i.free(), null) : i
|
|
1415
|
-
);
|
|
1416
|
-
} finally {
|
|
1417
|
-
r.free();
|
|
1418
|
-
}
|
|
1419
|
-
}
|
|
1420
|
-
createViewportSelection(e, t, s) {
|
|
1421
|
-
const r = Math.max(1, Math.floor(t)),
|
|
1422
|
-
i = Math.max(1, Math.floor(s)),
|
|
1423
|
-
o = this.resolveViewportGridRef(e, 0, 0);
|
|
1424
|
-
if (!o) return null;
|
|
1425
|
-
let l = null;
|
|
1426
|
-
for (let c = i - 1; c >= 0 && ((l = this.resolveViewportGridRef(e, r - 1, c)), !l); c -= 1);
|
|
1427
|
-
if (!l) return o.free(), null;
|
|
1428
|
-
const u = this.allocStruct('GhosttySelection');
|
|
1429
|
-
try {
|
|
1430
|
-
this.setField(u.view, 'GhosttySelection', 'size', this.typeSize('GhosttySelection')),
|
|
1431
|
-
this.setField(u.view, 'GhosttySelection', 'rectangle', !1);
|
|
1432
|
-
const c = this.field('GhosttySelection', 'start').offset,
|
|
1433
|
-
y = this.field('GhosttySelection', 'end').offset;
|
|
1434
|
-
return (
|
|
1435
|
-
this.bytes(u.ptr + c, this.typeSize('GhosttyGridRef')).set(
|
|
1436
|
-
this.bytes(o.ptr, this.typeSize('GhosttyGridRef'))
|
|
1437
|
-
),
|
|
1438
|
-
this.bytes(u.ptr + y, this.typeSize('GhosttyGridRef')).set(
|
|
1439
|
-
this.bytes(l.ptr, this.typeSize('GhosttyGridRef'))
|
|
1440
|
-
),
|
|
1441
|
-
u
|
|
1442
|
-
);
|
|
1443
|
-
} finally {
|
|
1444
|
-
o.free(), l.free();
|
|
1445
|
-
}
|
|
1446
|
-
}
|
|
1447
|
-
formatViewport(e, t, s, r) {
|
|
1448
|
-
const i = this.readTerminalSize(e),
|
|
1449
|
-
o = this.createViewportSelection(
|
|
1450
|
-
e,
|
|
1451
|
-
Math.max(1, Math.min(i.cols, r.cols)),
|
|
1452
|
-
Math.max(1, Math.min(i.rows, r.rows))
|
|
1453
|
-
),
|
|
1454
|
-
l = this.createFormatter(e, t, { ...s, selectionPtr: (o == null ? void 0 : o.ptr) ?? null });
|
|
1455
|
-
try {
|
|
1456
|
-
return this.formatFormatter(l);
|
|
1457
|
-
} finally {
|
|
1458
|
-
this.freeFormatter(l), o == null || o.free();
|
|
1459
|
-
}
|
|
1460
|
-
}
|
|
1461
|
-
formatFormatter(e) {
|
|
1462
|
-
const t = this.allocOpaque(),
|
|
1463
|
-
s = this.allocUsize();
|
|
1464
|
-
try {
|
|
1465
|
-
I(this.exports.ghostty_formatter_format_alloc(e, 0, t, s), 'ghostty_formatter_format_alloc');
|
|
1466
|
-
const r = this.readPointer(t),
|
|
1467
|
-
i = this.readUsize(s),
|
|
1468
|
-
o = this.buffer().byteLength;
|
|
1469
|
-
try {
|
|
1470
|
-
if (i === 0 || r === 0) return '';
|
|
1471
|
-
if (r < 0 || r > o || i > o - r)
|
|
1472
|
-
throw new Error(
|
|
1473
|
-
`ghostty_formatter_format_alloc returned invalid slice ptr=${r} len=${i} mem=${o}`
|
|
1474
|
-
);
|
|
1475
|
-
return this.readOwnedUtf8(r, i);
|
|
1476
|
-
} finally {
|
|
1477
|
-
i > 0 && r !== 0 && this.exports.ghostty_free(0, r, i);
|
|
1478
|
-
}
|
|
1479
|
-
} finally {
|
|
1480
|
-
this.freeOpaque(t), this.freeUsize(s);
|
|
1481
|
-
}
|
|
1482
|
-
}
|
|
1483
|
-
createRenderState() {
|
|
1484
|
-
const e = this.allocOpaque();
|
|
1485
|
-
try {
|
|
1486
|
-
return (
|
|
1487
|
-
I(this.exports.ghostty_render_state_new(0, e), 'ghostty_render_state_new'),
|
|
1488
|
-
this.readPointer(e)
|
|
1489
|
-
);
|
|
1490
|
-
} finally {
|
|
1491
|
-
this.freeOpaque(e);
|
|
1492
|
-
}
|
|
1493
|
-
}
|
|
1494
|
-
freeRenderState(e) {
|
|
1495
|
-
this.exports.ghostty_render_state_free(e);
|
|
1496
|
-
}
|
|
1497
|
-
updateRenderState(e, t) {
|
|
1498
|
-
I(this.exports.ghostty_render_state_update(e, t), 'ghostty_render_state_update');
|
|
1499
|
-
}
|
|
1500
|
-
getRenderStateValueResult(e, t, s) {
|
|
1501
|
-
return this.exports.ghostty_render_state_get(e, t, s);
|
|
1502
|
-
}
|
|
1503
|
-
getRenderStateValue(e, t, s) {
|
|
1504
|
-
I(this.getRenderStateValueResult(e, t, s), 'ghostty_render_state_get');
|
|
1505
|
-
}
|
|
1506
|
-
setRenderStateValue(e, t, s) {
|
|
1507
|
-
I(this.exports.ghostty_render_state_set(e, t, s), 'ghostty_render_state_set');
|
|
1508
|
-
}
|
|
1509
|
-
getRenderStateColors(e, t) {
|
|
1510
|
-
I(this.exports.ghostty_render_state_colors_get(e, t), 'ghostty_render_state_colors_get');
|
|
1511
|
-
}
|
|
1512
|
-
createRenderStateRowIterator() {
|
|
1513
|
-
const e = this.allocOpaque();
|
|
1514
|
-
try {
|
|
1515
|
-
return (
|
|
1516
|
-
I(
|
|
1517
|
-
this.exports.ghostty_render_state_row_iterator_new(0, e),
|
|
1518
|
-
'ghostty_render_state_row_iterator_new'
|
|
1519
|
-
),
|
|
1520
|
-
this.readPointer(e)
|
|
1521
|
-
);
|
|
1522
|
-
} finally {
|
|
1523
|
-
this.freeOpaque(e);
|
|
1524
|
-
}
|
|
1525
|
-
}
|
|
1526
|
-
freeRenderStateRowIterator(e) {
|
|
1527
|
-
this.exports.ghostty_render_state_row_iterator_free(e);
|
|
1528
|
-
}
|
|
1529
|
-
bindRenderStateRowIterator(e, t) {
|
|
1530
|
-
const s = this.allocOpaque();
|
|
1531
|
-
try {
|
|
1532
|
-
this.view(s, 4).setUint32(0, t, !0), this.getRenderStateValue(e, 4, s);
|
|
1533
|
-
} finally {
|
|
1534
|
-
this.freeOpaque(s);
|
|
1535
|
-
}
|
|
1536
|
-
}
|
|
1537
|
-
nextRenderStateRowIterator(e) {
|
|
1538
|
-
return this.exports.ghostty_render_state_row_iterator_next(e) !== 0;
|
|
1539
|
-
}
|
|
1540
|
-
getRenderStateRowValueResult(e, t, s) {
|
|
1541
|
-
return this.exports.ghostty_render_state_row_get(e, t, s);
|
|
1542
|
-
}
|
|
1543
|
-
getRenderStateRowValue(e, t, s) {
|
|
1544
|
-
I(this.getRenderStateRowValueResult(e, t, s), 'ghostty_render_state_row_get');
|
|
1545
|
-
}
|
|
1546
|
-
setRenderStateRowValue(e, t, s) {
|
|
1547
|
-
I(this.exports.ghostty_render_state_row_set(e, t, s), 'ghostty_render_state_row_set');
|
|
1548
|
-
}
|
|
1549
|
-
createRenderStateRowCells() {
|
|
1550
|
-
const e = this.allocOpaque();
|
|
1551
|
-
try {
|
|
1552
|
-
return (
|
|
1553
|
-
I(
|
|
1554
|
-
this.exports.ghostty_render_state_row_cells_new(0, e),
|
|
1555
|
-
'ghostty_render_state_row_cells_new'
|
|
1556
|
-
),
|
|
1557
|
-
this.readPointer(e)
|
|
1558
|
-
);
|
|
1559
|
-
} finally {
|
|
1560
|
-
this.freeOpaque(e);
|
|
1561
|
-
}
|
|
1562
|
-
}
|
|
1563
|
-
freeRenderStateRowCells(e) {
|
|
1564
|
-
this.exports.ghostty_render_state_row_cells_free(e);
|
|
1565
|
-
}
|
|
1566
|
-
bindRenderStateRowCells(e, t) {
|
|
1567
|
-
const s = this.allocOpaque();
|
|
1568
|
-
try {
|
|
1569
|
-
this.view(s, 4).setUint32(0, t, !0), this.getRenderStateRowValue(e, 3, s);
|
|
1570
|
-
} finally {
|
|
1571
|
-
this.freeOpaque(s);
|
|
1572
|
-
}
|
|
1573
|
-
}
|
|
1574
|
-
nextRenderStateRowCell(e) {
|
|
1575
|
-
return this.exports.ghostty_render_state_row_cells_next(e) !== 0;
|
|
1576
|
-
}
|
|
1577
|
-
selectRenderStateRowCell(e, t) {
|
|
1578
|
-
I(
|
|
1579
|
-
this.exports.ghostty_render_state_row_cells_select(e, t),
|
|
1580
|
-
'ghostty_render_state_row_cells_select'
|
|
1581
|
-
);
|
|
1582
|
-
}
|
|
1583
|
-
getRenderStateRowCellValueResult(e, t, s) {
|
|
1584
|
-
return this.exports.ghostty_render_state_row_cells_get(e, t, s);
|
|
1585
|
-
}
|
|
1586
|
-
getRenderStateRowCellValue(e, t, s) {
|
|
1587
|
-
I(this.getRenderStateRowCellValueResult(e, t, s), 'ghostty_render_state_row_cells_get');
|
|
1588
|
-
}
|
|
1589
|
-
getRawRowValueResult(e, t, s) {
|
|
1590
|
-
return this.exports.ghostty_row_get(e, t, s);
|
|
1591
|
-
}
|
|
1592
|
-
getRawRowValue(e, t, s) {
|
|
1593
|
-
I(this.getRawRowValueResult(e, t, s), 'ghostty_row_get');
|
|
1594
|
-
}
|
|
1595
|
-
getRawCellValueResult(e, t, s) {
|
|
1596
|
-
return this.exports.ghostty_cell_get(e, t, s);
|
|
1597
|
-
}
|
|
1598
|
-
getRawCellValue(e, t, s) {
|
|
1599
|
-
I(this.getRawCellValueResult(e, t, s), 'ghostty_cell_get');
|
|
1600
|
-
}
|
|
1601
|
-
createKeyEncoder() {
|
|
1602
|
-
const e = this.allocOpaque();
|
|
1603
|
-
try {
|
|
1604
|
-
return (
|
|
1605
|
-
I(this.exports.ghostty_key_encoder_new(0, e), 'ghostty_key_encoder_new'),
|
|
1606
|
-
this.readPointer(e)
|
|
1607
|
-
);
|
|
1608
|
-
} finally {
|
|
1609
|
-
this.freeOpaque(e);
|
|
1610
|
-
}
|
|
1611
|
-
}
|
|
1612
|
-
freeKeyEncoder(e) {
|
|
1613
|
-
this.exports.ghostty_key_encoder_free(e);
|
|
1614
|
-
}
|
|
1615
|
-
createMouseEncoder() {
|
|
1616
|
-
const e = this.allocOpaque(),
|
|
1617
|
-
t = this.allocU8();
|
|
1618
|
-
try {
|
|
1619
|
-
I(this.exports.ghostty_mouse_encoder_new(0, e), 'ghostty_mouse_encoder_new');
|
|
1620
|
-
const s = this.readPointer(e);
|
|
1621
|
-
return this.view().setUint8(t, 1), this.exports.ghostty_mouse_encoder_setopt(s, Os, t), s;
|
|
1622
|
-
} finally {
|
|
1623
|
-
this.freeU8(t), this.freeOpaque(e);
|
|
1624
|
-
}
|
|
1625
|
-
}
|
|
1626
|
-
freeMouseEncoder(e) {
|
|
1627
|
-
this.exports.ghostty_mouse_encoder_free(e);
|
|
1628
|
-
}
|
|
1629
|
-
resetMouseEncoder(e) {
|
|
1630
|
-
this.exports.ghostty_mouse_encoder_reset(e);
|
|
1631
|
-
}
|
|
1632
|
-
encodeMouseEvent(e, t, s) {
|
|
1633
|
-
const r = this.isTerminalModeEnabled(t, Ps),
|
|
1634
|
-
i = this.isTerminalModeEnabled(t, Hs),
|
|
1635
|
-
o = this.isTerminalModeEnabled(t, Bs),
|
|
1636
|
-
l = this.isTerminalModeEnabled(t, Is);
|
|
1637
|
-
if (
|
|
1638
|
-
(!r && !i && !o && !l) ||
|
|
1639
|
-
(s.action === 'motion' && !(r || (i && s.anyButtonPressed))) ||
|
|
1640
|
-
(l && s.action !== 'press') ||
|
|
1641
|
-
(!r && !i && !l && s.action === 'motion')
|
|
1642
|
-
)
|
|
1643
|
-
return null;
|
|
1644
|
-
const u = Us(s.button);
|
|
1645
|
-
if (u === null) return null;
|
|
1646
|
-
const c = Math.max(1, Math.floor(s.x / Math.max(1, s.cellWidth)) + 1),
|
|
1647
|
-
y = Math.max(1, Math.floor(s.y / Math.max(1, s.cellHeight)) + 1),
|
|
1648
|
-
M = Math.round(s.x + 1),
|
|
1649
|
-
O = Math.round(s.y + 1);
|
|
1650
|
-
let P =
|
|
1651
|
-
s.action === 'release' &&
|
|
1652
|
-
!this.isTerminalModeEnabled(t, _t) &&
|
|
1653
|
-
!this.isTerminalModeEnabled(t, Tt)
|
|
1654
|
-
? 3
|
|
1655
|
-
: u;
|
|
1656
|
-
if (
|
|
1657
|
-
(s.action === 'motion' && (P += 32), (P += Gs(s.mods)), this.isTerminalModeEnabled(t, Tt))
|
|
1658
|
-
) {
|
|
1659
|
-
const x = s.action === 'release' ? 'm' : 'M';
|
|
1660
|
-
return `\x1B[<${P};${M};${O}${x}`;
|
|
1661
|
-
}
|
|
1662
|
-
if (this.isTerminalModeEnabled(t, _t)) {
|
|
1663
|
-
const x = s.action === 'release' ? 'm' : 'M';
|
|
1664
|
-
return `\x1B[<${P};${c};${y}${x}`;
|
|
1665
|
-
}
|
|
1666
|
-
if (this.isTerminalModeEnabled(t, Ns)) return `\x1B[${P};${c};${y}M`;
|
|
1667
|
-
if (this.isTerminalModeEnabled(t, Ls) || o || i || r || l) {
|
|
1668
|
-
const x = Je(P),
|
|
1669
|
-
T = Je(c),
|
|
1670
|
-
g = Je(y);
|
|
1671
|
-
return !x || !T || !g ? null : `\x1B[M${x}${T}${g}`;
|
|
1672
|
-
}
|
|
1673
|
-
return null;
|
|
1674
|
-
}
|
|
1675
|
-
encodeKeyEvent(e, t, s) {
|
|
1676
|
-
if (s.keyCode <= 0) return null;
|
|
1677
|
-
const r = this.allocOpaque();
|
|
1678
|
-
let i = 0,
|
|
1679
|
-
o = null;
|
|
1680
|
-
try {
|
|
1681
|
-
return (
|
|
1682
|
-
I(this.exports.ghostty_key_event_new(0, r), 'ghostty_key_event_new'),
|
|
1683
|
-
(i = this.readPointer(r)),
|
|
1684
|
-
this.exports.ghostty_key_encoder_setopt_from_terminal(e, t),
|
|
1685
|
-
this.exports.ghostty_key_event_set_action(
|
|
1686
|
-
i,
|
|
1687
|
-
s.action === 'release' ? Ms : s.action === 'repeat' ? As : Ds
|
|
1688
|
-
),
|
|
1689
|
-
this.exports.ghostty_key_event_set_key(i, s.keyCode),
|
|
1690
|
-
this.exports.ghostty_key_event_set_mods(i, s.mods),
|
|
1691
|
-
this.exports.ghostty_key_event_set_consumed_mods(i, 0),
|
|
1692
|
-
this.exports.ghostty_key_event_set_composing(i, s.composing ? 1 : 0),
|
|
1693
|
-
s.utf8 &&
|
|
1694
|
-
((o = this.writeString(s.utf8)),
|
|
1695
|
-
this.exports.ghostty_key_event_set_utf8(i, o.ptr, o.len)),
|
|
1696
|
-
typeof s.unshiftedCodepoint == 'number' &&
|
|
1697
|
-
this.exports.ghostty_key_event_set_unshifted_codepoint(i, s.unshiftedCodepoint),
|
|
1698
|
-
this.encodeKeyHandle(e, i)
|
|
1699
|
-
);
|
|
1700
|
-
} finally {
|
|
1701
|
-
o == null || o.free(), i !== 0 && this.exports.ghostty_key_event_free(i), this.freeOpaque(r);
|
|
1702
|
-
}
|
|
1703
|
-
}
|
|
1704
|
-
encodeKeyHandle(e, t) {
|
|
1705
|
-
const s = this.allocUsize();
|
|
1706
|
-
try {
|
|
1707
|
-
const r = this.exports.ghostty_key_encoder_encode(e, t, 0, 0, s);
|
|
1708
|
-
r !== St && r !== Be && I(r, 'ghostty_key_encoder_encode(size)');
|
|
1709
|
-
const i = Math.max(0, this.readUsize(s));
|
|
1710
|
-
if (i === 0) return null;
|
|
1711
|
-
const o = this.allocBytes(i),
|
|
1712
|
-
l = this.allocUsize();
|
|
1713
|
-
try {
|
|
1714
|
-
I(this.exports.ghostty_key_encoder_encode(e, t, o, i, l), 'ghostty_key_encoder_encode');
|
|
1715
|
-
const u = this.readUsize(l);
|
|
1716
|
-
return u === 0 ? null : this.readOwnedUtf8(o, u);
|
|
1717
|
-
} finally {
|
|
1718
|
-
this.freeBytes(o, i), this.freeUsize(l);
|
|
1719
|
-
}
|
|
1720
|
-
} finally {
|
|
1721
|
-
this.freeUsize(s);
|
|
1722
|
-
}
|
|
1723
|
-
}
|
|
1724
|
-
encodePaste(e, t) {
|
|
1725
|
-
const s = this.writeString(t),
|
|
1726
|
-
r = this.allocUsize();
|
|
1727
|
-
try {
|
|
1728
|
-
const i = this.isTerminalModeEnabled(e, ks),
|
|
1729
|
-
o = this.exports.ghostty_paste_encode(s.ptr, s.len, i ? 1 : 0, 0, 0, r);
|
|
1730
|
-
o !== St && o !== Be && I(o, 'ghostty_paste_encode(size)');
|
|
1731
|
-
const l = Math.max(0, this.readUsize(r));
|
|
1732
|
-
if (l === 0) return '';
|
|
1733
|
-
const u = this.allocBytes(l),
|
|
1734
|
-
c = this.allocUsize();
|
|
1735
|
-
try {
|
|
1736
|
-
return (
|
|
1737
|
-
I(
|
|
1738
|
-
this.exports.ghostty_paste_encode(s.ptr, s.len, i ? 1 : 0, u, l, c),
|
|
1739
|
-
'ghostty_paste_encode'
|
|
1740
|
-
),
|
|
1741
|
-
this.readOwnedUtf8(u, this.readUsize(c))
|
|
1742
|
-
);
|
|
1743
|
-
} finally {
|
|
1744
|
-
this.freeBytes(u, l), this.freeUsize(c);
|
|
1745
|
-
}
|
|
1746
|
-
} finally {
|
|
1747
|
-
s.free(), this.freeUsize(r);
|
|
1748
|
-
}
|
|
1749
|
-
}
|
|
1750
|
-
}
|
|
1751
|
-
async function Vs(n) {
|
|
1752
|
-
if (
|
|
1753
|
-
(n.startsWith('/') || n.startsWith('./') || n.startsWith('../') || /^[A-Za-z]:[\\/]/.test(n)) &&
|
|
1754
|
-
typeof Bun < 'u'
|
|
1755
|
-
)
|
|
1756
|
-
return Bun.file(n).arrayBuffer();
|
|
1757
|
-
const t = await fetch(n);
|
|
1758
|
-
if (!t.ok) throw new Error(`failed to load ghostty wasm: ${t.status} ${t.statusText}`);
|
|
1759
|
-
return t.arrayBuffer();
|
|
1760
|
-
}
|
|
1761
|
-
async function $s() {
|
|
1762
|
-
return (
|
|
1763
|
-
Xe ||
|
|
1764
|
-
(Xe = (async () => {
|
|
1765
|
-
const n = await Vs(ws),
|
|
1766
|
-
t = (await WebAssembly.instantiate(n, { env: { log() {} } })).instance.exports,
|
|
1767
|
-
s = new Uint8Array(t.memory.buffer),
|
|
1768
|
-
r = t.ghostty_type_json();
|
|
1769
|
-
let i = r;
|
|
1770
|
-
while (s[i] !== 0) i += 1;
|
|
1771
|
-
const o = JSON.parse(new TextDecoder().decode(s.subarray(r, i)));
|
|
1772
|
-
return new Ys(t, o);
|
|
1773
|
-
})()),
|
|
1774
|
-
Xe
|
|
1775
|
-
);
|
|
1776
|
-
}
|
|
1777
|
-
const bt = 80,
|
|
1778
|
-
Re = 24,
|
|
1779
|
-
Qe = 9,
|
|
1780
|
-
Ae = 17,
|
|
1781
|
-
Ks = 48,
|
|
1782
|
-
Pt = 'ghostty-official',
|
|
1783
|
-
He = 9,
|
|
1784
|
-
Pe = 1e3,
|
|
1785
|
-
Le = 1002,
|
|
1786
|
-
Ne = 1003,
|
|
1787
|
-
Ze = 1007,
|
|
1788
|
-
Oe = 1047,
|
|
1789
|
-
ke = 1049,
|
|
1790
|
-
Ws = [He, Pe, Le, Ne],
|
|
1791
|
-
xt = 1,
|
|
1792
|
-
Et = 3,
|
|
1793
|
-
Rt = 2,
|
|
1794
|
-
js = 4,
|
|
1795
|
-
qs = 5;
|
|
1796
|
-
class Xs {
|
|
1797
|
-
constructor(e) {
|
|
1798
|
-
this.content = e;
|
|
1799
|
-
}
|
|
1800
|
-
translateToString(e) {
|
|
1801
|
-
return e ? this.content.replace(/\s+$/u, '') : this.content;
|
|
1802
|
-
}
|
|
1803
|
-
}
|
|
1804
|
-
class Js {
|
|
1805
|
-
constructor() {
|
|
1806
|
-
w(this, 'active', {
|
|
1807
|
-
baseY: 0,
|
|
1808
|
-
viewportY: 0,
|
|
1809
|
-
length: Re,
|
|
1810
|
-
getLine: (e) => {
|
|
1811
|
-
const t = e - this.active.viewportY,
|
|
1812
|
-
s = this.visibleLines[t];
|
|
1813
|
-
return typeof s == 'string' ? new Xs(s) : null;
|
|
1814
|
-
},
|
|
1815
|
-
});
|
|
1816
|
-
w(
|
|
1817
|
-
this,
|
|
1818
|
-
'visibleLines',
|
|
1819
|
-
Array.from({ length: Re }, () => '')
|
|
1820
|
-
);
|
|
1821
|
-
}
|
|
1822
|
-
setViewport(e, t, s, r) {
|
|
1823
|
-
(this.active.viewportY = e),
|
|
1824
|
-
(this.active.baseY = t),
|
|
1825
|
-
(this.active.length = s),
|
|
1826
|
-
(this.visibleLines = r);
|
|
1827
|
-
}
|
|
1828
|
-
}
|
|
1829
|
-
function Qs(n) {
|
|
1830
|
-
return !(n.key.length === 1 && !n.ctrlKey && !n.altKey && !n.metaKey);
|
|
1831
|
-
}
|
|
1832
|
-
function Zs(n, e) {
|
|
1833
|
-
const t = n.slice(0, e).map((s) => s.text);
|
|
1834
|
-
while (t.length < e) t.push('');
|
|
1835
|
-
return t;
|
|
1836
|
-
}
|
|
1837
|
-
function Ie(n) {
|
|
1838
|
-
return Ht({
|
|
1839
|
-
shiftKey: !!n.shiftKey,
|
|
1840
|
-
ctrlKey: !!n.ctrlKey,
|
|
1841
|
-
altKey: !!n.altKey,
|
|
1842
|
-
metaKey: !!n.metaKey,
|
|
1843
|
-
getModifierState: () => !1,
|
|
1844
|
-
});
|
|
1845
|
-
}
|
|
1846
|
-
class er {
|
|
1847
|
-
constructor() {
|
|
1848
|
-
w(this, 'terminal', null);
|
|
1849
|
-
}
|
|
1850
|
-
activate(e) {
|
|
1851
|
-
this.terminal = e instanceof Ge ? e : null;
|
|
1852
|
-
}
|
|
1853
|
-
fit() {
|
|
1854
|
-
const e = this.proposeDimensions();
|
|
1855
|
-
!this.terminal || !e || this.terminal.resize(e.cols, e.rows);
|
|
1856
|
-
}
|
|
1857
|
-
proposeDimensions() {
|
|
1858
|
-
var e;
|
|
1859
|
-
return ((e = this.terminal) == null ? void 0 : e.measureSizeFromElement()) ?? null;
|
|
1860
|
-
}
|
|
1861
|
-
dispose() {
|
|
1862
|
-
this.terminal = null;
|
|
1863
|
-
}
|
|
1864
|
-
}
|
|
1865
|
-
class Ge {
|
|
1866
|
-
constructor(e, t, s, r, i, o) {
|
|
1867
|
-
w(this, 'buffer', new Js());
|
|
1868
|
-
w(this, '_core', {
|
|
1869
|
-
_renderService: { dimensions: { css: { cell: { width: Qe, height: Ae } } } },
|
|
1870
|
-
});
|
|
1871
|
-
w(this, 'options');
|
|
1872
|
-
w(this, 'element', null);
|
|
1873
|
-
w(this, 'textarea', null);
|
|
1874
|
-
w(this, 'cols', bt);
|
|
1875
|
-
w(this, 'rows', Re);
|
|
1876
|
-
w(this, 'bindings');
|
|
1877
|
-
w(this, 'terminalHandle');
|
|
1878
|
-
w(this, 'keyEncoderHandle');
|
|
1879
|
-
w(this, 'mouseEncoderHandle');
|
|
1880
|
-
w(this, 'renderState');
|
|
1881
|
-
w(this, 'dataListeners', new Set());
|
|
1882
|
-
w(this, 'addons', new Set());
|
|
1883
|
-
w(this, 'screenElement', null);
|
|
1884
|
-
w(this, 'renderer', null);
|
|
1885
|
-
w(this, 'renderRaf', null);
|
|
1886
|
-
w(this, 'disposed', !1);
|
|
1887
|
-
w(this, 'disableStdin');
|
|
1888
|
-
w(this, 'customKeyEventHandler', () => !0);
|
|
1889
|
-
w(this, 'imeIsComposing', !1);
|
|
1890
|
-
w(this, 'lastCompositionCommit', null);
|
|
1891
|
-
w(this, 'selectionState', kt());
|
|
1892
|
-
w(this, 'lineCache', new Map());
|
|
1893
|
-
w(this, 'lastViewportOffset', 0);
|
|
1894
|
-
w(this, 'lastViewportRows', Re);
|
|
1895
|
-
w(this, 'lastRenderedRows', []);
|
|
1896
|
-
w(this, 'pointerDrag', {
|
|
1897
|
-
active: !1,
|
|
1898
|
-
moved: !1,
|
|
1899
|
-
mode: 'character',
|
|
1900
|
-
lastClientX: null,
|
|
1901
|
-
lastClientY: null,
|
|
1902
|
-
});
|
|
1903
|
-
w(this, 'autoScrollTimer', null);
|
|
1904
|
-
w(this, 'domEventDisposers', []);
|
|
1905
|
-
w(this, 'copyShortcutSuppressed', !1);
|
|
1906
|
-
w(this, 'scrollbarThumb', null);
|
|
1907
|
-
w(this, 'scrollbarFadeTimer', null);
|
|
1908
|
-
w(this, 'pressedMouseButtons', new Set());
|
|
1909
|
-
w(this, 'wheelPixelDelta', 0);
|
|
1910
|
-
w(this, 'mouseDragActive', !1);
|
|
1911
|
-
(this.bindings = e),
|
|
1912
|
-
(this.terminalHandle = t),
|
|
1913
|
-
(this.keyEncoderHandle = s),
|
|
1914
|
-
(this.mouseEncoderHandle = r),
|
|
1915
|
-
(this.renderState = i),
|
|
1916
|
-
(this.options = o),
|
|
1917
|
-
(this.disableStdin = !!o.disableStdin);
|
|
1918
|
-
}
|
|
1919
|
-
static async create(e) {
|
|
1920
|
-
const t = await $s(),
|
|
1921
|
-
s = t.createTerminal(bt, Re, e.scrollback);
|
|
1922
|
-
let r = 0,
|
|
1923
|
-
i = 0,
|
|
1924
|
-
o = null;
|
|
1925
|
-
try {
|
|
1926
|
-
return (
|
|
1927
|
-
t.setTerminalTheme(s, e.theme),
|
|
1928
|
-
(r = t.createKeyEncoder()),
|
|
1929
|
-
(i = t.createMouseEncoder()),
|
|
1930
|
-
(o = wt(t)),
|
|
1931
|
-
new Ge(t, s, r, i, o, e)
|
|
1932
|
-
);
|
|
1933
|
-
} catch (l) {
|
|
1934
|
-
throw (
|
|
1935
|
-
(o && qe(o),
|
|
1936
|
-
r !== 0 && t.freeKeyEncoder(r),
|
|
1937
|
-
i !== 0 && t.freeMouseEncoder(i),
|
|
1938
|
-
t.freeTerminal(s),
|
|
1939
|
-
l)
|
|
1940
|
-
);
|
|
1941
|
-
}
|
|
1942
|
-
}
|
|
1943
|
-
open(e) {
|
|
1944
|
-
if (this.disposed || this.element) return;
|
|
1945
|
-
const t = document.createElement('div');
|
|
1946
|
-
(t.className = 'xterm'),
|
|
1947
|
-
(t.style.position = 'absolute'),
|
|
1948
|
-
(t.style.inset = '0'),
|
|
1949
|
-
(t.style.overflow = 'hidden'),
|
|
1950
|
-
(t.style.width = '100%'),
|
|
1951
|
-
(t.style.height = '100%'),
|
|
1952
|
-
(t.style.backgroundColor = this.options.theme.background),
|
|
1953
|
-
(t.style.color = this.options.theme.foreground),
|
|
1954
|
-
(t.style.fontFamily = this.options.fontFamily),
|
|
1955
|
-
(t.style.fontSize = `${this.options.fontSize}px`),
|
|
1956
|
-
(t.style.lineHeight = '1.2');
|
|
1957
|
-
const s = document.createElement('div');
|
|
1958
|
-
(s.className = 'xterm-viewport'),
|
|
1959
|
-
(s.style.width = '100%'),
|
|
1960
|
-
(s.style.height = '100%'),
|
|
1961
|
-
(s.style.overflow = 'hidden'),
|
|
1962
|
-
(s.style.position = 'relative');
|
|
1963
|
-
const r = document.createElement('div');
|
|
1964
|
-
(r.className = 'xterm-screen'),
|
|
1965
|
-
(r.style.width = '100%'),
|
|
1966
|
-
(r.style.height = '100%'),
|
|
1967
|
-
(r.style.position = 'relative'),
|
|
1968
|
-
(r.style.userSelect = 'none'),
|
|
1969
|
-
(r.style.webkitUserSelect = 'none'),
|
|
1970
|
-
(r.style.backgroundColor = this.options.theme.background);
|
|
1971
|
-
const i = document.createElement('div');
|
|
1972
|
-
(i.className = 'xterm-helper-textarea'),
|
|
1973
|
-
i.setAttribute('aria-label', 'Terminal Input'),
|
|
1974
|
-
i.setAttribute('role', 'textbox'),
|
|
1975
|
-
i.setAttribute('contenteditable', 'true'),
|
|
1976
|
-
i.setAttribute('autocorrect', 'off'),
|
|
1977
|
-
i.setAttribute('autocapitalize', 'off'),
|
|
1978
|
-
i.setAttribute('spellcheck', 'false'),
|
|
1979
|
-
(i.style.position = 'absolute'),
|
|
1980
|
-
(i.style.opacity = '1'),
|
|
1981
|
-
(i.style.pointerEvents = 'none'),
|
|
1982
|
-
(i.style.left = '0'),
|
|
1983
|
-
(i.style.top = '0'),
|
|
1984
|
-
(i.style.minWidth = '1px'),
|
|
1985
|
-
(i.style.minHeight = '1px'),
|
|
1986
|
-
(i.style.whiteSpace = 'pre'),
|
|
1987
|
-
(i.style.border = '0'),
|
|
1988
|
-
(i.style.padding = '0'),
|
|
1989
|
-
(i.style.margin = '0'),
|
|
1990
|
-
(i.style.color = this.options.theme.foreground),
|
|
1991
|
-
(i.style.backgroundColor = 'transparent'),
|
|
1992
|
-
(i.style.caretColor = 'transparent'),
|
|
1993
|
-
(i.style.overflow = 'visible'),
|
|
1994
|
-
(i.style.outline = 'none'),
|
|
1995
|
-
(i.style.boxShadow = 'none'),
|
|
1996
|
-
(i.style.fontFamily = this.options.fontFamily),
|
|
1997
|
-
(i.style.fontSize = `${this.options.fontSize}px`),
|
|
1998
|
-
(i.style.userSelect = 'text'),
|
|
1999
|
-
(i.style.webkitUserSelect = 'text');
|
|
2000
|
-
const o = document.createElement('div');
|
|
2001
|
-
(o.className = 'xterm-scrollbar-track'),
|
|
2002
|
-
(o.style.position = 'absolute'),
|
|
2003
|
-
(o.style.top = '0'),
|
|
2004
|
-
(o.style.right = '0'),
|
|
2005
|
-
(o.style.width = '8px'),
|
|
2006
|
-
(o.style.height = '100%'),
|
|
2007
|
-
(o.style.backgroundColor = 'transparent'),
|
|
2008
|
-
(o.style.pointerEvents = 'none');
|
|
2009
|
-
const l = document.createElement('div');
|
|
2010
|
-
(l.className = 'xterm-scrollbar-thumb'),
|
|
2011
|
-
(l.style.position = 'absolute'),
|
|
2012
|
-
(l.style.top = '0'),
|
|
2013
|
-
(l.style.right = '0'),
|
|
2014
|
-
(l.style.width = '6px'),
|
|
2015
|
-
(l.style.marginRight = '1px'),
|
|
2016
|
-
(l.style.borderRadius = '3px'),
|
|
2017
|
-
(l.style.backgroundColor = 'rgba(128, 128, 128, 0.5)'),
|
|
2018
|
-
(l.style.pointerEvents = 'none'),
|
|
2019
|
-
(l.style.transition = 'opacity 0.15s ease'),
|
|
2020
|
-
(l.style.opacity = '0'),
|
|
2021
|
-
o.appendChild(l),
|
|
2022
|
-
s.appendChild(r),
|
|
2023
|
-
t.appendChild(s),
|
|
2024
|
-
t.appendChild(i),
|
|
2025
|
-
t.appendChild(o),
|
|
2026
|
-
e.appendChild(t),
|
|
2027
|
-
(this.element = t),
|
|
2028
|
-
(this.screenElement = r),
|
|
2029
|
-
(this.textarea = i),
|
|
2030
|
-
(this.scrollbarThumb = l),
|
|
2031
|
-
(this.renderer = new _n({
|
|
2032
|
-
screenElement: r,
|
|
2033
|
-
theme: this.options.theme,
|
|
2034
|
-
fontFamily: this.options.fontFamily,
|
|
2035
|
-
fontSize: this.options.fontSize,
|
|
2036
|
-
})),
|
|
2037
|
-
this.syncInputState(),
|
|
2038
|
-
this.bindDomEvents(),
|
|
2039
|
-
this.updateCellDimensions();
|
|
2040
|
-
const u = this.measureSizeFromElement();
|
|
2041
|
-
u ? this.resize(u.cols, u.rows) : this.render();
|
|
2042
|
-
}
|
|
2043
|
-
loadAddon(e) {
|
|
2044
|
-
e.activate(this), this.addons.add(e);
|
|
2045
|
-
}
|
|
2046
|
-
onData(e) {
|
|
2047
|
-
return (
|
|
2048
|
-
this.dataListeners.add(e),
|
|
2049
|
-
{
|
|
2050
|
-
dispose: () => {
|
|
2051
|
-
this.dataListeners.delete(e);
|
|
2052
|
-
},
|
|
2053
|
-
}
|
|
2054
|
-
);
|
|
2055
|
-
}
|
|
2056
|
-
attachCustomKeyEventHandler(e) {
|
|
2057
|
-
this.customKeyEventHandler = e;
|
|
2058
|
-
}
|
|
2059
|
-
write(e) {
|
|
2060
|
-
if (this.disposed) return;
|
|
2061
|
-
const t = this.isAltScreenActive();
|
|
2062
|
-
this.bindings.writeVt(this.terminalHandle, e);
|
|
2063
|
-
const s = this.isAltScreenActive();
|
|
2064
|
-
t && !s && this.clearMouseTrackingModes(), this.scheduleRender();
|
|
2065
|
-
}
|
|
2066
|
-
clearMouseTrackingModes() {
|
|
2067
|
-
if (!this.disposed) {
|
|
2068
|
-
for (const e of Ws) this.bindings.setTerminalMode(this.terminalHandle, e, !1);
|
|
2069
|
-
this.bindings.resetMouseEncoder(this.mouseEncoderHandle),
|
|
2070
|
-
this.pressedMouseButtons.clear(),
|
|
2071
|
-
(this.mouseDragActive = !1);
|
|
2072
|
-
}
|
|
2073
|
-
}
|
|
2074
|
-
isAltScreenActive() {
|
|
2075
|
-
return this.isModeEnabled(Oe) || this.isModeEnabled(ke);
|
|
2076
|
-
}
|
|
2077
|
-
reset() {
|
|
2078
|
-
this.disposed ||
|
|
2079
|
-
(this.lineCache.clear(),
|
|
2080
|
-
this.clearSelectionState(!1),
|
|
2081
|
-
this.bindings.resetTerminal(this.terminalHandle),
|
|
2082
|
-
this.scheduleRender());
|
|
2083
|
-
}
|
|
2084
|
-
refresh() {
|
|
2085
|
-
this.disposed || this.render();
|
|
2086
|
-
}
|
|
2087
|
-
resize(e, t) {
|
|
2088
|
-
if (this.disposed) return;
|
|
2089
|
-
const s = Math.max(2, Math.floor(e)),
|
|
2090
|
-
r = Math.max(2, Math.floor(t));
|
|
2091
|
-
(this.cols = s),
|
|
2092
|
-
(this.rows = r),
|
|
2093
|
-
this.clearSelectionState(!1),
|
|
2094
|
-
this.bindings.resizeTerminal(this.terminalHandle, s, r, this.cellDimensions()),
|
|
2095
|
-
this.bindings.resetMouseEncoder(this.mouseEncoderHandle),
|
|
2096
|
-
this.scheduleRender();
|
|
2097
|
-
}
|
|
2098
|
-
scrollLines(e) {
|
|
2099
|
-
this.disposed ||
|
|
2100
|
-
e === 0 ||
|
|
2101
|
-
(this.bindings.scrollViewportDelta(this.terminalHandle, e), this.render());
|
|
2102
|
-
}
|
|
2103
|
-
scrollToTop() {
|
|
2104
|
-
this.disposed || (this.bindings.scrollViewportTop(this.terminalHandle), this.render());
|
|
2105
|
-
}
|
|
2106
|
-
scrollToBottom() {
|
|
2107
|
-
this.disposed || (this.bindings.scrollViewportBottom(this.terminalHandle), this.render());
|
|
2108
|
-
}
|
|
2109
|
-
exportModeSnapshot() {
|
|
2110
|
-
return {
|
|
2111
|
-
mouseX10: this.isModeEnabled(He),
|
|
2112
|
-
mouseNormal: this.isModeEnabled(Pe),
|
|
2113
|
-
mouseButton: this.isModeEnabled(Le),
|
|
2114
|
-
mouseAny: this.isModeEnabled(Ne),
|
|
2115
|
-
mouseUtf8: this.isModeEnabled(1005),
|
|
2116
|
-
mouseSgr: this.isModeEnabled(1006),
|
|
2117
|
-
mouseSgrPixels: this.isModeEnabled(1016),
|
|
2118
|
-
mouseUrxvt: this.isModeEnabled(1015),
|
|
2119
|
-
altScroll: this.isModeEnabled(Ze),
|
|
2120
|
-
altScreen1047: this.isModeEnabled(Oe),
|
|
2121
|
-
altScreen1049: this.isModeEnabled(ke),
|
|
2122
|
-
};
|
|
2123
|
-
}
|
|
2124
|
-
restoreModeSnapshot(e) {
|
|
2125
|
-
this.bindings.setTerminalMode(this.terminalHandle, He, e.mouseX10),
|
|
2126
|
-
this.bindings.setTerminalMode(this.terminalHandle, Pe, e.mouseNormal),
|
|
2127
|
-
this.bindings.setTerminalMode(this.terminalHandle, Le, e.mouseButton),
|
|
2128
|
-
this.bindings.setTerminalMode(this.terminalHandle, Ne, e.mouseAny),
|
|
2129
|
-
this.bindings.setTerminalMode(this.terminalHandle, 1005, e.mouseUtf8),
|
|
2130
|
-
this.bindings.setTerminalMode(this.terminalHandle, 1006, e.mouseSgr),
|
|
2131
|
-
this.bindings.setTerminalMode(this.terminalHandle, 1016, e.mouseSgrPixels),
|
|
2132
|
-
this.bindings.setTerminalMode(this.terminalHandle, 1015, e.mouseUrxvt),
|
|
2133
|
-
this.bindings.setTerminalMode(this.terminalHandle, Ze, e.altScroll),
|
|
2134
|
-
this.bindings.setTerminalMode(this.terminalHandle, Oe, e.altScreen1047),
|
|
2135
|
-
this.bindings.setTerminalMode(this.terminalHandle, ke, e.altScreen1049),
|
|
2136
|
-
this.bindings.resetMouseEncoder(this.mouseEncoderHandle);
|
|
2137
|
-
}
|
|
2138
|
-
handleViewportGesture(e) {
|
|
2139
|
-
if (this.disposed || e.deltaY === 0) return !1;
|
|
2140
|
-
const t = this.gestureToLines(e);
|
|
2141
|
-
if (t === 0) return !1;
|
|
2142
|
-
const s = this.getInputRoutingState();
|
|
2143
|
-
if (s.mouseReporting) {
|
|
2144
|
-
const r = t < 0 ? js : qs;
|
|
2145
|
-
let i = !1;
|
|
2146
|
-
for (let o = 0; o < Math.abs(t); o += 1)
|
|
2147
|
-
i =
|
|
2148
|
-
this.emitMouseInput({
|
|
2149
|
-
action: 'press',
|
|
2150
|
-
button: r,
|
|
2151
|
-
clientX: e.clientX,
|
|
2152
|
-
clientY: e.clientY,
|
|
2153
|
-
mods: Ie(e),
|
|
2154
|
-
anyButtonPressed: this.pressedMouseButtons.size > 0,
|
|
2155
|
-
}) || i;
|
|
2156
|
-
return i;
|
|
2157
|
-
}
|
|
2158
|
-
return s.altScroll ? this.emitAltScrollInput(t) : (this.scrollLines(t), !0);
|
|
2159
|
-
}
|
|
2160
|
-
paste(e) {
|
|
2161
|
-
if (this.disposed || this.disableStdin || !e) return;
|
|
2162
|
-
const t = this.bindings.encodePaste(this.terminalHandle, e);
|
|
2163
|
-
t && this.emitData(t);
|
|
2164
|
-
}
|
|
2165
|
-
focus() {
|
|
2166
|
-
var e;
|
|
2167
|
-
(e = this.textarea) == null || e.focus({ preventScroll: !0 });
|
|
2168
|
-
}
|
|
2169
|
-
getRendererKind() {
|
|
2170
|
-
var e;
|
|
2171
|
-
return ((e = this.renderer) == null ? void 0 : e.kind) ?? 'unknown';
|
|
2172
|
-
}
|
|
2173
|
-
setTheme(e) {
|
|
2174
|
-
var t;
|
|
2175
|
-
this.bindings.setTerminalTheme(this.terminalHandle, e),
|
|
2176
|
-
(this.options.theme = e),
|
|
2177
|
-
this.element &&
|
|
2178
|
-
((this.element.style.backgroundColor = e.background),
|
|
2179
|
-
(this.element.style.color = e.foreground)),
|
|
2180
|
-
this.screenElement && (this.screenElement.style.backgroundColor = e.background),
|
|
2181
|
-
(t = this.renderer) == null || t.setTheme(e),
|
|
2182
|
-
this.scheduleRender();
|
|
2183
|
-
}
|
|
2184
|
-
setDisableStdin(e) {
|
|
2185
|
-
(this.disableStdin = e), this.syncInputState();
|
|
2186
|
-
}
|
|
2187
|
-
measureSizeFromElement() {
|
|
2188
|
-
const e = this.element;
|
|
2189
|
-
if (!e) return null;
|
|
2190
|
-
const t = e.getBoundingClientRect(),
|
|
2191
|
-
{ width: s, height: r } = this.cellDimensions();
|
|
2192
|
-
return t.width === 0 || t.height === 0 || s <= 0 || r <= 0
|
|
2193
|
-
? null
|
|
2194
|
-
: { cols: Math.max(2, Math.floor(t.width / s)), rows: Math.max(2, Math.floor(t.height / r)) };
|
|
2195
|
-
}
|
|
2196
|
-
dispose() {
|
|
2197
|
-
var e, t;
|
|
2198
|
-
if (!this.disposed) {
|
|
2199
|
-
(this.disposed = !0),
|
|
2200
|
-
this.renderRaf !== null && (cancelAnimationFrame(this.renderRaf), (this.renderRaf = null)),
|
|
2201
|
-
this.stopAutoScroll(),
|
|
2202
|
-
this.updateSelectionTextProbe(null),
|
|
2203
|
-
this.clearDomEventListeners(),
|
|
2204
|
-
this.scrollbarFadeTimer &&
|
|
2205
|
-
(clearTimeout(this.scrollbarFadeTimer), (this.scrollbarFadeTimer = null));
|
|
2206
|
-
for (const s of this.addons) s.dispose();
|
|
2207
|
-
this.addons.clear(),
|
|
2208
|
-
(e = this.renderer) == null || e.dispose(),
|
|
2209
|
-
(this.renderer = null),
|
|
2210
|
-
(t = this.element) == null || t.remove(),
|
|
2211
|
-
(this.element = null),
|
|
2212
|
-
(this.screenElement = null),
|
|
2213
|
-
(this.textarea = null),
|
|
2214
|
-
(this.scrollbarThumb = null),
|
|
2215
|
-
qe(this.renderState),
|
|
2216
|
-
this.bindings.freeMouseEncoder(this.mouseEncoderHandle),
|
|
2217
|
-
this.bindings.freeKeyEncoder(this.keyEncoderHandle),
|
|
2218
|
-
this.bindings.freeTerminal(this.terminalHandle);
|
|
2219
|
-
}
|
|
2220
|
-
}
|
|
2221
|
-
cellDimensions() {
|
|
2222
|
-
return this._core._renderService.dimensions.css.cell;
|
|
2223
|
-
}
|
|
2224
|
-
syncInputState() {
|
|
2225
|
-
this.textarea &&
|
|
2226
|
-
((this.textarea.readOnly = this.disableStdin),
|
|
2227
|
-
(this.textarea.tabIndex = this.disableStdin ? -1 : 0),
|
|
2228
|
-
this.disableStdin && document.activeElement === this.textarea && this.textarea.blur());
|
|
2229
|
-
}
|
|
2230
|
-
bindDomEvents() {
|
|
2231
|
-
const e = this.element,
|
|
2232
|
-
t = this.textarea;
|
|
2233
|
-
if (!e || !t) return;
|
|
2234
|
-
e.addEventListener('click', () => {
|
|
2235
|
-
this.disableStdin || this.focus();
|
|
2236
|
-
}),
|
|
2237
|
-
(this.screenElement ?? e).addEventListener('mousedown', (i) => {
|
|
2238
|
-
if (i instanceof MouseEvent) {
|
|
2239
|
-
if ((this.disableStdin || this.focus(), this.getInputRoutingState().mouseReporting)) {
|
|
2240
|
-
const o = this.mouseButtonFromEvent(i);
|
|
2241
|
-
if (o === null) return;
|
|
2242
|
-
this.clearSelectionState(),
|
|
2243
|
-
this.pressedMouseButtons.add(o),
|
|
2244
|
-
(this.mouseDragActive = !0),
|
|
2245
|
-
this.emitMouseInput({
|
|
2246
|
-
action: 'press',
|
|
2247
|
-
button: o,
|
|
2248
|
-
clientX: i.clientX,
|
|
2249
|
-
clientY: i.clientY,
|
|
2250
|
-
mods: Ie(i),
|
|
2251
|
-
anyButtonPressed: !0,
|
|
2252
|
-
}),
|
|
2253
|
-
i.preventDefault();
|
|
2254
|
-
return;
|
|
2255
|
-
}
|
|
2256
|
-
i.button === 0 &&
|
|
2257
|
-
((this.mouseDragActive = !0), this.beginPointerSelection(i), i.preventDefault());
|
|
2258
|
-
}
|
|
2259
|
-
}),
|
|
2260
|
-
e.addEventListener(
|
|
2261
|
-
'wheel',
|
|
2262
|
-
(i) => {
|
|
2263
|
-
this.handleViewportGesture({
|
|
2264
|
-
source: 'wheel',
|
|
2265
|
-
deltaY: i.deltaY,
|
|
2266
|
-
deltaMode: i.deltaMode,
|
|
2267
|
-
clientX: i.clientX,
|
|
2268
|
-
clientY: i.clientY,
|
|
2269
|
-
shiftKey: i.shiftKey,
|
|
2270
|
-
ctrlKey: i.ctrlKey,
|
|
2271
|
-
altKey: i.altKey,
|
|
2272
|
-
metaKey: i.metaKey,
|
|
2273
|
-
}) && i.preventDefault();
|
|
2274
|
-
},
|
|
2275
|
-
{ passive: !1 }
|
|
2276
|
-
);
|
|
2277
|
-
const r = typeof window < 'u' && typeof window.addEventListener == 'function' ? window : null;
|
|
2278
|
-
if (r) {
|
|
2279
|
-
const i = (l) => {
|
|
2280
|
-
if (this.mouseDragActive) {
|
|
2281
|
-
if (this.getInputRoutingState().mouseReporting) {
|
|
2282
|
-
this.emitMouseInput({
|
|
2283
|
-
action: 'motion',
|
|
2284
|
-
button: this.mouseButtonFromButtons(l.buttons),
|
|
2285
|
-
clientX: l.clientX,
|
|
2286
|
-
clientY: l.clientY,
|
|
2287
|
-
mods: Ie(l),
|
|
2288
|
-
anyButtonPressed: this.pressedMouseButtons.size > 0 || l.buttons > 0,
|
|
2289
|
-
});
|
|
2290
|
-
return;
|
|
2291
|
-
}
|
|
2292
|
-
this.updatePointerSelection(l);
|
|
2293
|
-
}
|
|
2294
|
-
},
|
|
2295
|
-
o = (l) => {
|
|
2296
|
-
if (this.mouseDragActive) {
|
|
2297
|
-
if (((this.mouseDragActive = !1), this.getInputRoutingState().mouseReporting)) {
|
|
2298
|
-
const u = this.mouseButtonFromEvent(l);
|
|
2299
|
-
u !== null && this.pressedMouseButtons.delete(u),
|
|
2300
|
-
this.emitMouseInput({
|
|
2301
|
-
action: 'release',
|
|
2302
|
-
button: u,
|
|
2303
|
-
clientX: l.clientX,
|
|
2304
|
-
clientY: l.clientY,
|
|
2305
|
-
mods: Ie(l),
|
|
2306
|
-
anyButtonPressed: this.pressedMouseButtons.size > 0,
|
|
2307
|
-
});
|
|
2308
|
-
return;
|
|
2309
|
-
}
|
|
2310
|
-
this.finishPointerSelection(l);
|
|
2311
|
-
}
|
|
2312
|
-
};
|
|
2313
|
-
r.addEventListener('mousemove', i),
|
|
2314
|
-
r.addEventListener('mouseup', o),
|
|
2315
|
-
this.domEventDisposers.push(() => {
|
|
2316
|
-
r.removeEventListener('mousemove', i), r.removeEventListener('mouseup', o);
|
|
2317
|
-
});
|
|
2318
|
-
}
|
|
2319
|
-
t.addEventListener('keydown', (i) => {
|
|
2320
|
-
const o = this.getSelectionText();
|
|
2321
|
-
if (o && fs(i)) {
|
|
2322
|
-
(this.copyShortcutSuppressed = !0),
|
|
2323
|
-
i.preventDefault(),
|
|
2324
|
-
ms(o).catch(() => {}),
|
|
2325
|
-
this.clearTextarea();
|
|
2326
|
-
return;
|
|
2327
|
-
}
|
|
2328
|
-
if (
|
|
2329
|
-
!this.customKeyEventHandler(i) ||
|
|
2330
|
-
this.disableStdin ||
|
|
2331
|
-
this.imeIsComposing ||
|
|
2332
|
-
i.keyCode === 229 ||
|
|
2333
|
-
!Qs(i)
|
|
2334
|
-
)
|
|
2335
|
-
return;
|
|
2336
|
-
const l = this.encodeKeyboardEvent(i, i.repeat ? 'repeat' : 'press');
|
|
2337
|
-
l && (i.preventDefault(), this.emitData(l), this.clearTextarea());
|
|
2338
|
-
}),
|
|
2339
|
-
t.addEventListener('keyup', (i) => {
|
|
2340
|
-
if (this.copyShortcutSuppressed) {
|
|
2341
|
-
const l = i.key.toLowerCase();
|
|
2342
|
-
if (l === 'c') {
|
|
2343
|
-
i.preventDefault();
|
|
2344
|
-
return;
|
|
2345
|
-
}
|
|
2346
|
-
if (l === 'control' || l === 'meta' || l === 'os') {
|
|
2347
|
-
(this.copyShortcutSuppressed = !1), i.preventDefault();
|
|
2348
|
-
return;
|
|
2349
|
-
}
|
|
2350
|
-
}
|
|
2351
|
-
if (this.disableStdin || this.imeIsComposing) return;
|
|
2352
|
-
const o = this.encodeKeyboardEvent(i, 'release');
|
|
2353
|
-
o && (i.preventDefault(), this.emitData(o), this.clearTextarea());
|
|
2354
|
-
}),
|
|
2355
|
-
t.addEventListener('compositionstart', () => {
|
|
2356
|
-
(this.imeIsComposing = !0),
|
|
2357
|
-
(this.lastCompositionCommit = null),
|
|
2358
|
-
this.syncTextareaPositionToCursor();
|
|
2359
|
-
}),
|
|
2360
|
-
t.addEventListener('compositionupdate', () => {
|
|
2361
|
-
this.syncTextareaPositionToCursor();
|
|
2362
|
-
}),
|
|
2363
|
-
t.addEventListener('compositionend', (i) => {
|
|
2364
|
-
this.imeIsComposing = !1;
|
|
2365
|
-
const o = i.data ?? '';
|
|
2366
|
-
o &&
|
|
2367
|
-
((this.lastCompositionCommit = { data: o, at: Date.now() }),
|
|
2368
|
-
this.emitData(o),
|
|
2369
|
-
this.clearTextarea());
|
|
2370
|
-
}),
|
|
2371
|
-
t.addEventListener('beforeinput', (i) => {
|
|
2372
|
-
if (this.disableStdin || i.inputType === 'insertFromPaste') return;
|
|
2373
|
-
const o = i.data ?? '';
|
|
2374
|
-
if (!o || i.isComposing || this.imeIsComposing) return;
|
|
2375
|
-
const l = this.lastCompositionCommit;
|
|
2376
|
-
if (l && l.data === o && Date.now() - l.at < 40) {
|
|
2377
|
-
(this.lastCompositionCommit = null), i.preventDefault(), this.clearTextarea();
|
|
2378
|
-
return;
|
|
2379
|
-
}
|
|
2380
|
-
(this.lastCompositionCommit = null),
|
|
2381
|
-
i.preventDefault(),
|
|
2382
|
-
this.emitData(o),
|
|
2383
|
-
this.clearTextarea();
|
|
2384
|
-
}),
|
|
2385
|
-
t.addEventListener('paste', (i) => {
|
|
2386
|
-
var l;
|
|
2387
|
-
if (this.disableStdin) return;
|
|
2388
|
-
const o = ((l = i.clipboardData) == null ? void 0 : l.getData('text/plain')) ?? '';
|
|
2389
|
-
o && (i.preventDefault(), this.paste(o), this.clearTextarea());
|
|
2390
|
-
}),
|
|
2391
|
-
t.addEventListener('copy', (i) => {
|
|
2392
|
-
const o = this.getSelectionText();
|
|
2393
|
-
o && ps(i, o);
|
|
2394
|
-
}),
|
|
2395
|
-
t.addEventListener('input', () => {
|
|
2396
|
-
if (this.disableStdin || this.imeIsComposing) return;
|
|
2397
|
-
const i = t.textContent ?? '';
|
|
2398
|
-
if (!i) {
|
|
2399
|
-
this.clearTextarea();
|
|
2400
|
-
return;
|
|
2401
|
-
}
|
|
2402
|
-
const o = this.lastCompositionCommit;
|
|
2403
|
-
if (o && o.data === i && Date.now() - o.at < 40) {
|
|
2404
|
-
(this.lastCompositionCommit = null), this.clearTextarea();
|
|
2405
|
-
return;
|
|
2406
|
-
}
|
|
2407
|
-
(this.lastCompositionCommit = null), this.emitData(i), this.clearTextarea();
|
|
2408
|
-
});
|
|
2409
|
-
}
|
|
2410
|
-
encodeKeyboardEvent(e, t) {
|
|
2411
|
-
const s = ft(e.code);
|
|
2412
|
-
if (s === 0) return null;
|
|
2413
|
-
const r = e.key.length === 1 && !e.ctrlKey && !e.metaKey ? e.key : null;
|
|
2414
|
-
return this.bindings.encodeKeyEvent(this.keyEncoderHandle, this.terminalHandle, {
|
|
2415
|
-
action: t,
|
|
2416
|
-
keyCode: s,
|
|
2417
|
-
mods: Ht(e),
|
|
2418
|
-
composing: e.isComposing,
|
|
2419
|
-
utf8: r,
|
|
2420
|
-
unshiftedCodepoint: xn(e.code),
|
|
2421
|
-
});
|
|
2422
|
-
}
|
|
2423
|
-
getInputRoutingState() {
|
|
2424
|
-
const e =
|
|
2425
|
-
this.isModeEnabled(He) ||
|
|
2426
|
-
this.isModeEnabled(Pe) ||
|
|
2427
|
-
this.isModeEnabled(Le) ||
|
|
2428
|
-
this.isModeEnabled(Ne),
|
|
2429
|
-
t = this.isModeEnabled(Oe) || this.isModeEnabled(ke);
|
|
2430
|
-
return { mouseReporting: e, altScroll: !e && t && this.isModeEnabled(Ze) };
|
|
2431
|
-
}
|
|
2432
|
-
gestureToLines(e) {
|
|
2433
|
-
const t = this.cellDimensions().height || Ae;
|
|
2434
|
-
if (e.source === 'wheel') {
|
|
2435
|
-
if (e.deltaMode === 1)
|
|
2436
|
-
return (
|
|
2437
|
-
(this.wheelPixelDelta = 0), e.deltaY > 0 ? Math.ceil(e.deltaY) : Math.floor(e.deltaY)
|
|
2438
|
-
);
|
|
2439
|
-
if (e.deltaMode === 2) {
|
|
2440
|
-
this.wheelPixelDelta = 0;
|
|
2441
|
-
const r = Math.max(1, this.rows),
|
|
2442
|
-
i = e.deltaY * r;
|
|
2443
|
-
return i > 0 ? Math.ceil(i) : Math.floor(i);
|
|
2444
|
-
}
|
|
2445
|
-
this.wheelPixelDelta += e.deltaY;
|
|
2446
|
-
const s =
|
|
2447
|
-
this.wheelPixelDelta > 0
|
|
2448
|
-
? Math.floor(this.wheelPixelDelta / t)
|
|
2449
|
-
: Math.ceil(this.wheelPixelDelta / t);
|
|
2450
|
-
return s !== 0 && (this.wheelPixelDelta -= s * t), s;
|
|
2451
|
-
}
|
|
2452
|
-
return e.deltaY > 0 ? Math.ceil(e.deltaY / t) : Math.floor(e.deltaY / t);
|
|
2453
|
-
}
|
|
2454
|
-
isModeEnabled(e) {
|
|
2455
|
-
return this.bindings.isTerminalModeEnabled(this.terminalHandle, e);
|
|
2456
|
-
}
|
|
2457
|
-
mouseButtonFromEvent(e) {
|
|
2458
|
-
switch (e.button) {
|
|
2459
|
-
case 0:
|
|
2460
|
-
return xt;
|
|
2461
|
-
case 1:
|
|
2462
|
-
return Et;
|
|
2463
|
-
case 2:
|
|
2464
|
-
return Rt;
|
|
2465
|
-
default:
|
|
2466
|
-
return null;
|
|
2467
|
-
}
|
|
2468
|
-
}
|
|
2469
|
-
mouseButtonFromButtons(e) {
|
|
2470
|
-
return e & 1 ? xt : e & 4 ? Et : e & 2 ? Rt : null;
|
|
2471
|
-
}
|
|
2472
|
-
pointerPositionFromClient(e, t) {
|
|
2473
|
-
var o;
|
|
2474
|
-
const s = (o = this.screenElement) == null ? void 0 : o.getBoundingClientRect();
|
|
2475
|
-
if (!s) return null;
|
|
2476
|
-
const r = Math.max(1, s.width),
|
|
2477
|
-
i = Math.max(1, s.height);
|
|
2478
|
-
return {
|
|
2479
|
-
x: Math.max(0, Math.min(r - 1, e - s.left)),
|
|
2480
|
-
y: Math.max(0, Math.min(i - 1, t - s.top)),
|
|
2481
|
-
};
|
|
2482
|
-
}
|
|
2483
|
-
emitMouseInput(e) {
|
|
2484
|
-
var o;
|
|
2485
|
-
if (this.disableStdin) return !1;
|
|
2486
|
-
const t = this.pointerPositionFromClient(e.clientX, e.clientY);
|
|
2487
|
-
if (!t) return !1;
|
|
2488
|
-
const s = this.cellDimensions(),
|
|
2489
|
-
r = (o = this.screenElement) == null ? void 0 : o.getBoundingClientRect();
|
|
2490
|
-
if (!r) return !1;
|
|
2491
|
-
const i = this.bindings.encodeMouseEvent(this.mouseEncoderHandle, this.terminalHandle, {
|
|
2492
|
-
action: e.action,
|
|
2493
|
-
button: e.button,
|
|
2494
|
-
mods: e.mods,
|
|
2495
|
-
x: t.x,
|
|
2496
|
-
y: t.y,
|
|
2497
|
-
anyButtonPressed: e.anyButtonPressed,
|
|
2498
|
-
screenWidth: Math.max(1, Math.round(r.width)),
|
|
2499
|
-
screenHeight: Math.max(1, Math.round(r.height)),
|
|
2500
|
-
cellWidth: Math.max(1, Math.round(s.width || Qe)),
|
|
2501
|
-
cellHeight: Math.max(1, Math.round(s.height || Ae)),
|
|
2502
|
-
});
|
|
2503
|
-
return i ? (this.emitData(i), !0) : !1;
|
|
2504
|
-
}
|
|
2505
|
-
emitAltScrollInput(e) {
|
|
2506
|
-
const t = ft(e < 0 ? 'ArrowUp' : 'ArrowDown');
|
|
2507
|
-
if (t === 0) return !1;
|
|
2508
|
-
let s = !1;
|
|
2509
|
-
for (let r = 0; r < Math.abs(e); r += 1) {
|
|
2510
|
-
const i = this.bindings.encodeKeyEvent(this.keyEncoderHandle, this.terminalHandle, {
|
|
2511
|
-
action: 'press',
|
|
2512
|
-
keyCode: t,
|
|
2513
|
-
mods: 0,
|
|
2514
|
-
composing: !1,
|
|
2515
|
-
utf8: null,
|
|
2516
|
-
unshiftedCodepoint: null,
|
|
2517
|
-
});
|
|
2518
|
-
i && (this.emitData(i), (s = !0));
|
|
2519
|
-
}
|
|
2520
|
-
return s;
|
|
2521
|
-
}
|
|
2522
|
-
emitData(e) {
|
|
2523
|
-
for (const t of this.dataListeners) t(e);
|
|
2524
|
-
}
|
|
2525
|
-
clearTextarea() {
|
|
2526
|
-
this.textarea && (this.textarea.textContent = '');
|
|
2527
|
-
}
|
|
2528
|
-
syncTextareaPositionToCursor() {
|
|
2529
|
-
const e = this.textarea,
|
|
2530
|
-
t = this.screenElement;
|
|
2531
|
-
if (!e || !t) return;
|
|
2532
|
-
const { width: s, height: r } = this.cellDimensions();
|
|
2533
|
-
if (s <= 0 || r <= 0) return;
|
|
2534
|
-
const i = wt(this.bindings);
|
|
2535
|
-
let o = 0,
|
|
2536
|
-
l = 0;
|
|
2537
|
-
try {
|
|
2538
|
-
gt(i, this.terminalHandle);
|
|
2539
|
-
const y = tt(i);
|
|
2540
|
-
y.cursor.x !== null && y.cursor.y !== null && ((o = y.cursor.x), (l = y.cursor.y));
|
|
2541
|
-
} finally {
|
|
2542
|
-
qe(i);
|
|
2543
|
-
}
|
|
2544
|
-
const u = o * s,
|
|
2545
|
-
c = l * r;
|
|
2546
|
-
(e.style.left = `${u}px`),
|
|
2547
|
-
(e.style.top = `${c}px`),
|
|
2548
|
-
(e.style.width = `${Math.max(1, s)}px`),
|
|
2549
|
-
(e.style.height = `${Math.max(1, r)}px`),
|
|
2550
|
-
(e.style.lineHeight = `${r}px`),
|
|
2551
|
-
(e.style.fontFamily = this.options.fontFamily),
|
|
2552
|
-
(e.style.fontSize = `${this.options.fontSize}px`);
|
|
2553
|
-
}
|
|
2554
|
-
scheduleRender() {
|
|
2555
|
-
this.renderRaf === null &&
|
|
2556
|
-
(this.renderRaf = requestAnimationFrame(() => {
|
|
2557
|
-
(this.renderRaf = null), this.render();
|
|
2558
|
-
}));
|
|
2559
|
-
}
|
|
2560
|
-
render() {
|
|
2561
|
-
if (this.disposed || !this.screenElement || !this.renderer) return;
|
|
2562
|
-
const e = this.bindings.readScrollbar(this.terminalHandle),
|
|
2563
|
-
t = Math.max(1, e.len || this.rows);
|
|
2564
|
-
gt(this.renderState, this.terminalHandle);
|
|
2565
|
-
const s = tt(this.renderState),
|
|
2566
|
-
r = Array.from(rs(this.renderState));
|
|
2567
|
-
(this.cols = Math.max(2, s.cols)),
|
|
2568
|
-
(this.rows = Math.max(2, s.rows || t)),
|
|
2569
|
-
(this.lastViewportOffset = e.offset),
|
|
2570
|
-
(this.lastViewportRows = this.rows),
|
|
2571
|
-
(this.lastRenderedRows = r);
|
|
2572
|
-
for (const c of r) this.lineCache.set(e.offset + c.y, c.text);
|
|
2573
|
-
const i = us(this.selectionState, this.lastViewportOffset, this.lastViewportRows, (c) =>
|
|
2574
|
-
this.getLineText(c)
|
|
2575
|
-
),
|
|
2576
|
-
o = this.getSelectionText();
|
|
2577
|
-
this.renderer.render({
|
|
2578
|
-
meta: s,
|
|
2579
|
-
rows: r,
|
|
2580
|
-
cellDimensions: this.cellDimensions(),
|
|
2581
|
-
selectionRects: i,
|
|
2582
|
-
selectionColor: this.options.theme.selectionBackground,
|
|
2583
|
-
});
|
|
2584
|
-
const l = Zs(r, this.rows),
|
|
2585
|
-
u = Math.max(0, e.total - e.len);
|
|
2586
|
-
this.buffer.setViewport(e.offset, u, e.total, l),
|
|
2587
|
-
this.updateSelectionTextProbe(o),
|
|
2588
|
-
this.updateScrollbar(e);
|
|
2589
|
-
}
|
|
2590
|
-
updateScrollbar(e) {
|
|
2591
|
-
var u;
|
|
2592
|
-
const t = this.scrollbarThumb;
|
|
2593
|
-
if (!t) return;
|
|
2594
|
-
const s = ((u = this.screenElement) == null ? void 0 : u.clientHeight) ?? 0;
|
|
2595
|
-
if (s === 0 || e.total <= e.len) {
|
|
2596
|
-
t.style.opacity = '0';
|
|
2597
|
-
return;
|
|
2598
|
-
}
|
|
2599
|
-
const r = e.len / e.total,
|
|
2600
|
-
i = Math.max(20, r * s),
|
|
2601
|
-
l = (e.offset / Math.max(1, e.total - e.len)) * (s - i);
|
|
2602
|
-
(t.style.height = `${i}px`),
|
|
2603
|
-
(t.style.transform = `translateY(${l}px)`),
|
|
2604
|
-
(t.style.opacity = '1'),
|
|
2605
|
-
this.scrollbarFadeTimer && clearTimeout(this.scrollbarFadeTimer),
|
|
2606
|
-
(this.scrollbarFadeTimer = setTimeout(() => {
|
|
2607
|
-
t.style.opacity = '0';
|
|
2608
|
-
}, 800));
|
|
2609
|
-
}
|
|
2610
|
-
updateCellDimensions() {
|
|
2611
|
-
if (!this.element) return;
|
|
2612
|
-
const e = document.createElement('span');
|
|
2613
|
-
(e.textContent = 'WWWWWWWWWW'),
|
|
2614
|
-
(e.style.position = 'absolute'),
|
|
2615
|
-
(e.style.visibility = 'hidden'),
|
|
2616
|
-
(e.style.whiteSpace = 'pre'),
|
|
2617
|
-
(e.style.fontFamily = this.options.fontFamily),
|
|
2618
|
-
(e.style.fontSize = `${this.options.fontSize}px`),
|
|
2619
|
-
(e.style.lineHeight = '1.2'),
|
|
2620
|
-
this.element.appendChild(e);
|
|
2621
|
-
const t = e.getBoundingClientRect();
|
|
2622
|
-
e.remove(),
|
|
2623
|
-
(this._core._renderService.dimensions.css.cell.width = t.width > 0 ? t.width / 10 : Qe),
|
|
2624
|
-
(this._core._renderService.dimensions.css.cell.height = t.height > 0 ? t.height : Ae);
|
|
2625
|
-
}
|
|
2626
|
-
clearSelectionState(e = !0) {
|
|
2627
|
-
(this.selectionState = as()),
|
|
2628
|
-
this.pressedMouseButtons.clear(),
|
|
2629
|
-
(this.wheelPixelDelta = 0),
|
|
2630
|
-
(this.pointerDrag = {
|
|
2631
|
-
active: !1,
|
|
2632
|
-
moved: !1,
|
|
2633
|
-
mode: 'character',
|
|
2634
|
-
lastClientX: null,
|
|
2635
|
-
lastClientY: null,
|
|
2636
|
-
}),
|
|
2637
|
-
(this.copyShortcutSuppressed = !1),
|
|
2638
|
-
this.stopAutoScroll(),
|
|
2639
|
-
this.updateSelectionTextProbe(null),
|
|
2640
|
-
e && this.screenElement && this.renderer && this.render();
|
|
2641
|
-
}
|
|
2642
|
-
beginPointerSelection(e) {
|
|
2643
|
-
const t = this.hitTest(e.clientX, e.clientY);
|
|
2644
|
-
if (!t) return;
|
|
2645
|
-
const s = this.selectionModeFromClickDetail(e.detail);
|
|
2646
|
-
(this.pointerDrag = {
|
|
2647
|
-
active: !0,
|
|
2648
|
-
moved: !1,
|
|
2649
|
-
mode: s,
|
|
2650
|
-
lastClientX: e.clientX,
|
|
2651
|
-
lastClientY: e.clientY,
|
|
2652
|
-
}),
|
|
2653
|
-
(this.selectionState = cs(this.selectionState, { ...t, mode: s }, (r) =>
|
|
2654
|
-
this.getLineText(r)
|
|
2655
|
-
)),
|
|
2656
|
-
this.updateAutoScroll(),
|
|
2657
|
-
this.render();
|
|
2658
|
-
}
|
|
2659
|
-
updatePointerSelection(e) {
|
|
2660
|
-
if (!this.pointerDrag.active) return;
|
|
2661
|
-
const t = this.hitTest(e.clientX, e.clientY);
|
|
2662
|
-
(this.pointerDrag.lastClientX = e.clientX),
|
|
2663
|
-
(this.pointerDrag.lastClientY = e.clientY),
|
|
2664
|
-
t &&
|
|
2665
|
-
((this.pointerDrag.moved = !0),
|
|
2666
|
-
(this.selectionState = yt(this.selectionState, t, (s) => this.getLineText(s))),
|
|
2667
|
-
this.render()),
|
|
2668
|
-
this.updateAutoScroll();
|
|
2669
|
-
}
|
|
2670
|
-
finishPointerSelection(e) {
|
|
2671
|
-
var s, r, i, o;
|
|
2672
|
-
if (!this.pointerDrag.active || e.button !== 0) return;
|
|
2673
|
-
(this.pointerDrag.lastClientX = e.clientX),
|
|
2674
|
-
(this.pointerDrag.lastClientY = e.clientY),
|
|
2675
|
-
this.stopAutoScroll();
|
|
2676
|
-
const t =
|
|
2677
|
-
this.pointerDrag.mode === 'character' &&
|
|
2678
|
-
!this.pointerDrag.moved &&
|
|
2679
|
-
((s = this.selectionState.anchor) == null ? void 0 : s.line) ===
|
|
2680
|
-
((r = this.selectionState.focus) == null ? void 0 : r.line) &&
|
|
2681
|
-
((i = this.selectionState.anchor) == null ? void 0 : i.col) ===
|
|
2682
|
-
((o = this.selectionState.focus) == null ? void 0 : o.col);
|
|
2683
|
-
if (((this.pointerDrag.active = !1), t)) {
|
|
2684
|
-
this.clearSelectionState();
|
|
2685
|
-
return;
|
|
2686
|
-
}
|
|
2687
|
-
this.render();
|
|
2688
|
-
}
|
|
2689
|
-
selectionModeFromClickDetail(e) {
|
|
2690
|
-
return e >= 3 ? 'line' : e === 2 ? 'word' : 'character';
|
|
2691
|
-
}
|
|
2692
|
-
hitTest(e, t) {
|
|
2693
|
-
var O;
|
|
2694
|
-
const s = (O = this.screenElement) == null ? void 0 : O.getBoundingClientRect();
|
|
2695
|
-
if (!s) return null;
|
|
2696
|
-
const { width: r, height: i } = this.cellDimensions();
|
|
2697
|
-
if (r <= 0 || i <= 0) return null;
|
|
2698
|
-
const o = e - s.left,
|
|
2699
|
-
l = t - s.top,
|
|
2700
|
-
u = Math.max(this.cols - 1, 0),
|
|
2701
|
-
c = Math.max(this.lastViewportRows - 1, 0),
|
|
2702
|
-
y = Math.max(0, Math.min(u, Math.floor(o / r))),
|
|
2703
|
-
M = Math.max(0, Math.min(c, Math.floor(l / i)));
|
|
2704
|
-
return { line: this.lastViewportOffset + M, col: y };
|
|
2705
|
-
}
|
|
2706
|
-
getLineText(e) {
|
|
2707
|
-
const t = this.lineCache.get(e);
|
|
2708
|
-
if (typeof t == 'string') return t;
|
|
2709
|
-
const s = e - this.lastViewportOffset,
|
|
2710
|
-
r = this.lastRenderedRows[s];
|
|
2711
|
-
return (r == null ? void 0 : r.text) ?? '';
|
|
2712
|
-
}
|
|
2713
|
-
getSelectionText() {
|
|
2714
|
-
return ls(this.selectionState) ? ds(this.selectionState, (e) => this.getLineText(e)) : null;
|
|
2715
|
-
}
|
|
2716
|
-
updateSelectionTextProbe(e) {
|
|
2717
|
-
globalThis.__tmexE2eTerminalSelectionText = e;
|
|
2718
|
-
}
|
|
2719
|
-
updateAutoScroll() {
|
|
2720
|
-
var s;
|
|
2721
|
-
if (!this.pointerDrag.active || this.pointerDrag.lastClientY === null) {
|
|
2722
|
-
this.stopAutoScroll();
|
|
2723
|
-
return;
|
|
2724
|
-
}
|
|
2725
|
-
const e = (s = this.screenElement) == null ? void 0 : s.getBoundingClientRect();
|
|
2726
|
-
if (!e) {
|
|
2727
|
-
this.stopAutoScroll();
|
|
2728
|
-
return;
|
|
2729
|
-
}
|
|
2730
|
-
if (!(this.pointerDrag.lastClientY < e.top || this.pointerDrag.lastClientY > e.bottom)) {
|
|
2731
|
-
this.stopAutoScroll();
|
|
2732
|
-
return;
|
|
2733
|
-
}
|
|
2734
|
-
this.autoScrollTimer === null &&
|
|
2735
|
-
(this.autoScrollTimer = setInterval(() => {
|
|
2736
|
-
this.stepAutoScroll();
|
|
2737
|
-
}, Ks));
|
|
2738
|
-
}
|
|
2739
|
-
stepAutoScroll() {
|
|
2740
|
-
var r;
|
|
2741
|
-
if (
|
|
2742
|
-
!this.pointerDrag.active ||
|
|
2743
|
-
this.pointerDrag.lastClientX === null ||
|
|
2744
|
-
this.pointerDrag.lastClientY === null
|
|
2745
|
-
) {
|
|
2746
|
-
this.stopAutoScroll();
|
|
2747
|
-
return;
|
|
2748
|
-
}
|
|
2749
|
-
const e = (r = this.screenElement) == null ? void 0 : r.getBoundingClientRect();
|
|
2750
|
-
if (!e) {
|
|
2751
|
-
this.stopAutoScroll();
|
|
2752
|
-
return;
|
|
2753
|
-
}
|
|
2754
|
-
let t = 0;
|
|
2755
|
-
if (
|
|
2756
|
-
(this.pointerDrag.lastClientY < e.top
|
|
2757
|
-
? (t = -1)
|
|
2758
|
-
: this.pointerDrag.lastClientY > e.bottom && (t = 1),
|
|
2759
|
-
t === 0)
|
|
2760
|
-
) {
|
|
2761
|
-
this.stopAutoScroll();
|
|
2762
|
-
return;
|
|
2763
|
-
}
|
|
2764
|
-
this.bindings.scrollViewportDelta(this.terminalHandle, t), this.render();
|
|
2765
|
-
const s = this.hitTest(this.pointerDrag.lastClientX, this.pointerDrag.lastClientY);
|
|
2766
|
-
s &&
|
|
2767
|
-
((this.selectionState = yt(this.selectionState, s, (i) => this.getLineText(i))),
|
|
2768
|
-
(this.pointerDrag.moved = !0),
|
|
2769
|
-
this.render());
|
|
2770
|
-
}
|
|
2771
|
-
stopAutoScroll() {
|
|
2772
|
-
this.autoScrollTimer !== null &&
|
|
2773
|
-
(clearInterval(this.autoScrollTimer), (this.autoScrollTimer = null));
|
|
2774
|
-
}
|
|
2775
|
-
clearDomEventListeners() {
|
|
2776
|
-
while (this.domEventDisposers.length > 0) {
|
|
2777
|
-
const e = this.domEventDisposers.pop();
|
|
2778
|
-
e == null || e();
|
|
2779
|
-
}
|
|
2780
|
-
}
|
|
2781
|
-
}
|
|
2782
|
-
async function tr(n) {
|
|
2783
|
-
return Ge.create(n);
|
|
2784
|
-
}
|
|
2785
|
-
const Lt = {
|
|
2786
|
-
background: '#e1e1e1',
|
|
2787
|
-
foreground: '#616161',
|
|
2788
|
-
cursor: '#616161',
|
|
2789
|
-
selectionBackground: 'rgba(97, 97, 97, 0.25)',
|
|
2790
|
-
black: '#171717',
|
|
2791
|
-
red: '#bf2172',
|
|
2792
|
-
green: '#009799',
|
|
2793
|
-
yellow: '#9a7200',
|
|
2794
|
-
blue: '#007299',
|
|
2795
|
-
magenta: '#9b1d72',
|
|
2796
|
-
cyan: '#007173',
|
|
2797
|
-
white: '#d9d9d9',
|
|
2798
|
-
brightBlack: '#4e4e4e',
|
|
2799
|
-
brightRed: '#e12672',
|
|
2800
|
-
brightGreen: '#00bddf',
|
|
2801
|
-
brightYellow: '#ffdd00',
|
|
2802
|
-
brightBlue: '#7299bc',
|
|
2803
|
-
brightMagenta: '#e17899',
|
|
2804
|
-
brightCyan: '#6fbcbd',
|
|
2805
|
-
brightWhite: '#f1f1f1',
|
|
2806
|
-
},
|
|
2807
|
-
Nt = {
|
|
2808
|
-
background: '#262626',
|
|
2809
|
-
foreground: '#d0d0d0',
|
|
2810
|
-
cursor: '#c5c5c5',
|
|
2811
|
-
selectionBackground: 'rgba(197, 197, 197, 0.25)',
|
|
2812
|
-
black: '#000000',
|
|
2813
|
-
red: '#ba3c3c',
|
|
2814
|
-
green: '#5d876d',
|
|
2815
|
-
yellow: '#d5a54e',
|
|
2816
|
-
blue: '#887c8d',
|
|
2817
|
-
magenta: '#cd6d6d',
|
|
2818
|
-
cyan: '#618484',
|
|
2819
|
-
white: '#cfcdc3',
|
|
2820
|
-
brightBlack: '#000000',
|
|
2821
|
-
brightRed: '#ea7171',
|
|
2822
|
-
brightGreen: '#7aab7a',
|
|
2823
|
-
brightYellow: '#d1d194',
|
|
2824
|
-
brightBlue: '#afa3b5',
|
|
2825
|
-
brightMagenta: '#e29f9f',
|
|
2826
|
-
brightCyan: '#a0aea3',
|
|
2827
|
-
brightWhite: '#d0d0d0',
|
|
2828
|
-
},
|
|
2829
|
-
nr =
|
|
2830
|
-
'"JetBrains Mono", "SF Mono", Menlo, Monaco, Consolas, "Liberation Mono", "Noto Sans Mono CJK SC", "Source Han Mono SC", "Sarasa Mono SC", "Noto Color Emoji", "Apple Color Emoji", "Segoe UI Emoji", monospace';
|
|
2831
|
-
function Ft(n) {
|
|
2832
|
-
if (!n) return n;
|
|
2833
|
-
const e = n.replace(
|
|
2834
|
-
/\r\n/g,
|
|
2835
|
-
`
|
|
2836
|
-
`
|
|
2837
|
-
);
|
|
2838
|
-
return (
|
|
2839
|
-
e.endsWith(`
|
|
2840
|
-
`)
|
|
2841
|
-
? e.slice(0, -1)
|
|
2842
|
-
: e
|
|
2843
|
-
).replace(
|
|
2844
|
-
/\n/g,
|
|
2845
|
-
`\r
|
|
2846
|
-
`
|
|
2847
|
-
);
|
|
2848
|
-
}
|
|
2849
|
-
const sr = '\x1B[?1049h\x1B[H\x1B[2J';
|
|
2850
|
-
function rr(n) {
|
|
2851
|
-
return sr + Ft(n);
|
|
2852
|
-
}
|
|
2853
|
-
function Ct(n, e) {
|
|
2854
|
-
let t = e,
|
|
2855
|
-
s = 0;
|
|
2856
|
-
for (const l of n) l === 10 && !t && (s += 1), (t = l === 13);
|
|
2857
|
-
const r = t;
|
|
2858
|
-
if (s === 0) return { normalized: n, endedWithCR: r };
|
|
2859
|
-
const i = new Uint8Array(n.length + s);
|
|
2860
|
-
let o = 0;
|
|
2861
|
-
t = e;
|
|
2862
|
-
for (const l of n)
|
|
2863
|
-
l === 10 && !t && ((i[o] = 13), (o += 1)), (i[o] = l), (o += 1), (t = l === 13);
|
|
2864
|
-
return { normalized: i, endedWithCR: r };
|
|
2865
|
-
}
|
|
2866
|
-
const ir = 1.3,
|
|
2867
|
-
or = 36;
|
|
2868
|
-
function lr(n, e) {
|
|
2869
|
-
const t = d.useRef(!1);
|
|
2870
|
-
return (
|
|
2871
|
-
d.useEffect(() => {
|
|
2872
|
-
const s = n.current;
|
|
2873
|
-
if (
|
|
2874
|
-
!s ||
|
|
2875
|
-
!(window.innerWidth < 768 || navigator.maxTouchPoints > 0 || 'ontouchstart' in window)
|
|
2876
|
-
)
|
|
2877
|
-
return;
|
|
2878
|
-
t.current = !0;
|
|
2879
|
-
let i = 0,
|
|
2880
|
-
o = null,
|
|
2881
|
-
l = !1,
|
|
2882
|
-
u = 0;
|
|
2883
|
-
const c = (g) =>
|
|
2884
|
-
g
|
|
2885
|
-
? !!(g.closest('.scrollbar') || g.closest('.slider') || g.closest('.xterm-scroll-area'))
|
|
2886
|
-
: !1,
|
|
2887
|
-
y = (g, h, k) => {
|
|
2888
|
-
const D = k instanceof Element ? k : null;
|
|
2889
|
-
if (c(D)) return !0;
|
|
2890
|
-
const q = document.elementFromPoint(g, h);
|
|
2891
|
-
if (c(q)) return !0;
|
|
2892
|
-
const F = s.querySelector('.xterm');
|
|
2893
|
-
if (!(F instanceof HTMLElement)) return !1;
|
|
2894
|
-
const A = F.getBoundingClientRect(),
|
|
2895
|
-
z = g >= A.left && g <= A.right,
|
|
2896
|
-
X = h >= A.top && h <= A.bottom;
|
|
2897
|
-
return !z || !X ? !1 : g >= A.right - or;
|
|
2898
|
-
},
|
|
2899
|
-
M = () =>
|
|
2900
|
-
[s.querySelector('.xterm-viewport'), s.querySelector('.xterm-scrollable-element')].filter(
|
|
2901
|
-
(h) => h instanceof HTMLElement
|
|
2902
|
-
),
|
|
2903
|
-
O = (g) => {
|
|
2904
|
-
if (o === null) return null;
|
|
2905
|
-
for (let h = 0; h < g.length; h += 1) {
|
|
2906
|
-
const k = g.item(h);
|
|
2907
|
-
if (k && k.identifier === o) return k;
|
|
2908
|
-
}
|
|
2909
|
-
return null;
|
|
2910
|
-
},
|
|
2911
|
-
P = (g) => {
|
|
2912
|
-
if (g.touches.length !== 1) return;
|
|
2913
|
-
const h = g.touches.item(0);
|
|
2914
|
-
h &&
|
|
2915
|
-
((o = h.identifier), (i = h.clientY), (u = 0), (l = y(h.clientX, h.clientY, g.target)));
|
|
2916
|
-
},
|
|
2917
|
-
x = (g) => {
|
|
2918
|
-
var z, X, oe, Q, b, L, G, V;
|
|
2919
|
-
const h = O(g.touches) ?? g.touches.item(0);
|
|
2920
|
-
if (!h || (l || ((l = y(h.clientX, h.clientY, g.target)), l && (u = 0)), l)) return;
|
|
2921
|
-
const k = h.clientY,
|
|
2922
|
-
D = i - k;
|
|
2923
|
-
if (((i = k), D === 0)) return;
|
|
2924
|
-
let q = !1,
|
|
2925
|
-
F = !1;
|
|
2926
|
-
const A = (e == null ? void 0 : e()) ?? null;
|
|
2927
|
-
if (A) {
|
|
2928
|
-
const C = A == null ? void 0 : A._core,
|
|
2929
|
-
v =
|
|
2930
|
-
((Q =
|
|
2931
|
-
(oe =
|
|
2932
|
-
(X =
|
|
2933
|
-
(z = C == null ? void 0 : C._renderService) == null
|
|
2934
|
-
? void 0
|
|
2935
|
-
: z.dimensions) == null
|
|
2936
|
-
? void 0
|
|
2937
|
-
: X.css) == null
|
|
2938
|
-
? void 0
|
|
2939
|
-
: oe.cell) == null
|
|
2940
|
-
? void 0
|
|
2941
|
-
: Q.height) ?? 18;
|
|
2942
|
-
u += D * ir;
|
|
2943
|
-
const E = u > 0 ? Math.floor(u / v) : Math.ceil(u / v);
|
|
2944
|
-
if (typeof A.handleViewportGesture == 'function')
|
|
2945
|
-
E !== 0 &&
|
|
2946
|
-
((q = A.handleViewportGesture({
|
|
2947
|
-
source: 'touch',
|
|
2948
|
-
deltaY: E * v,
|
|
2949
|
-
clientX: h.clientX,
|
|
2950
|
-
clientY: h.clientY,
|
|
2951
|
-
})),
|
|
2952
|
-
(u -= E * v));
|
|
2953
|
-
else if (E !== 0) {
|
|
2954
|
-
const Y =
|
|
2955
|
-
((L = (b = A.buffer) == null ? void 0 : b.active) == null ? void 0 : L.viewportY) ??
|
|
2956
|
-
0;
|
|
2957
|
-
A.scrollLines(E);
|
|
2958
|
-
const te =
|
|
2959
|
-
((V = (G = A.buffer) == null ? void 0 : G.active) == null ? void 0 : V.viewportY) ??
|
|
2960
|
-
0;
|
|
2961
|
-
(q = Y !== te), (F = E < 0 && Y <= 0 && te <= 0), (u -= E * v);
|
|
2962
|
-
}
|
|
2963
|
-
} else {
|
|
2964
|
-
const C = M();
|
|
2965
|
-
if (C.length === 0) return;
|
|
2966
|
-
for (const v of C) {
|
|
2967
|
-
const E = v.scrollTop;
|
|
2968
|
-
v.scrollTop += D;
|
|
2969
|
-
const Y = v.scrollTop;
|
|
2970
|
-
Math.abs(Y - E) > 0 && (q = !0), D < 0 && Y <= 0 && (F = !0);
|
|
2971
|
-
}
|
|
2972
|
-
if (!q) {
|
|
2973
|
-
const v = s.querySelector('.xterm');
|
|
2974
|
-
if (v instanceof HTMLElement) {
|
|
2975
|
-
const E = new WheelEvent('wheel', {
|
|
2976
|
-
bubbles: !0,
|
|
2977
|
-
cancelable: !0,
|
|
2978
|
-
deltaMode: WheelEvent.DOM_DELTA_PIXEL,
|
|
2979
|
-
deltaY: D,
|
|
2980
|
-
}),
|
|
2981
|
-
Y = v.dispatchEvent(E);
|
|
2982
|
-
q = E.defaultPrevented || !Y;
|
|
2983
|
-
}
|
|
2984
|
-
}
|
|
2985
|
-
}
|
|
2986
|
-
g.cancelable && (q || F) && g.preventDefault();
|
|
2987
|
-
},
|
|
2988
|
-
T = (g) => {
|
|
2989
|
-
o === null || !O(g.changedTouches) || ((o = null), (u = 0), (l = !1));
|
|
2990
|
-
};
|
|
2991
|
-
return (
|
|
2992
|
-
s.addEventListener('touchstart', P, { passive: !0 }),
|
|
2993
|
-
s.addEventListener('touchmove', x, { passive: !1 }),
|
|
2994
|
-
s.addEventListener('touchend', T, { passive: !0 }),
|
|
2995
|
-
s.addEventListener('touchcancel', T, { passive: !0 }),
|
|
2996
|
-
() => {
|
|
2997
|
-
(t.current = !1),
|
|
2998
|
-
s.removeEventListener('touchstart', P),
|
|
2999
|
-
s.removeEventListener('touchmove', x),
|
|
3000
|
-
s.removeEventListener('touchend', T),
|
|
3001
|
-
s.removeEventListener('touchcancel', T);
|
|
3002
|
-
}
|
|
3003
|
-
);
|
|
3004
|
-
}, [n, e]),
|
|
3005
|
-
t
|
|
3006
|
-
);
|
|
3007
|
-
}
|
|
3008
|
-
function ar({ now: n, remoteSize: e, pendingLocalSize: t, ttlMs: s = 2e3 }) {
|
|
3009
|
-
return !t || n - t.at > s ? !0 : t.cols === e.cols && t.rows === e.rows;
|
|
3010
|
-
}
|
|
3011
|
-
function cr({ currentSize: n, containerSize: e, force: t = !1 }) {
|
|
3012
|
-
return t ? !0 : n.cols !== e.cols || n.rows !== e.rows;
|
|
3013
|
-
}
|
|
3014
|
-
function dr({
|
|
3015
|
-
deviceId: n,
|
|
3016
|
-
paneId: e,
|
|
3017
|
-
deviceConnected: t,
|
|
3018
|
-
isSelectionInvalid: s,
|
|
3019
|
-
onResize: r,
|
|
3020
|
-
onSync: i,
|
|
3021
|
-
getContainerRect: o,
|
|
3022
|
-
}) {
|
|
3023
|
-
const l = d.useRef(null),
|
|
3024
|
-
u = d.useRef(null),
|
|
3025
|
-
c = d.useRef(null),
|
|
3026
|
-
y = d.useRef(null),
|
|
3027
|
-
M = d.useRef(0),
|
|
3028
|
-
O = d.useRef([]),
|
|
3029
|
-
P = d.useRef(null),
|
|
3030
|
-
x = d.useRef(null),
|
|
3031
|
-
T = d.useRef(o),
|
|
3032
|
-
g = d.useRef(!1),
|
|
3033
|
-
h = d.useRef(r),
|
|
3034
|
-
k = d.useRef(i);
|
|
3035
|
-
d.useEffect(() => {
|
|
3036
|
-
h.current = r;
|
|
3037
|
-
}, [r]),
|
|
3038
|
-
d.useEffect(() => {
|
|
3039
|
-
k.current = i;
|
|
3040
|
-
}, [i]),
|
|
3041
|
-
d.useEffect(() => {
|
|
3042
|
-
T.current = o;
|
|
3043
|
-
}, [o]);
|
|
3044
|
-
const D = d.useCallback(() => {
|
|
3045
|
-
var Y, te, _, S, B, N, $, K, le, H;
|
|
3046
|
-
const b = x.current,
|
|
3047
|
-
L = P.current;
|
|
3048
|
-
if (!b || !L || !b.element) return null;
|
|
3049
|
-
let G;
|
|
3050
|
-
try {
|
|
3051
|
-
const ae = L.proposeDimensions();
|
|
3052
|
-
if (!ae) throw new Error('fitAddon.proposeDimensions() returned null');
|
|
3053
|
-
G = Math.max(2, ae.cols);
|
|
3054
|
-
} catch {
|
|
3055
|
-
const ae = b._core,
|
|
3056
|
-
ce =
|
|
3057
|
-
((S =
|
|
3058
|
-
(_ =
|
|
3059
|
-
(te =
|
|
3060
|
-
(Y = ae == null ? void 0 : ae._renderService) == null ? void 0 : Y.dimensions) ==
|
|
3061
|
-
null
|
|
3062
|
-
? void 0
|
|
3063
|
-
: te.css) == null
|
|
3064
|
-
? void 0
|
|
3065
|
-
: _.cell) == null
|
|
3066
|
-
? void 0
|
|
3067
|
-
: S.width) ?? 9,
|
|
3068
|
-
ee = (B = T.current) == null ? void 0 : B.call(T);
|
|
3069
|
-
if (!ee || ee.width === 0) return null;
|
|
3070
|
-
G = Math.max(2, Math.floor(ee.width / ce));
|
|
3071
|
-
}
|
|
3072
|
-
const V = (N = T.current) == null ? void 0 : N.call(T);
|
|
3073
|
-
if (!V || V.height === 0) return null;
|
|
3074
|
-
const C = b._core,
|
|
3075
|
-
v =
|
|
3076
|
-
((H =
|
|
3077
|
-
(le =
|
|
3078
|
-
(K = ($ = C == null ? void 0 : C._renderService) == null ? void 0 : $.dimensions) ==
|
|
3079
|
-
null
|
|
3080
|
-
? void 0
|
|
3081
|
-
: K.css) == null
|
|
3082
|
-
? void 0
|
|
3083
|
-
: le.cell) == null
|
|
3084
|
-
? void 0
|
|
3085
|
-
: H.height) ?? 17,
|
|
3086
|
-
E = Math.max(2, Math.floor(V.height / v));
|
|
3087
|
-
return { cols: G, rows: E };
|
|
3088
|
-
}, []),
|
|
3089
|
-
q = d.useCallback((b, L) => {
|
|
3090
|
-
const G = x.current;
|
|
3091
|
-
G && ((G.cols === b && G.rows === L) || G.resize(b, L));
|
|
3092
|
-
}, []),
|
|
3093
|
-
F = d.useCallback(
|
|
3094
|
-
(b, L = !1) => {
|
|
3095
|
-
if (!n || !e || !t || (s && b !== 'sync') || (!L && Date.now() < M.current) || !x.current)
|
|
3096
|
-
return !1;
|
|
3097
|
-
const V = D();
|
|
3098
|
-
if (!V) return !1;
|
|
3099
|
-
const { cols: C, rows: v } = V,
|
|
3100
|
-
E = c.current;
|
|
3101
|
-
return !L && E && E.cols === C && E.rows === v
|
|
3102
|
-
? (q(C, v), !0)
|
|
3103
|
-
: (q(C, v),
|
|
3104
|
-
b === 'sync' ? k.current(C, v) : h.current(C, v),
|
|
3105
|
-
(c.current = { cols: C, rows: v }),
|
|
3106
|
-
(y.current = { cols: C, rows: v, at: Date.now() }),
|
|
3107
|
-
!0);
|
|
3108
|
-
},
|
|
3109
|
-
[q, t, n, s, D, e]
|
|
3110
|
-
),
|
|
3111
|
-
A = d.useCallback(
|
|
3112
|
-
(b = 'resize', L = {}) => {
|
|
3113
|
-
const { immediate: G = !1, force: V = !1 } = L;
|
|
3114
|
-
u.current !== null && (window.clearTimeout(u.current), (u.current = null)),
|
|
3115
|
-
l.current !== null && (cancelAnimationFrame(l.current), (l.current = null));
|
|
3116
|
-
const C = () => {
|
|
3117
|
-
l.current = requestAnimationFrame(() => {
|
|
3118
|
-
(l.current = null), F(b, V);
|
|
3119
|
-
});
|
|
3120
|
-
};
|
|
3121
|
-
if (G) {
|
|
3122
|
-
C();
|
|
3123
|
-
return;
|
|
3124
|
-
}
|
|
3125
|
-
u.current = window.setTimeout(() => {
|
|
3126
|
-
(u.current = null), C();
|
|
3127
|
-
}, 150);
|
|
3128
|
-
},
|
|
3129
|
-
[F]
|
|
3130
|
-
),
|
|
3131
|
-
z = d.useCallback(() => {
|
|
3132
|
-
for (const b of O.current) window.clearTimeout(b);
|
|
3133
|
-
O.current = [];
|
|
3134
|
-
}, []),
|
|
3135
|
-
X = d.useCallback(() => {
|
|
3136
|
-
var L;
|
|
3137
|
-
z(), A('sync', { immediate: !0, force: !0 });
|
|
3138
|
-
const b = window.setTimeout(() => {
|
|
3139
|
-
A('sync', { immediate: !0, force: !0 });
|
|
3140
|
-
}, 60);
|
|
3141
|
-
O.current.push(b),
|
|
3142
|
-
typeof document < 'u' &&
|
|
3143
|
-
'fonts' in document &&
|
|
3144
|
-
(L = document.fonts) != null &&
|
|
3145
|
-
L.ready &&
|
|
3146
|
-
document.fonts.ready
|
|
3147
|
-
.then(() => {
|
|
3148
|
-
A('sync', { immediate: !0, force: !0 });
|
|
3149
|
-
})
|
|
3150
|
-
.catch(() => {});
|
|
3151
|
-
}, [z, A]);
|
|
3152
|
-
d.useEffect(() => {
|
|
3153
|
-
let b = null;
|
|
3154
|
-
const L = () => {
|
|
3155
|
-
b !== null && cancelAnimationFrame(b),
|
|
3156
|
-
(b = requestAnimationFrame(() => {
|
|
3157
|
-
(b = null), A('resize');
|
|
3158
|
-
}));
|
|
3159
|
-
};
|
|
3160
|
-
return (
|
|
3161
|
-
window.addEventListener('resize', L),
|
|
3162
|
-
() => {
|
|
3163
|
-
window.removeEventListener('resize', L), b !== null && cancelAnimationFrame(b);
|
|
3164
|
-
}
|
|
3165
|
-
);
|
|
3166
|
-
}, [A]),
|
|
3167
|
-
d.useEffect(() => {
|
|
3168
|
-
const b = () => {
|
|
3169
|
-
var Y;
|
|
3170
|
-
const C = x.current,
|
|
3171
|
-
v = D();
|
|
3172
|
-
if (!C || !v) return;
|
|
3173
|
-
if (
|
|
3174
|
-
!cr({
|
|
3175
|
-
currentSize: { cols: Math.max(2, C.cols), rows: Math.max(2, C.rows) },
|
|
3176
|
-
containerSize: v,
|
|
3177
|
-
})
|
|
3178
|
-
) {
|
|
3179
|
-
(Y = C.refresh) == null || Y.call(C);
|
|
3180
|
-
return;
|
|
3181
|
-
}
|
|
3182
|
-
A('sync', { force: !0 });
|
|
3183
|
-
},
|
|
3184
|
-
L = () => {
|
|
3185
|
-
if (document.visibilityState !== 'visible') {
|
|
3186
|
-
g.current = !0;
|
|
3187
|
-
return;
|
|
3188
|
-
}
|
|
3189
|
-
g.current && ((g.current = !1), b());
|
|
3190
|
-
},
|
|
3191
|
-
G = () => {
|
|
3192
|
-
g.current = !0;
|
|
3193
|
-
},
|
|
3194
|
-
V = () => {
|
|
3195
|
-
g.current && ((g.current = !1), b());
|
|
3196
|
-
};
|
|
3197
|
-
return (
|
|
3198
|
-
document.addEventListener('visibilitychange', L),
|
|
3199
|
-
window.addEventListener('blur', G),
|
|
3200
|
-
window.addEventListener('focus', V),
|
|
3201
|
-
() => {
|
|
3202
|
-
document.removeEventListener('visibilitychange', L),
|
|
3203
|
-
window.removeEventListener('blur', G),
|
|
3204
|
-
window.removeEventListener('focus', V);
|
|
3205
|
-
}
|
|
3206
|
-
);
|
|
3207
|
-
}, [D, A]),
|
|
3208
|
-
d.useEffect(
|
|
3209
|
-
() => () => {
|
|
3210
|
-
z(),
|
|
3211
|
-
u.current !== null && window.clearTimeout(u.current),
|
|
3212
|
-
l.current !== null && cancelAnimationFrame(l.current);
|
|
3213
|
-
},
|
|
3214
|
-
[z]
|
|
3215
|
-
);
|
|
3216
|
-
const oe = d.useCallback((b) => {
|
|
3217
|
-
P.current = b;
|
|
3218
|
-
}, []),
|
|
3219
|
-
Q = d.useCallback((b) => {
|
|
3220
|
-
x.current = b;
|
|
3221
|
-
}, []);
|
|
3222
|
-
return {
|
|
3223
|
-
scheduleResize: A,
|
|
3224
|
-
runPostSelectResize: X,
|
|
3225
|
-
clearPostSelectResizeTimers: z,
|
|
3226
|
-
setFitAddon: oe,
|
|
3227
|
-
setTerminal: Q,
|
|
3228
|
-
lastReportedSize: c,
|
|
3229
|
-
pendingLocalSize: y,
|
|
3230
|
-
suppressLocalResizeUntil: M,
|
|
3231
|
-
};
|
|
3232
|
-
}
|
|
3233
|
-
const ur = { fontFamily: nr, fontSize: 13, scrollback: 1e4 },
|
|
3234
|
-
nt = 'tmex:terminal-mode-cache';
|
|
3235
|
-
function hr(n, e) {
|
|
3236
|
-
try {
|
|
3237
|
-
const t = sessionStorage.getItem(nt);
|
|
3238
|
-
return t ? (JSON.parse(t)[`${n}:${e}`] ?? null) : null;
|
|
3239
|
-
} catch {
|
|
3240
|
-
return null;
|
|
3241
|
-
}
|
|
3242
|
-
}
|
|
3243
|
-
function fr(n, e, t) {
|
|
3244
|
-
try {
|
|
3245
|
-
const s = sessionStorage.getItem(nt),
|
|
3246
|
-
r = s ? JSON.parse(s) : {},
|
|
3247
|
-
i = `${n}:${e}`;
|
|
3248
|
-
t ? (r[i] = t) : delete r[i], sessionStorage.setItem(nt, JSON.stringify(r));
|
|
3249
|
-
} catch {}
|
|
3250
|
-
}
|
|
3251
|
-
function mr() {
|
|
3252
|
-
return {
|
|
3253
|
-
mouseX10: !1,
|
|
3254
|
-
mouseNormal: !0,
|
|
3255
|
-
mouseButton: !1,
|
|
3256
|
-
mouseAny: !1,
|
|
3257
|
-
mouseUtf8: !1,
|
|
3258
|
-
mouseSgr: !0,
|
|
3259
|
-
mouseSgrPixels: !1,
|
|
3260
|
-
mouseUrxvt: !1,
|
|
3261
|
-
altScroll: !0,
|
|
3262
|
-
altScreen1047: !1,
|
|
3263
|
-
altScreen1049: !1,
|
|
3264
|
-
};
|
|
3265
|
-
}
|
|
3266
|
-
function pr(n, e) {
|
|
3267
|
-
if (!e)
|
|
3268
|
-
return n
|
|
3269
|
-
? {
|
|
3270
|
-
...n,
|
|
3271
|
-
mouseX10: !1,
|
|
3272
|
-
mouseNormal: !1,
|
|
3273
|
-
mouseButton: !1,
|
|
3274
|
-
mouseAny: !1,
|
|
3275
|
-
mouseUtf8: !1,
|
|
3276
|
-
mouseSgrPixels: !1,
|
|
3277
|
-
mouseUrxvt: !1,
|
|
3278
|
-
altScreen1047: !1,
|
|
3279
|
-
altScreen1049: !1,
|
|
3280
|
-
}
|
|
3281
|
-
: null;
|
|
3282
|
-
const t = mr();
|
|
3283
|
-
if (!n) return t;
|
|
3284
|
-
const s = n.mouseNormal || n.mouseButton || n.mouseAny;
|
|
3285
|
-
return {
|
|
3286
|
-
...n,
|
|
3287
|
-
mouseX10: !1,
|
|
3288
|
-
mouseUtf8: !1,
|
|
3289
|
-
mouseSgr: !0,
|
|
3290
|
-
mouseSgrPixels: !1,
|
|
3291
|
-
mouseUrxvt: !1,
|
|
3292
|
-
altScroll: !0,
|
|
3293
|
-
altScreen1047: !1,
|
|
3294
|
-
altScreen1049: !1,
|
|
3295
|
-
mouseNormal: s ? n.mouseNormal : t.mouseNormal,
|
|
3296
|
-
};
|
|
3297
|
-
}
|
|
3298
|
-
function wr(n) {
|
|
3299
|
-
var t;
|
|
3300
|
-
const e = globalThis;
|
|
3301
|
-
(e.__tmexE2eXterm = n),
|
|
3302
|
-
(e.__tmexE2eTerminal = n),
|
|
3303
|
-
(e.__tmexE2eTerminalEngine = Pt),
|
|
3304
|
-
(e.__tmexE2eTerminalRenderer = ((t = n.getRendererKind) == null ? void 0 : t.call(n)) ?? null);
|
|
3305
|
-
}
|
|
3306
|
-
function gr(n) {
|
|
3307
|
-
if (!n) return;
|
|
3308
|
-
const e = globalThis;
|
|
3309
|
-
(e.__tmexE2eTerminal !== n && e.__tmexE2eXterm !== n) ||
|
|
3310
|
-
((e.__tmexE2eXterm = null),
|
|
3311
|
-
(e.__tmexE2eTerminal = null),
|
|
3312
|
-
(e.__tmexE2eTerminalEngine = null),
|
|
3313
|
-
(e.__tmexE2eTerminalRenderer = null),
|
|
3314
|
-
(e.__tmexE2eTerminalSelectionText = null));
|
|
3315
|
-
}
|
|
3316
|
-
const Gt = d.forwardRef(
|
|
3317
|
-
(
|
|
3318
|
-
{
|
|
3319
|
-
deviceId: n,
|
|
3320
|
-
paneId: e,
|
|
3321
|
-
theme: t,
|
|
3322
|
-
inputMode: s,
|
|
3323
|
-
deviceConnected: r,
|
|
3324
|
-
isSelectionInvalid: i,
|
|
3325
|
-
onResize: o,
|
|
3326
|
-
onSync: l,
|
|
3327
|
-
},
|
|
3328
|
-
u
|
|
3329
|
-
) => {
|
|
3330
|
-
const [c, y] = d.useState(null),
|
|
3331
|
-
M = j((_) => _.sendInput),
|
|
3332
|
-
O = d.useMemo(() => {
|
|
3333
|
-
switch (t) {
|
|
3334
|
-
case 'light':
|
|
3335
|
-
return Lt;
|
|
3336
|
-
default:
|
|
3337
|
-
return Nt;
|
|
3338
|
-
}
|
|
3339
|
-
}, [t]),
|
|
3340
|
-
P = d.useRef(null),
|
|
3341
|
-
x = d.useRef(null),
|
|
3342
|
-
T = d.useRef(null),
|
|
3343
|
-
g = d.useRef(n),
|
|
3344
|
-
h = d.useRef(e),
|
|
3345
|
-
k = d.useRef(n),
|
|
3346
|
-
D = d.useRef(e),
|
|
3347
|
-
q = d.useRef(r && !i),
|
|
3348
|
-
F = d.useRef(s),
|
|
3349
|
-
A = d.useRef(O),
|
|
3350
|
-
z = d.useRef(!1),
|
|
3351
|
-
X = d.useRef(!1),
|
|
3352
|
-
oe = d.useRef(null),
|
|
3353
|
-
Q = d.useRef(!1),
|
|
3354
|
-
b = d.useCallback((_, S, B) => {
|
|
3355
|
-
!(_ != null && _.exportModeSnapshot) || !S || !B || fr(S, B, _.exportModeSnapshot());
|
|
3356
|
-
}, []),
|
|
3357
|
-
L = d.useCallback(() => c, [c]);
|
|
3358
|
-
lr(P, L),
|
|
3359
|
-
d.useEffect(() => {
|
|
3360
|
-
(g.current = n), (h.current = e), (X.current = !1);
|
|
3361
|
-
}, [n, e]),
|
|
3362
|
-
d.useEffect(() => {
|
|
3363
|
-
q.current = r && !i;
|
|
3364
|
-
}, [r, i]),
|
|
3365
|
-
d.useEffect(() => {
|
|
3366
|
-
F.current = s;
|
|
3367
|
-
}, [s]),
|
|
3368
|
-
d.useEffect(() => {
|
|
3369
|
-
A.current = O;
|
|
3370
|
-
}, [O]);
|
|
3371
|
-
const G = d.useCallback(
|
|
3372
|
-
(_) => {
|
|
3373
|
-
if (!_ || s !== 'direct' || !q.current) return;
|
|
3374
|
-
const S = g.current,
|
|
3375
|
-
B = h.current;
|
|
3376
|
-
!S || !B || M(S, B, _, !1);
|
|
3377
|
-
},
|
|
3378
|
-
[s, M]
|
|
3379
|
-
),
|
|
3380
|
-
{
|
|
3381
|
-
pendingLocalSize: V,
|
|
3382
|
-
scheduleResize: C,
|
|
3383
|
-
runPostSelectResize: v,
|
|
3384
|
-
setFitAddon: E,
|
|
3385
|
-
setTerminal: Y,
|
|
3386
|
-
} = dr({
|
|
3387
|
-
deviceId: n,
|
|
3388
|
-
paneId: e,
|
|
3389
|
-
deviceConnected: r,
|
|
3390
|
-
isSelectionInvalid: i,
|
|
3391
|
-
onResize: o,
|
|
3392
|
-
onSync: l,
|
|
3393
|
-
getContainerRect: () => {
|
|
3394
|
-
const _ = P.current;
|
|
3395
|
-
if (!_) return null;
|
|
3396
|
-
const S = _.getBoundingClientRect();
|
|
3397
|
-
return { width: S.width, height: S.height };
|
|
3398
|
-
},
|
|
3399
|
-
});
|
|
3400
|
-
d.useEffect(() => {
|
|
3401
|
-
let _ = !1,
|
|
3402
|
-
S = null;
|
|
3403
|
-
return (
|
|
3404
|
-
tr({ ...ur, theme: A.current, disableStdin: F.current === 'editor' }).then((B) => {
|
|
3405
|
-
if (_) {
|
|
3406
|
-
B.dispose();
|
|
3407
|
-
return;
|
|
3408
|
-
}
|
|
3409
|
-
(S = B), x.current && B.open(x.current), wr(B), y(B);
|
|
3410
|
-
}),
|
|
3411
|
-
() => {
|
|
3412
|
-
(_ = !0), y(null), gr(S), S == null || S.dispose();
|
|
3413
|
-
}
|
|
3414
|
-
);
|
|
3415
|
-
}, []),
|
|
3416
|
-
d.useEffect(() => {
|
|
3417
|
-
!c || !('setTheme' in c) || c.setTheme(O);
|
|
3418
|
-
}, [c, O]),
|
|
3419
|
-
d.useEffect(() => {
|
|
3420
|
-
!c || !('setDisableStdin' in c) || c.setDisableStdin(s === 'editor');
|
|
3421
|
-
}, [c, s]);
|
|
3422
|
-
const te = d.useMemo(
|
|
3423
|
-
() =>
|
|
3424
|
-
c
|
|
3425
|
-
? {
|
|
3426
|
-
onResetTerminal: (_) => {
|
|
3427
|
-
g.current === _ &&
|
|
3428
|
-
(b(c, k.current, D.current), (Q.current = !0), c.reset(), (z.current = !1), v());
|
|
3429
|
-
},
|
|
3430
|
-
onApplyHistory: (_, S, B) => {
|
|
3431
|
-
var K;
|
|
3432
|
-
if (g.current !== _) return;
|
|
3433
|
-
const N = pr(hr(g.current, h.current), B);
|
|
3434
|
-
N && ((K = c.restoreModeSnapshot) == null || K.call(c, N));
|
|
3435
|
-
const $ = B ? rr(S) : Ft(S);
|
|
3436
|
-
(X.current = !0),
|
|
3437
|
-
c.write($),
|
|
3438
|
-
(Q.current = !1),
|
|
3439
|
-
(k.current = g.current),
|
|
3440
|
-
(D.current = h.current),
|
|
3441
|
-
b(c, g.current, h.current);
|
|
3442
|
-
},
|
|
3443
|
-
onFlushBuffer: (_, S) => {
|
|
3444
|
-
if (g.current === _) {
|
|
3445
|
-
for (const B of S) {
|
|
3446
|
-
const N = Ct(B, z.current);
|
|
3447
|
-
(z.current = N.endedWithCR), c.write(N.normalized);
|
|
3448
|
-
}
|
|
3449
|
-
X.current && (c.buffer.active.baseY <= 1 && c.scrollToTop(), (X.current = !1)),
|
|
3450
|
-
(k.current = g.current),
|
|
3451
|
-
(D.current = h.current),
|
|
3452
|
-
b(c, g.current, h.current);
|
|
3453
|
-
}
|
|
3454
|
-
},
|
|
3455
|
-
onOutput: (_, S, B) => {
|
|
3456
|
-
if (g.current !== _ || h.current !== S || !q.current) return;
|
|
3457
|
-
const N = Ct(B, z.current);
|
|
3458
|
-
(z.current = N.endedWithCR),
|
|
3459
|
-
c.write(N.normalized),
|
|
3460
|
-
X.current && (c.buffer.active.baseY <= 1 && c.scrollToTop(), (X.current = !1)),
|
|
3461
|
-
(k.current = g.current),
|
|
3462
|
-
(D.current = h.current),
|
|
3463
|
-
b(c, g.current, h.current);
|
|
3464
|
-
},
|
|
3465
|
-
}
|
|
3466
|
-
: {},
|
|
3467
|
-
[c, b, v]
|
|
3468
|
-
);
|
|
3469
|
-
return (
|
|
3470
|
-
d.useEffect(() => {
|
|
3471
|
-
c
|
|
3472
|
-
? oe.current !== c &&
|
|
3473
|
-
((z.current = !1),
|
|
3474
|
-
c.reset(),
|
|
3475
|
-
(k.current = g.current),
|
|
3476
|
-
(D.current = h.current),
|
|
3477
|
-
(oe.current = c))
|
|
3478
|
-
: (oe.current = null);
|
|
3479
|
-
}, [c]),
|
|
3480
|
-
d.useEffect(() => {
|
|
3481
|
-
if (!(!c || !n || !e))
|
|
3482
|
-
return () => {
|
|
3483
|
-
if (Q.current) {
|
|
3484
|
-
Q.current = !1;
|
|
3485
|
-
return;
|
|
3486
|
-
}
|
|
3487
|
-
b(c, k.current, D.current);
|
|
3488
|
-
};
|
|
3489
|
-
}, [n, c, e, b]),
|
|
3490
|
-
d.useEffect(() => {
|
|
3491
|
-
ut(te);
|
|
3492
|
-
}, [te]),
|
|
3493
|
-
d.useEffect(
|
|
3494
|
-
() => () => {
|
|
3495
|
-
ut({});
|
|
3496
|
-
},
|
|
3497
|
-
[]
|
|
3498
|
-
),
|
|
3499
|
-
d.useEffect(() => {
|
|
3500
|
-
if (!c) {
|
|
3501
|
-
(T.current = null), E(null), Y(null);
|
|
3502
|
-
return;
|
|
3503
|
-
}
|
|
3504
|
-
const _ = new er();
|
|
3505
|
-
return (
|
|
3506
|
-
c.loadAddon(_),
|
|
3507
|
-
(T.current = _),
|
|
3508
|
-
E(_),
|
|
3509
|
-
Y(c),
|
|
3510
|
-
v(),
|
|
3511
|
-
() => {
|
|
3512
|
-
try {
|
|
3513
|
-
_.dispose();
|
|
3514
|
-
} finally {
|
|
3515
|
-
(T.current = null), E(null), Y(null);
|
|
3516
|
-
}
|
|
3517
|
-
}
|
|
3518
|
-
);
|
|
3519
|
-
}, [c, v, E, Y]),
|
|
3520
|
-
d.useEffect(() => {
|
|
3521
|
-
const _ = P.current;
|
|
3522
|
-
if (!_) return;
|
|
3523
|
-
let S = null;
|
|
3524
|
-
const B = new ResizeObserver(() => {
|
|
3525
|
-
S !== null && cancelAnimationFrame(S),
|
|
3526
|
-
(S = requestAnimationFrame(() => {
|
|
3527
|
-
(S = null), C('resize');
|
|
3528
|
-
}));
|
|
3529
|
-
});
|
|
3530
|
-
return (
|
|
3531
|
-
B.observe(_),
|
|
3532
|
-
() => {
|
|
3533
|
-
B.disconnect(), S !== null && cancelAnimationFrame(S);
|
|
3534
|
-
}
|
|
3535
|
-
);
|
|
3536
|
-
}, [C]),
|
|
3537
|
-
d.useEffect(() => {
|
|
3538
|
-
if (!c || !n || !e) return;
|
|
3539
|
-
const _ = c.onData((S) => {
|
|
3540
|
-
!r || i || G(S);
|
|
3541
|
-
});
|
|
3542
|
-
return (
|
|
3543
|
-
c.attachCustomKeyEventHandler((S) =>
|
|
3544
|
-
!r || i || S.type !== 'keydown' || s !== 'direct'
|
|
3545
|
-
? !0
|
|
3546
|
-
: S.shiftKey && S.key === 'Enter'
|
|
3547
|
-
? (S.preventDefault(), G('\x1B[13;2u'), !1)
|
|
3548
|
-
: !0
|
|
3549
|
-
),
|
|
3550
|
-
() => {
|
|
3551
|
-
_.dispose(), c.attachCustomKeyEventHandler(() => !0);
|
|
3552
|
-
}
|
|
3553
|
-
);
|
|
3554
|
-
}, [c, r, i, s, G, n, e]),
|
|
3555
|
-
d.useImperativeHandle(
|
|
3556
|
-
u,
|
|
3557
|
-
() => ({
|
|
3558
|
-
write: (_) => (c == null ? void 0 : c.write(_)),
|
|
3559
|
-
reset: () => {
|
|
3560
|
-
c == null || c.reset(), (z.current = !1);
|
|
3561
|
-
},
|
|
3562
|
-
scrollToBottom: () => (c == null ? void 0 : c.scrollToBottom()),
|
|
3563
|
-
resize: (_, S) => (c == null ? void 0 : c.resize(_, S)),
|
|
3564
|
-
getTerminal: () => c ?? null,
|
|
3565
|
-
getSize: () => (c ? { cols: Math.max(2, c.cols), rows: Math.max(2, c.rows) } : null),
|
|
3566
|
-
runPostSelectResize: () => v(),
|
|
3567
|
-
scheduleResize: (_, S) => C(_, S),
|
|
3568
|
-
calculateSizeFromContainer: () => {
|
|
3569
|
-
var ae, ce, ee, ne, se, Se, Ue, ze, Ye, _e, J, Te, me, ve, Me, de;
|
|
3570
|
-
const _ = P.current,
|
|
3571
|
-
S = c,
|
|
3572
|
-
B = T.current;
|
|
3573
|
-
if (!_ || !S) return null;
|
|
3574
|
-
const N = _.getBoundingClientRect();
|
|
3575
|
-
if (N.width === 0 || N.height === 0) return null;
|
|
3576
|
-
const $ = S._core;
|
|
3577
|
-
let K;
|
|
3578
|
-
if (B)
|
|
3579
|
-
try {
|
|
3580
|
-
const re = B.proposeDimensions();
|
|
3581
|
-
if (re) K = Math.max(2, re.cols);
|
|
3582
|
-
else {
|
|
3583
|
-
const he =
|
|
3584
|
-
((ne =
|
|
3585
|
-
(ee =
|
|
3586
|
-
(ce =
|
|
3587
|
-
(ae = $ == null ? void 0 : $._renderService) == null
|
|
3588
|
-
? void 0
|
|
3589
|
-
: ae.dimensions) == null
|
|
3590
|
-
? void 0
|
|
3591
|
-
: ce.css) == null
|
|
3592
|
-
? void 0
|
|
3593
|
-
: ee.cell) == null
|
|
3594
|
-
? void 0
|
|
3595
|
-
: ne.width) ?? 9;
|
|
3596
|
-
K = Math.max(2, Math.floor(N.width / he));
|
|
3597
|
-
}
|
|
3598
|
-
} catch {
|
|
3599
|
-
const re =
|
|
3600
|
-
((ze =
|
|
3601
|
-
(Ue =
|
|
3602
|
-
(Se =
|
|
3603
|
-
(se = $ == null ? void 0 : $._renderService) == null
|
|
3604
|
-
? void 0
|
|
3605
|
-
: se.dimensions) == null
|
|
3606
|
-
? void 0
|
|
3607
|
-
: Se.css) == null
|
|
3608
|
-
? void 0
|
|
3609
|
-
: Ue.cell) == null
|
|
3610
|
-
? void 0
|
|
3611
|
-
: ze.width) ?? 9;
|
|
3612
|
-
K = Math.max(2, Math.floor(N.width / re));
|
|
3613
|
-
}
|
|
3614
|
-
else {
|
|
3615
|
-
const re =
|
|
3616
|
-
((Te =
|
|
3617
|
-
(J =
|
|
3618
|
-
(_e =
|
|
3619
|
-
(Ye = $ == null ? void 0 : $._renderService) == null
|
|
3620
|
-
? void 0
|
|
3621
|
-
: Ye.dimensions) == null
|
|
3622
|
-
? void 0
|
|
3623
|
-
: _e.css) == null
|
|
3624
|
-
? void 0
|
|
3625
|
-
: J.cell) == null
|
|
3626
|
-
? void 0
|
|
3627
|
-
: Te.width) ?? 9;
|
|
3628
|
-
K = Math.max(2, Math.floor(N.width / re));
|
|
3629
|
-
}
|
|
3630
|
-
const le =
|
|
3631
|
-
((de =
|
|
3632
|
-
(Me =
|
|
3633
|
-
(ve =
|
|
3634
|
-
(me = $ == null ? void 0 : $._renderService) == null
|
|
3635
|
-
? void 0
|
|
3636
|
-
: me.dimensions) == null
|
|
3637
|
-
? void 0
|
|
3638
|
-
: ve.css) == null
|
|
3639
|
-
? void 0
|
|
3640
|
-
: Me.cell) == null
|
|
3641
|
-
? void 0
|
|
3642
|
-
: de.height) ?? 17,
|
|
3643
|
-
H = Math.max(2, Math.floor(N.height / le));
|
|
3644
|
-
return { cols: K, rows: H };
|
|
3645
|
-
},
|
|
3646
|
-
getPendingLocalSize: () => V.current,
|
|
3647
|
-
}),
|
|
3648
|
-
[c, V, v, C]
|
|
3649
|
-
),
|
|
3650
|
-
m.jsx('div', {
|
|
3651
|
-
ref: P,
|
|
3652
|
-
className: 'h-full w-full relative',
|
|
3653
|
-
style: { backgroundColor: O.background },
|
|
3654
|
-
'data-terminal-engine': Pt,
|
|
3655
|
-
children: m.jsx('div', { ref: x, className: 'absolute inset-0' }),
|
|
3656
|
-
})
|
|
3657
|
-
);
|
|
3658
|
-
}
|
|
3659
|
-
);
|
|
3660
|
-
Gt.displayName = 'Terminal';
|
|
3661
|
-
const yr = 1200,
|
|
3662
|
-
Sr = 2e3;
|
|
3663
|
-
function pe(n, e) {
|
|
3664
|
-
return !n || !e ? !1 : n.windowId === e.windowId && n.paneId === e.paneId;
|
|
3665
|
-
}
|
|
3666
|
-
function Ut(n, e) {
|
|
3667
|
-
const t = n.filter((s) => e - s.at < yr);
|
|
3668
|
-
return t.length === 0 ? null : t.reduce((s, r) => (r.at > s.at ? r : s));
|
|
3669
|
-
}
|
|
3670
|
-
function Ce(n, e = Date.now()) {
|
|
3671
|
-
return !n || e - n.at > Sr ? null : n;
|
|
3672
|
-
}
|
|
3673
|
-
function _r(n) {
|
|
3674
|
-
const e = n.now ?? Date.now(),
|
|
3675
|
-
t = Ut(n.recentSelectRequests, e);
|
|
3676
|
-
if (
|
|
3677
|
-
(t && !pe(t, n.activePaneFromEvent)) ||
|
|
3678
|
-
pe(n.currentRoute, n.activePaneFromEvent) ||
|
|
3679
|
-
pe(n.lastHandledActive, n.activePaneFromEvent)
|
|
3680
|
-
)
|
|
3681
|
-
return !0;
|
|
3682
|
-
const s = Ce(n.pendingUserSelection, e);
|
|
3683
|
-
return !!(s && !pe(s, n.activePaneFromEvent));
|
|
3684
|
-
}
|
|
3685
|
-
function Tr(n) {
|
|
3686
|
-
const e = n.now ?? Date.now(),
|
|
3687
|
-
t = Ut(n.recentSelectRequests, e),
|
|
3688
|
-
s = Ce(n.pendingUserSelection, e);
|
|
3689
|
-
return !!((s && !pe(s, n.snapshotActive)) || (t && !pe(t, n.snapshotActive)));
|
|
3690
|
-
}
|
|
3691
|
-
function br(n) {
|
|
3692
|
-
const e = n.now ?? Date.now(),
|
|
3693
|
-
t = Ce(n.pendingUserSelection, e);
|
|
3694
|
-
return !(
|
|
3695
|
-
(t && pe(t, n.routeTarget)) ||
|
|
3696
|
-
(n.snapshotActive && pe(n.snapshotActive, n.routeTarget))
|
|
3697
|
-
);
|
|
3698
|
-
}
|
|
3699
|
-
function xr() {
|
|
3700
|
-
const n = st.getState().settings;
|
|
3701
|
-
return (n == null ? void 0 : n.siteName) || 'tmex';
|
|
3702
|
-
}
|
|
3703
|
-
function vt(n) {
|
|
3704
|
-
const e = n == null ? void 0 : n.trim();
|
|
3705
|
-
return e && e.length > 0 ? e : '?';
|
|
3706
|
-
}
|
|
3707
|
-
function zt({ paneIdx: n, windowIdx: e, paneTitle: t, windowName: s, deviceName: r }) {
|
|
3708
|
-
const i = e ?? '?',
|
|
3709
|
-
o = n ?? '?',
|
|
3710
|
-
l = vt(t ?? s),
|
|
3711
|
-
u = vt(r);
|
|
3712
|
-
return `${i}/${o}: ${l}@${u}`;
|
|
3713
|
-
}
|
|
3714
|
-
function Er(n) {
|
|
3715
|
-
const e = xr();
|
|
3716
|
-
return n != null && n.trim() ? `[${e}]${n}` : e;
|
|
3717
|
-
}
|
|
3718
|
-
function Rr() {
|
|
3719
|
-
if (typeof navigator > 'u') return !1;
|
|
3720
|
-
const n = navigator.userAgent,
|
|
3721
|
-
e = /iPad|iPhone|iPod/.test(n),
|
|
3722
|
-
t = navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1;
|
|
3723
|
-
return e || t;
|
|
3724
|
-
}
|
|
3725
|
-
const Cr = [
|
|
3726
|
-
{ key: 'enter', label: 'ENTER', payload: '\r' },
|
|
3727
|
-
{ key: 'ctrl-c', label: 'CTRL-C', payload: '' },
|
|
3728
|
-
{ key: 'ctrl-d', label: 'CTRL-D', payload: '' },
|
|
3729
|
-
{ key: 'up', label: '↑', payload: '\x1B[A' },
|
|
3730
|
-
{ key: 'down', label: '↓', payload: '\x1B[B' },
|
|
3731
|
-
{ key: 'left', label: '←', payload: '\x1B[D' },
|
|
3732
|
-
{ key: 'right', label: '→', payload: '\x1B[C' },
|
|
3733
|
-
{ key: 'shift-enter', label: 'SHIFT+ENTER', payload: '\x1B[13;2u' },
|
|
3734
|
-
{ key: 'tab', label: 'TAB', payload: ' ' },
|
|
3735
|
-
{ key: 'backspace', label: 'BACKSPACE', payload: '\b' },
|
|
3736
|
-
{ key: 'esc', label: 'ESC', payload: '\x1B' },
|
|
3737
|
-
{ key: 'delete', label: 'DELETE', payload: '' },
|
|
3738
|
-
{ key: ':', label: ':', payload: ':' },
|
|
3739
|
-
{ key: '/', label: '/', payload: '/' },
|
|
3740
|
-
{ key: "'", label: "'", payload: "'" },
|
|
3741
|
-
{ key: '"', label: '"', payload: '"' },
|
|
3742
|
-
{ key: '`', label: '`', payload: '`' },
|
|
3743
|
-
],
|
|
3744
|
-
Mt = d.memo(({ onSend: e, onFocusEditor: t, disabled: s, isMobile: r, inputMode: i }) =>
|
|
3745
|
-
m.jsx('div', {
|
|
3746
|
-
className: 'terminal-shortcuts-strip my-2 bg-muted rounded-xl',
|
|
3747
|
-
'data-testid': 'terminal-shortcuts-strip',
|
|
3748
|
-
children: m.jsx('div', {
|
|
3749
|
-
className: 'shortcut-row flex items-center gap-1.5 p-2 overflow-x-auto scrollbar-thin',
|
|
3750
|
-
'data-testid': 'editor-shortcuts-row',
|
|
3751
|
-
children: Cr.map((o) =>
|
|
3752
|
-
m.jsx(
|
|
3753
|
-
we,
|
|
3754
|
-
{
|
|
3755
|
-
variant: 'secondary',
|
|
3756
|
-
size: 'sm',
|
|
3757
|
-
className:
|
|
3758
|
-
'h-7 min-w-9 px-2.5 rounded-full text-[11px] font-medium tracking-wide shrink-0 [@media(any-pointer:coarse)]:h-9 [@media(any-pointer:coarse)]:min-w-10 [@media(any-pointer:coarse)]:px-3',
|
|
3759
|
-
title: o.label,
|
|
3760
|
-
'aria-label': o.label,
|
|
3761
|
-
'data-testid': `editor-shortcut-${o.key}`,
|
|
3762
|
-
onPointerDown: (l) => l.preventDefault(),
|
|
3763
|
-
onClick: () => {
|
|
3764
|
-
e(o.payload), r && i === 'editor' && (t == null || t());
|
|
3765
|
-
},
|
|
3766
|
-
disabled: s,
|
|
3767
|
-
children: o.label,
|
|
3768
|
-
},
|
|
3769
|
-
o.key
|
|
3770
|
-
)
|
|
3771
|
-
),
|
|
3772
|
-
}),
|
|
3773
|
-
})
|
|
3774
|
-
);
|
|
3775
|
-
function Or() {
|
|
3776
|
-
var dt;
|
|
3777
|
-
const { t: n } = Dt(),
|
|
3778
|
-
{ deviceId: e, windowId: t, paneId: s } = rt(),
|
|
3779
|
-
r = Qt(),
|
|
3780
|
-
i = d.useRef(null),
|
|
3781
|
-
o = d.useRef(null),
|
|
3782
|
-
l = d.useRef(null),
|
|
3783
|
-
u = d.useRef(null),
|
|
3784
|
-
c = d.useRef(!1),
|
|
3785
|
-
y = d.useRef(!1),
|
|
3786
|
-
M = d.useRef(null),
|
|
3787
|
-
O = j((a) => a.selectPane),
|
|
3788
|
-
P = j((a) => (e ? a.snapshots[e] : void 0)),
|
|
3789
|
-
x = j((a) => {
|
|
3790
|
-
var p;
|
|
3791
|
-
return e ? ((p = a.deviceErrors) == null ? void 0 : p[e]) : void 0;
|
|
3792
|
-
}),
|
|
3793
|
-
T = j((a) => {
|
|
3794
|
-
var p;
|
|
3795
|
-
return e ? (((p = a.deviceConnected) == null ? void 0 : p[e]) ?? !1) : !1;
|
|
3796
|
-
}),
|
|
3797
|
-
g = st((a) => {
|
|
3798
|
-
var p;
|
|
3799
|
-
return ((p = a.settings) == null ? void 0 : p.siteName) ?? 'tmex';
|
|
3800
|
-
}),
|
|
3801
|
-
h = d.useMemo(() => it(s), [s]),
|
|
3802
|
-
k = d.useMemo(() => (e && h ? `${e}:${h}` : null), [e, h]),
|
|
3803
|
-
[D, q] = d.useState(!1),
|
|
3804
|
-
[F, A] = d.useState(''),
|
|
3805
|
-
[z, X] = d.useState(!1),
|
|
3806
|
-
oe = d.useRef(!1),
|
|
3807
|
-
Q = !T || !h,
|
|
3808
|
-
[b, L] = d.useState(0),
|
|
3809
|
-
[G, V] = d.useState(0),
|
|
3810
|
-
[C, v] = d.useState(!1),
|
|
3811
|
-
E = ue((a) => a.inputMode),
|
|
3812
|
-
Y = ue((a) => a.theme),
|
|
3813
|
-
te = ue((a) => a.editorSendWithEnter),
|
|
3814
|
-
_ = ue((a) => a.setEditorSendWithEnter),
|
|
3815
|
-
S = ue((a) => a.addEditorHistory),
|
|
3816
|
-
B = ue((a) => a.setEditorDraft),
|
|
3817
|
-
N = ue((a) => a.removeEditorDraft),
|
|
3818
|
-
$ = ue((a) => (k ? (a.editorDrafts[k] ?? '') : '')),
|
|
3819
|
-
K = d.useMemo(() => Rr(), []),
|
|
3820
|
-
le = D && E === 'editor' && K && z,
|
|
3821
|
-
H = (dt = P == null ? void 0 : P.session) == null ? void 0 : dt.windows,
|
|
3822
|
-
ae = Y === 'light' ? Lt : Nt,
|
|
3823
|
-
{ data: ce } = Zt({
|
|
3824
|
-
queryKey: ['devices'],
|
|
3825
|
-
queryFn: async () => {
|
|
3826
|
-
const a = await fetch('/api/devices');
|
|
3827
|
-
if (!a.ok) throw new Error('Failed to fetch devices');
|
|
3828
|
-
return a.json();
|
|
3829
|
-
},
|
|
3830
|
-
throwOnError: !1,
|
|
3831
|
-
}),
|
|
3832
|
-
ee = d.useMemo(() => {
|
|
3833
|
-
if (e) return ce == null ? void 0 : ce.devices.find((a) => a.id === e);
|
|
3834
|
-
}, [e, ce == null ? void 0 : ce.devices]),
|
|
3835
|
-
ne = d.useMemo(() => {
|
|
3836
|
-
if (!(!t || !H)) return H.find((a) => a.id === t);
|
|
3837
|
-
}, [t, H]),
|
|
3838
|
-
se = d.useMemo(() => {
|
|
3839
|
-
if (!(!h || !ne)) return ne.panes.find((a) => a.id === h);
|
|
3840
|
-
}, [h, ne]),
|
|
3841
|
-
Se = !!H,
|
|
3842
|
-
_e = !!((Se && !!t && !ne) || (Se && !!t && !!h && !!ne && !se)
|
|
3843
|
-
? n('wsError.checkGateway')
|
|
3844
|
-
: null),
|
|
3845
|
-
J = !!(T && h && !_e),
|
|
3846
|
-
Te = d.useMemo(() => {
|
|
3847
|
-
if (!ne || !se) return null;
|
|
3848
|
-
const a = (ee == null ? void 0 : ee.name) ?? e;
|
|
3849
|
-
return zt({
|
|
3850
|
-
paneIdx: se.index,
|
|
3851
|
-
windowIdx: ne.index,
|
|
3852
|
-
paneTitle: se.title,
|
|
3853
|
-
windowName: ne.name,
|
|
3854
|
-
deviceName: a,
|
|
3855
|
-
});
|
|
3856
|
-
}, [ee == null ? void 0 : ee.name, e, se, ne]),
|
|
3857
|
-
me = d.useMemo(() => {
|
|
3858
|
-
if (!H || H.length === 0) return null;
|
|
3859
|
-
const a = H.find((f) => f.active),
|
|
3860
|
-
p = a == null ? void 0 : a.panes.find((f) => f.active);
|
|
3861
|
-
return !a || !p ? null : { windowId: a.id, paneId: p.id };
|
|
3862
|
-
}, [H]),
|
|
3863
|
-
ve = d.useCallback(
|
|
3864
|
-
(a, p) => {
|
|
3865
|
-
!e || !h || j.getState().resizePane(e, h, a, p);
|
|
3866
|
-
},
|
|
3867
|
-
[e, h]
|
|
3868
|
-
),
|
|
3869
|
-
Me = d.useCallback(
|
|
3870
|
-
(a, p) => {
|
|
3871
|
-
!e || !h || j.getState().syncPaneSize(e, h, a, p);
|
|
3872
|
-
},
|
|
3873
|
-
[e, h]
|
|
3874
|
-
),
|
|
3875
|
-
de = d.useCallback(
|
|
3876
|
-
(a, p) => {
|
|
3877
|
-
const f = u.current,
|
|
3878
|
-
R =
|
|
3879
|
-
(f == null ? void 0 : f.calculateSizeFromContainer()) ??
|
|
3880
|
-
(f == null ? void 0 : f.getSize()) ??
|
|
3881
|
-
void 0;
|
|
3882
|
-
if (R) return R;
|
|
3883
|
-
if (!a || !p || !H) return;
|
|
3884
|
-
const W = H.find((ie) => ie.id === a),
|
|
3885
|
-
U = W == null ? void 0 : W.panes.find((ie) => ie.id === p);
|
|
3886
|
-
if (!(!U || U.width <= 1 || U.height <= 1)) return { cols: U.width, rows: U.height };
|
|
3887
|
-
},
|
|
3888
|
-
[H]
|
|
3889
|
-
);
|
|
3890
|
-
d.useEffect(() => {
|
|
3891
|
-
const a = () => {
|
|
3892
|
-
q(window.innerWidth < 768 || 'ontouchstart' in window);
|
|
3893
|
-
};
|
|
3894
|
-
return a(), window.addEventListener('resize', a), () => window.removeEventListener('resize', a);
|
|
3895
|
-
}, []),
|
|
3896
|
-
d.useEffect(() => {
|
|
3897
|
-
if (!D || !K || y.current) return;
|
|
3898
|
-
y.current = !0;
|
|
3899
|
-
const a = () => {
|
|
3900
|
-
window.scrollTo(0, 1);
|
|
3901
|
-
},
|
|
3902
|
-
p = window.requestAnimationFrame(a),
|
|
3903
|
-
f = window.setTimeout(a, 120),
|
|
3904
|
-
R = window.setTimeout(a, 420);
|
|
3905
|
-
return () => {
|
|
3906
|
-
window.cancelAnimationFrame(p), window.clearTimeout(f), window.clearTimeout(R);
|
|
3907
|
-
};
|
|
3908
|
-
}, [K, D]),
|
|
3909
|
-
d.useEffect(() => {
|
|
3910
|
-
E !== 'editor' && X(!1);
|
|
3911
|
-
}, [E]),
|
|
3912
|
-
d.useEffect(() => {
|
|
3913
|
-
var R, W;
|
|
3914
|
-
if (!(D && K && E === 'editor' && z)) {
|
|
3915
|
-
L(0);
|
|
3916
|
-
return;
|
|
3917
|
-
}
|
|
3918
|
-
let a = null;
|
|
3919
|
-
const p = () => {
|
|
3920
|
-
const U = window.visualViewport,
|
|
3921
|
-
ie = (U == null ? void 0 : U.height) ?? window.innerHeight,
|
|
3922
|
-
xe = (U == null ? void 0 : U.offsetTop) ?? 0,
|
|
3923
|
-
qt = Math.max(0, Math.round(window.innerHeight - ie - xe));
|
|
3924
|
-
L(qt);
|
|
3925
|
-
},
|
|
3926
|
-
f = () => {
|
|
3927
|
-
a === null &&
|
|
3928
|
-
(a = window.requestAnimationFrame(() => {
|
|
3929
|
-
(a = null), p();
|
|
3930
|
-
}));
|
|
3931
|
-
};
|
|
3932
|
-
return (
|
|
3933
|
-
p(),
|
|
3934
|
-
(R = window.visualViewport) == null || R.addEventListener('resize', f),
|
|
3935
|
-
(W = window.visualViewport) == null || W.addEventListener('scroll', f),
|
|
3936
|
-
window.addEventListener('resize', f),
|
|
3937
|
-
() => {
|
|
3938
|
-
var U, ie;
|
|
3939
|
-
(U = window.visualViewport) == null || U.removeEventListener('resize', f),
|
|
3940
|
-
(ie = window.visualViewport) == null || ie.removeEventListener('scroll', f),
|
|
3941
|
-
window.removeEventListener('resize', f),
|
|
3942
|
-
a !== null && window.cancelAnimationFrame(a);
|
|
3943
|
-
}
|
|
3944
|
-
);
|
|
3945
|
-
}, [E, z, K, D]),
|
|
3946
|
-
d.useEffect(() => {
|
|
3947
|
-
if (!le) {
|
|
3948
|
-
V(0);
|
|
3949
|
-
return;
|
|
3950
|
-
}
|
|
3951
|
-
const a = o.current;
|
|
3952
|
-
if (!a) return;
|
|
3953
|
-
const p = () => {
|
|
3954
|
-
V(Math.ceil(a.getBoundingClientRect().height));
|
|
3955
|
-
};
|
|
3956
|
-
p();
|
|
3957
|
-
const f = new ResizeObserver(p);
|
|
3958
|
-
return f.observe(a), () => f.disconnect();
|
|
3959
|
-
}, [le]),
|
|
3960
|
-
d.useEffect(() => {
|
|
3961
|
-
e &&
|
|
3962
|
-
((c.current = !1),
|
|
3963
|
-
(Ve.current = null),
|
|
3964
|
-
(be.current = null),
|
|
3965
|
-
(M.current = null),
|
|
3966
|
-
(re.current = []));
|
|
3967
|
-
}, [e]),
|
|
3968
|
-
d.useEffect(() => {
|
|
3969
|
-
T || (c.current = !1);
|
|
3970
|
-
}, [T]),
|
|
3971
|
-
d.useEffect(() => {
|
|
3972
|
-
if (!e || !T || !t || !H) return;
|
|
3973
|
-
if (H.length === 0) {
|
|
3974
|
-
r('/devices', { replace: !0 });
|
|
3975
|
-
return;
|
|
3976
|
-
}
|
|
3977
|
-
const a = H.find((f) => f.id === t);
|
|
3978
|
-
if (!a) return;
|
|
3979
|
-
if (!h) {
|
|
3980
|
-
const f = a.panes.find((R) => R.active) ?? a.panes[0];
|
|
3981
|
-
f && r(`/devices/${e}/windows/${t}/panes/${ge(f.id)}`, { replace: !0 });
|
|
3982
|
-
return;
|
|
3983
|
-
}
|
|
3984
|
-
if (!a.panes.find((f) => f.id === h)) {
|
|
3985
|
-
const f = a.panes.find((R) => R.active) ?? a.panes[0];
|
|
3986
|
-
f && r(`/devices/${e}/windows/${t}/panes/${ge(f.id)}`, { replace: !0 });
|
|
3987
|
-
return;
|
|
3988
|
-
}
|
|
3989
|
-
}, [e, T, H, t, h, r]),
|
|
3990
|
-
d.useEffect(() => {
|
|
3991
|
-
if (!e || !T || !H || H.length === 0 || (t && h) || c.current) return;
|
|
3992
|
-
const a = H.find((f) => f.active) ?? H[0],
|
|
3993
|
-
p = a.panes.find((f) => f.active) ?? a.panes[0];
|
|
3994
|
-
p &&
|
|
3995
|
-
((c.current = !0), r(`/devices/${e}/windows/${a.id}/panes/${ge(p.id)}`, { replace: !0 }));
|
|
3996
|
-
}, [T, e, r, h, t, H]),
|
|
3997
|
-
d.useEffect(() => {
|
|
3998
|
-
if (!e || !t || !h || Q || !T) return;
|
|
3999
|
-
const a = j.getState().selectedPanes[e];
|
|
4000
|
-
if (a && a.windowId === t && a.paneId === h) return;
|
|
4001
|
-
const p = de(t, h);
|
|
4002
|
-
he(t, h), O(e, t, h, p);
|
|
4003
|
-
}, [T, e, de, Q, h, O, t]),
|
|
4004
|
-
d.useEffect(() => {
|
|
4005
|
-
if (!e || !T || !t || !h) return;
|
|
4006
|
-
const a = { windowId: t, paneId: h };
|
|
4007
|
-
br({ routeTarget: a, snapshotActive: me, pendingUserSelection: M.current }) &&
|
|
4008
|
-
(M.current = { windowId: a.windowId, paneId: a.paneId, at: Date.now() });
|
|
4009
|
-
}, [T, e, h, me, t]);
|
|
4010
|
-
const re = d.useRef([]),
|
|
4011
|
-
he = d.useCallback((a, p) => {
|
|
4012
|
-
const f = Date.now(),
|
|
4013
|
-
R = [...re.current.filter((W) => f - W.at < 2e3), { windowId: a, paneId: p, at: f }];
|
|
4014
|
-
re.current = R.slice(-8);
|
|
4015
|
-
}, []),
|
|
4016
|
-
Z = j((a) => (e ? a.activePaneFromEvent[e] : void 0)),
|
|
4017
|
-
Ve = d.useRef(null);
|
|
4018
|
-
d.useEffect(() => {
|
|
4019
|
-
if (!e || !T || !t || !h || !Z) return;
|
|
4020
|
-
const a = Date.now(),
|
|
4021
|
-
p = Ce(M.current, a);
|
|
4022
|
-
if (
|
|
4023
|
-
((M.current = p),
|
|
4024
|
-
_r({
|
|
4025
|
-
now: a,
|
|
4026
|
-
pendingUserSelection: p,
|
|
4027
|
-
activePaneFromEvent: Z,
|
|
4028
|
-
currentRoute: { windowId: t, paneId: h },
|
|
4029
|
-
recentSelectRequests: re.current,
|
|
4030
|
-
lastHandledActive: Ve.current,
|
|
4031
|
-
}))
|
|
4032
|
-
)
|
|
4033
|
-
return;
|
|
4034
|
-
(Ve.current = { ...Z }),
|
|
4035
|
-
p && p.windowId === Z.windowId && p.paneId === Z.paneId && (M.current = null);
|
|
4036
|
-
const f = de(Z.windowId, Z.paneId);
|
|
4037
|
-
he(Z.windowId, Z.paneId),
|
|
4038
|
-
O(e, Z.windowId, Z.paneId, f),
|
|
4039
|
-
r(`/devices/${e}/windows/${Z.windowId}/panes/${ge(Z.paneId)}`, { replace: !0 });
|
|
4040
|
-
}, [e, T, t, h, Z, he, de, O, r]);
|
|
4041
|
-
const be = d.useRef(null);
|
|
4042
|
-
d.useEffect(() => {
|
|
4043
|
-
if (!e || !T || !H || H.length === 0) return;
|
|
4044
|
-
const a = re.current,
|
|
4045
|
-
p = H.find((xe) => xe.active);
|
|
4046
|
-
if (!p) return;
|
|
4047
|
-
const f = p.panes.find((xe) => xe.active);
|
|
4048
|
-
if (!f) return;
|
|
4049
|
-
const R = { windowId: p.id, paneId: f.id },
|
|
4050
|
-
W = Date.now(),
|
|
4051
|
-
U = Ce(M.current, W);
|
|
4052
|
-
if (
|
|
4053
|
-
((M.current = U),
|
|
4054
|
-
Tr({ now: W, pendingUserSelection: U, snapshotActive: R, recentSelectRequests: a }) ||
|
|
4055
|
-
(be.current && be.current.windowId === R.windowId && be.current.paneId === R.paneId) ||
|
|
4056
|
-
((be.current = { ...R }),
|
|
4057
|
-
U && U.windowId === R.windowId && U.paneId === R.paneId && (M.current = null),
|
|
4058
|
-
t === R.windowId && h === R.paneId))
|
|
4059
|
-
)
|
|
4060
|
-
return;
|
|
4061
|
-
const ie = de(R.windowId, R.paneId);
|
|
4062
|
-
he(R.windowId, R.paneId),
|
|
4063
|
-
O(e, R.windowId, R.paneId, ie),
|
|
4064
|
-
r(`/devices/${e}/windows/${R.windowId}/panes/${ge(R.paneId)}`, { replace: !0 });
|
|
4065
|
-
}, [e, T, H, t, h, he, de, O, r]);
|
|
4066
|
-
const $e = j((a) => (e ? a.pendingCreateWindowAt[e] : void 0));
|
|
4067
|
-
d.useEffect(() => {
|
|
4068
|
-
if (!e || !T || !$e) return;
|
|
4069
|
-
const a = 5e3,
|
|
4070
|
-
p = Date.now() - $e;
|
|
4071
|
-
if (p > a) {
|
|
4072
|
-
j.getState().clearPendingCreateWindow(e);
|
|
4073
|
-
return;
|
|
4074
|
-
}
|
|
4075
|
-
if (!me) {
|
|
4076
|
-
const W = window.setTimeout(() => {
|
|
4077
|
-
j.getState().clearPendingCreateWindow(e);
|
|
4078
|
-
}, a - p);
|
|
4079
|
-
return () => window.clearTimeout(W);
|
|
4080
|
-
}
|
|
4081
|
-
const f = me;
|
|
4082
|
-
if (t === f.windowId && h === f.paneId) {
|
|
4083
|
-
const W = window.setTimeout(() => {
|
|
4084
|
-
j.getState().clearPendingCreateWindow(e);
|
|
4085
|
-
}, a - p);
|
|
4086
|
-
return () => window.clearTimeout(W);
|
|
4087
|
-
}
|
|
4088
|
-
M.current = { windowId: f.windowId, paneId: f.paneId, at: Date.now() };
|
|
4089
|
-
const R = de(f.windowId, f.paneId);
|
|
4090
|
-
he(f.windowId, f.paneId),
|
|
4091
|
-
O(e, f.windowId, f.paneId, R),
|
|
4092
|
-
r(`/devices/${e}/windows/${f.windowId}/panes/${ge(f.paneId)}`, { replace: !0 }),
|
|
4093
|
-
j.getState().clearPendingCreateWindow(e);
|
|
4094
|
-
}, [e, T, $e, me, t, h, he, de, O, r]),
|
|
4095
|
-
d.useEffect(() => {
|
|
4096
|
-
if (!J || !se || Q) return;
|
|
4097
|
-
const a = u.current,
|
|
4098
|
-
p = a == null ? void 0 : a.getTerminal();
|
|
4099
|
-
if (!p) return;
|
|
4100
|
-
const f = Math.max(2, Math.floor(se.width || 0)),
|
|
4101
|
-
R = Math.max(2, Math.floor(se.height || 0));
|
|
4102
|
-
if (!f || !R) return;
|
|
4103
|
-
const W = Date.now(),
|
|
4104
|
-
U = { cols: f, rows: R },
|
|
4105
|
-
ie = (a == null ? void 0 : a.getPendingLocalSize()) ?? null;
|
|
4106
|
-
ar({ now: W, remoteSize: U, pendingLocalSize: ie }) &&
|
|
4107
|
-
((p.cols === f && p.rows === R) || p.resize(f, R));
|
|
4108
|
-
}, [J, Q, se]),
|
|
4109
|
-
d.useEffect(() => {
|
|
4110
|
-
const a = window.requestAnimationFrame(() => {
|
|
4111
|
-
var f;
|
|
4112
|
-
(f = u.current) == null || f.scrollToBottom();
|
|
4113
|
-
}),
|
|
4114
|
-
p = window.setTimeout(() => {
|
|
4115
|
-
var f;
|
|
4116
|
-
(f = u.current) == null || f.scrollToBottom();
|
|
4117
|
-
}, 120);
|
|
4118
|
-
return () => {
|
|
4119
|
-
window.cancelAnimationFrame(a), window.clearTimeout(p);
|
|
4120
|
-
};
|
|
4121
|
-
}, [E]),
|
|
4122
|
-
d.useEffect(() => {
|
|
4123
|
-
x != null && x.message && Ke.error(x.message);
|
|
4124
|
-
}, [x == null ? void 0 : x.message]),
|
|
4125
|
-
d.useEffect(
|
|
4126
|
-
() => (
|
|
4127
|
-
(document.title = Er(Te)),
|
|
4128
|
-
() => {
|
|
4129
|
-
document.title = g;
|
|
4130
|
-
}
|
|
4131
|
-
),
|
|
4132
|
-
[g, Te]
|
|
4133
|
-
),
|
|
4134
|
-
d.useEffect(() => {
|
|
4135
|
-
const a = () => {
|
|
4136
|
-
var p;
|
|
4137
|
-
(p = u.current) == null || p.scrollToBottom();
|
|
4138
|
-
};
|
|
4139
|
-
return (
|
|
4140
|
-
window.addEventListener('tmex:jump-to-latest', a),
|
|
4141
|
-
() => {
|
|
4142
|
-
window.removeEventListener('tmex:jump-to-latest', a);
|
|
4143
|
-
}
|
|
4144
|
-
);
|
|
4145
|
-
}, []),
|
|
4146
|
-
d.useEffect(() => {
|
|
4147
|
-
const a = (p) => {
|
|
4148
|
-
const { deviceId: f, windowId: R, paneId: W } = p.detail;
|
|
4149
|
-
f === e && (M.current = { windowId: R, paneId: W, at: Date.now() });
|
|
4150
|
-
};
|
|
4151
|
-
return (
|
|
4152
|
-
window.addEventListener('tmex:user-initiated-selection', a),
|
|
4153
|
-
() => {
|
|
4154
|
-
window.removeEventListener('tmex:user-initiated-selection', a);
|
|
4155
|
-
}
|
|
4156
|
-
);
|
|
4157
|
-
}, [e]),
|
|
4158
|
-
d.useEffect(() => {
|
|
4159
|
-
A($);
|
|
4160
|
-
}, [$]);
|
|
4161
|
-
const ct = d.useCallback(
|
|
4162
|
-
(a) => {
|
|
4163
|
-
if (!e || !h || !J) return;
|
|
4164
|
-
j.getState().sendInput(e, h, a, !1);
|
|
4165
|
-
},
|
|
4166
|
-
[J, e, h]
|
|
4167
|
-
),
|
|
4168
|
-
Yt = d.useCallback(() => {
|
|
4169
|
-
if (!J) {
|
|
4170
|
-
Ke.error(n('wsError.checkGateway'));
|
|
4171
|
-
return;
|
|
4172
|
-
}
|
|
4173
|
-
if (!e || !h || !F.trim()) return;
|
|
4174
|
-
v(!0), window.setTimeout(() => v(!1), 150);
|
|
4175
|
-
const a = te ? `${F}\r` : F;
|
|
4176
|
-
j.getState().sendInput(e, h, a, !1), S(F), k && N(k), A('');
|
|
4177
|
-
}, [S, J, e, k, te, F, N, h, n]),
|
|
4178
|
-
Vt = d.useCallback(() => {
|
|
4179
|
-
if (!J) {
|
|
4180
|
-
Ke.error(n('wsError.checkGateway'));
|
|
4181
|
-
return;
|
|
4182
|
-
}
|
|
4183
|
-
if (!e || !h || !F.trim()) return;
|
|
4184
|
-
v(!0), window.setTimeout(() => v(!1), 150);
|
|
4185
|
-
const a = F.split(/\r?\n/),
|
|
4186
|
-
p = j.getState();
|
|
4187
|
-
for (const f of a) f.trim() && p.sendInput(e, h, `${f}\r`, !1);
|
|
4188
|
-
S(F), k && N(k), A('');
|
|
4189
|
-
}, [S, J, e, k, F, N, h, n]),
|
|
4190
|
-
$t = d.useCallback(
|
|
4191
|
-
(a) => {
|
|
4192
|
-
if ((X(!0), !(D && K))) return;
|
|
4193
|
-
const p = a.currentTarget;
|
|
4194
|
-
window.requestAnimationFrame(() => {
|
|
4195
|
-
p.scrollIntoView({ block: 'nearest', inline: 'nearest' });
|
|
4196
|
-
}),
|
|
4197
|
-
window.setTimeout(() => {
|
|
4198
|
-
window.scrollTo(0, 1);
|
|
4199
|
-
}, 60);
|
|
4200
|
-
},
|
|
4201
|
-
[K, D]
|
|
4202
|
-
),
|
|
4203
|
-
Kt = d.useCallback(() => {
|
|
4204
|
-
X(!1);
|
|
4205
|
-
}, []),
|
|
4206
|
-
Wt = d.useCallback(() => {
|
|
4207
|
-
var a;
|
|
4208
|
-
(a = l.current) == null || a.focus({ preventScroll: !0 });
|
|
4209
|
-
}, []);
|
|
4210
|
-
if (!e)
|
|
4211
|
-
return m.jsx('div', {
|
|
4212
|
-
className: 'flex h-full items-center justify-center p-4',
|
|
4213
|
-
children: m.jsx('div', {
|
|
4214
|
-
className:
|
|
4215
|
-
'rounded-lg border border-dashed border-border px-4 py-3 text-sm text-muted-foreground',
|
|
4216
|
-
children: n('device.noDevices'),
|
|
4217
|
-
}),
|
|
4218
|
-
});
|
|
4219
|
-
const jt = !T && !x;
|
|
4220
|
-
return m.jsxs('div', {
|
|
4221
|
-
className: 'flex h-full min-h-0 flex-col bg-background',
|
|
4222
|
-
'data-testid': 'device-page',
|
|
4223
|
-
children: [
|
|
4224
|
-
m.jsxs('div', {
|
|
4225
|
-
className: `flex-1 relative overflow-hidden min-h-0 min-w-0 ${D && E === 'editor' && !le ? 'pb-1' : ''}`,
|
|
4226
|
-
style: { paddingBottom: le ? `${G + 60}px` : void 0 },
|
|
4227
|
-
children: [
|
|
4228
|
-
m.jsx('div', {
|
|
4229
|
-
className: 'h-full px-3 py-1 min-h-0 min-w-0 w-full relative flex rounded-xl',
|
|
4230
|
-
style: { backgroundColor: ae.background },
|
|
4231
|
-
children:
|
|
4232
|
-
T && h
|
|
4233
|
-
? m.jsx('div', {
|
|
4234
|
-
ref: i,
|
|
4235
|
-
className: 'flex-1 h-full min-h-0 w-full',
|
|
4236
|
-
children: m.jsx(
|
|
4237
|
-
Gt,
|
|
4238
|
-
{
|
|
4239
|
-
ref: u,
|
|
4240
|
-
deviceId: e,
|
|
4241
|
-
paneId: h,
|
|
4242
|
-
theme: Y,
|
|
4243
|
-
inputMode: E,
|
|
4244
|
-
deviceConnected: T,
|
|
4245
|
-
isSelectionInvalid: _e,
|
|
4246
|
-
onResize: ve,
|
|
4247
|
-
onSync: Me,
|
|
4248
|
-
},
|
|
4249
|
-
`${e}:${h}`
|
|
4250
|
-
),
|
|
4251
|
-
})
|
|
4252
|
-
: m.jsx('div', {
|
|
4253
|
-
className:
|
|
4254
|
-
'absolute inset-0 flex flex-col items-center justify-center p-8 text-center',
|
|
4255
|
-
children: m.jsx('div', {
|
|
4256
|
-
className: 'max-w-sm space-y-4',
|
|
4257
|
-
children: T
|
|
4258
|
-
? t
|
|
4259
|
-
? m.jsxs(m.Fragment, {
|
|
4260
|
-
children: [
|
|
4261
|
-
m.jsx('div', {
|
|
4262
|
-
className:
|
|
4263
|
-
'h-12 w-12 rounded-full bg-muted flex items-center justify-center mx-auto',
|
|
4264
|
-
children: m.jsx(We, {
|
|
4265
|
-
className: 'h-6 w-6 text-muted-foreground animate-spin',
|
|
4266
|
-
}),
|
|
4267
|
-
}),
|
|
4268
|
-
m.jsx('h3', {
|
|
4269
|
-
className: 'text-lg font-medium',
|
|
4270
|
-
children: n('terminal.connecting'),
|
|
4271
|
-
}),
|
|
4272
|
-
],
|
|
4273
|
-
})
|
|
4274
|
-
: m.jsxs(m.Fragment, {
|
|
4275
|
-
children: [
|
|
4276
|
-
m.jsx('div', {
|
|
4277
|
-
className:
|
|
4278
|
-
'h-12 w-12 rounded-full bg-muted flex items-center justify-center mx-auto',
|
|
4279
|
-
children: m.jsx('span', {
|
|
4280
|
-
className: 'text-2xl text-muted-foreground',
|
|
4281
|
-
children: '📋',
|
|
4282
|
-
}),
|
|
4283
|
-
}),
|
|
4284
|
-
m.jsx('h3', {
|
|
4285
|
-
className: 'text-lg font-medium',
|
|
4286
|
-
children: n('window.noWindowSelected'),
|
|
4287
|
-
}),
|
|
4288
|
-
m.jsx('p', {
|
|
4289
|
-
className: 'text-sm text-muted-foreground',
|
|
4290
|
-
children: n('window.selectWindowToStart'),
|
|
4291
|
-
}),
|
|
4292
|
-
],
|
|
4293
|
-
})
|
|
4294
|
-
: m.jsxs(m.Fragment, {
|
|
4295
|
-
children: [
|
|
4296
|
-
m.jsx('div', {
|
|
4297
|
-
className:
|
|
4298
|
-
'h-12 w-12 rounded-full bg-muted flex items-center justify-center mx-auto',
|
|
4299
|
-
children: m.jsx('span', {
|
|
4300
|
-
className: 'text-2xl text-muted-foreground',
|
|
4301
|
-
children: '🔌',
|
|
4302
|
-
}),
|
|
4303
|
-
}),
|
|
4304
|
-
m.jsx('h3', {
|
|
4305
|
-
className: 'text-lg font-medium',
|
|
4306
|
-
children: n('device.disconnected'),
|
|
4307
|
-
}),
|
|
4308
|
-
m.jsx('p', {
|
|
4309
|
-
className: 'text-sm text-muted-foreground',
|
|
4310
|
-
children: n('device.connectToStart'),
|
|
4311
|
-
}),
|
|
4312
|
-
],
|
|
4313
|
-
}),
|
|
4314
|
-
}),
|
|
4315
|
-
}),
|
|
4316
|
-
}),
|
|
4317
|
-
jt &&
|
|
4318
|
-
m.jsx('div', {
|
|
4319
|
-
className:
|
|
4320
|
-
'absolute inset-0 flex items-center justify-center bg-background/85 backdrop-blur-sm',
|
|
4321
|
-
'data-testid': 'terminal-status-overlay',
|
|
4322
|
-
children: m.jsxs('div', {
|
|
4323
|
-
className:
|
|
4324
|
-
'flex flex-col items-center gap-2 rounded-lg border border-border bg-card/90 px-4 py-3 shadow-sm',
|
|
4325
|
-
children: [
|
|
4326
|
-
m.jsx('div', {
|
|
4327
|
-
className:
|
|
4328
|
-
'h-7 w-7 rounded-full border-2 border-primary border-t-transparent animate-spin',
|
|
4329
|
-
}),
|
|
4330
|
-
m.jsx('span', {
|
|
4331
|
-
className: 'text-xs text-muted-foreground',
|
|
4332
|
-
'data-testid': 'terminal-status-text',
|
|
4333
|
-
children: n('terminal.connecting'),
|
|
4334
|
-
}),
|
|
4335
|
-
],
|
|
4336
|
-
}),
|
|
4337
|
-
}),
|
|
4338
|
-
],
|
|
4339
|
-
}),
|
|
4340
|
-
E === 'direct' &&
|
|
4341
|
-
m.jsx('div', {
|
|
4342
|
-
className: '',
|
|
4343
|
-
children: m.jsx(Mt, { onSend: ct, disabled: !J, isMobile: D, inputMode: E }),
|
|
4344
|
-
}),
|
|
4345
|
-
E === 'editor' &&
|
|
4346
|
-
m.jsxs('div', {
|
|
4347
|
-
ref: o,
|
|
4348
|
-
className: `editor-mode-input bg-card/85 backdrop-blur-sm ${le ? 'fixed left-0 right-0 z-50' : ''}`,
|
|
4349
|
-
style: le ? { bottom: `${b}px` } : void 0,
|
|
4350
|
-
children: [
|
|
4351
|
-
D &&
|
|
4352
|
-
m.jsx(Mt, { onSend: ct, onFocusEditor: Wt, disabled: !J, isMobile: D, inputMode: E }),
|
|
4353
|
-
m.jsx('textarea', {
|
|
4354
|
-
ref: l,
|
|
4355
|
-
'data-testid': 'editor-input',
|
|
4356
|
-
className:
|
|
4357
|
-
'min-h-[88px] max-h-[28vh] w-full resize-y rounded-lg border border-border bg-background px-3 py-2 text-sm text-foreground shadow-xs outline-none transition-colors focus:border-ring',
|
|
4358
|
-
value: F,
|
|
4359
|
-
onChange: (a) => {
|
|
4360
|
-
const p = a.target.value;
|
|
4361
|
-
if ((A(p), !!k)) {
|
|
4362
|
-
if (p) {
|
|
4363
|
-
B(k, p);
|
|
4364
|
-
return;
|
|
4365
|
-
}
|
|
4366
|
-
N(k);
|
|
4367
|
-
}
|
|
4368
|
-
},
|
|
4369
|
-
placeholder: n('terminal.inputPlaceholder'),
|
|
4370
|
-
onFocus: $t,
|
|
4371
|
-
onBlur: Kt,
|
|
4372
|
-
onCompositionStart: () => {
|
|
4373
|
-
oe.current = !0;
|
|
4374
|
-
},
|
|
4375
|
-
onCompositionEnd: () => {
|
|
4376
|
-
oe.current = !1;
|
|
4377
|
-
},
|
|
4378
|
-
}),
|
|
4379
|
-
m.jsx('div', {
|
|
4380
|
-
className: 'actions mt-2',
|
|
4381
|
-
children: m.jsxs('div', {
|
|
4382
|
-
className: 'send-row flex flex-wrap items-center justify-end gap-2',
|
|
4383
|
-
'data-testid': 'editor-send-row',
|
|
4384
|
-
children: [
|
|
4385
|
-
m.jsxs('div', {
|
|
4386
|
-
className:
|
|
4387
|
-
'send-with-enter-toggle mr-auto flex items-center gap-2 text-xs text-muted-foreground',
|
|
4388
|
-
'data-testid': 'editor-send-with-enter-toggle',
|
|
4389
|
-
children: [
|
|
4390
|
-
m.jsx(dn, { size: 'sm', checked: te, onCheckedChange: (a) => _(!!a) }),
|
|
4391
|
-
m.jsx('span', { children: n('terminal.editorSendWithEnter') }),
|
|
4392
|
-
],
|
|
4393
|
-
}),
|
|
4394
|
-
m.jsxs(we, {
|
|
4395
|
-
variant: 'outline',
|
|
4396
|
-
size: 'sm',
|
|
4397
|
-
'data-testid': 'editor-clear',
|
|
4398
|
-
onPointerDown: (a) => a.preventDefault(),
|
|
4399
|
-
onClick: () => {
|
|
4400
|
-
var a;
|
|
4401
|
-
A(''),
|
|
4402
|
-
k && N(k),
|
|
4403
|
-
D &&
|
|
4404
|
-
E === 'editor' &&
|
|
4405
|
-
((a = l.current) == null || a.focus({ preventScroll: !0 }));
|
|
4406
|
-
},
|
|
4407
|
-
title: n('terminal.clear'),
|
|
4408
|
-
children: [m.jsx(en, { className: 'h-4 w-4' }), n('terminal.clear')],
|
|
4409
|
-
}),
|
|
4410
|
-
m.jsxs(we, {
|
|
4411
|
-
variant: 'secondary',
|
|
4412
|
-
size: 'sm',
|
|
4413
|
-
'data-testid': 'editor-send-line-by-line',
|
|
4414
|
-
onPointerDown: (a) => a.preventDefault(),
|
|
4415
|
-
onClick: () => {
|
|
4416
|
-
var a;
|
|
4417
|
-
Vt(),
|
|
4418
|
-
D &&
|
|
4419
|
-
E === 'editor' &&
|
|
4420
|
-
((a = l.current) == null || a.focus({ preventScroll: !0 }));
|
|
4421
|
-
},
|
|
4422
|
-
disabled: !J || C,
|
|
4423
|
-
children: [
|
|
4424
|
-
C
|
|
4425
|
-
? m.jsx(We, { className: 'h-4 w-4 animate-spin' })
|
|
4426
|
-
: m.jsx(ht, { className: 'h-4 w-4' }),
|
|
4427
|
-
n('terminal.editorSendLineByLine'),
|
|
4428
|
-
],
|
|
4429
|
-
}),
|
|
4430
|
-
m.jsxs(we, {
|
|
4431
|
-
variant: 'default',
|
|
4432
|
-
size: 'sm',
|
|
4433
|
-
'data-testid': 'editor-send',
|
|
4434
|
-
onPointerDown: (a) => a.preventDefault(),
|
|
4435
|
-
onClick: () => {
|
|
4436
|
-
var a;
|
|
4437
|
-
Yt(),
|
|
4438
|
-
D &&
|
|
4439
|
-
E === 'editor' &&
|
|
4440
|
-
((a = l.current) == null || a.focus({ preventScroll: !0 }));
|
|
4441
|
-
},
|
|
4442
|
-
disabled: !J || C,
|
|
4443
|
-
children: [
|
|
4444
|
-
C
|
|
4445
|
-
? m.jsx(We, { className: 'h-4 w-4 animate-spin' })
|
|
4446
|
-
: m.jsx(ht, { className: 'h-4 w-4' }),
|
|
4447
|
-
n('common.send'),
|
|
4448
|
-
],
|
|
4449
|
-
}),
|
|
4450
|
-
],
|
|
4451
|
-
}),
|
|
4452
|
-
}),
|
|
4453
|
-
],
|
|
4454
|
-
}),
|
|
4455
|
-
],
|
|
4456
|
-
});
|
|
4457
|
-
}
|
|
4458
|
-
function kr() {
|
|
4459
|
-
const { deviceId: n, windowId: e, paneId: t } = rt(),
|
|
4460
|
-
s = t ? it(t) : void 0,
|
|
4461
|
-
r = j((y) => y.snapshots),
|
|
4462
|
-
i = st((y) => {
|
|
4463
|
-
var M;
|
|
4464
|
-
return ((M = y.settings) == null ? void 0 : M.siteName) ?? 'tmex';
|
|
4465
|
-
}),
|
|
4466
|
-
o = n ? r[n] : void 0,
|
|
4467
|
-
l = d.useMemo(() => {
|
|
4468
|
-
var y;
|
|
4469
|
-
if (!(!e || !((y = o == null ? void 0 : o.session) != null && y.windows)))
|
|
4470
|
-
return o.session.windows.find((M) => M.id === e);
|
|
4471
|
-
}, [e, o]),
|
|
4472
|
-
u = d.useMemo(() => {
|
|
4473
|
-
if (!(!s || !l)) return l.panes.find((y) => y.id === s);
|
|
4474
|
-
}, [s, l]),
|
|
4475
|
-
c = d.useMemo(
|
|
4476
|
-
() =>
|
|
4477
|
-
l && u
|
|
4478
|
-
? zt({
|
|
4479
|
-
paneIdx: u.index,
|
|
4480
|
-
windowIdx: l.index,
|
|
4481
|
-
paneTitle: u.title,
|
|
4482
|
-
windowName: l.name,
|
|
4483
|
-
deviceName: i,
|
|
4484
|
-
})
|
|
4485
|
-
: (n ?? ''),
|
|
4486
|
-
[l, u, i, n]
|
|
4487
|
-
);
|
|
4488
|
-
return m.jsx(m.Fragment, { children: c });
|
|
4489
|
-
}
|
|
4490
|
-
function Ir() {
|
|
4491
|
-
const { t: n } = Dt(),
|
|
4492
|
-
{ deviceId: e, paneId: t } = rt(),
|
|
4493
|
-
s = t ? it(t) : void 0,
|
|
4494
|
-
r = ue((x) => x.inputMode),
|
|
4495
|
-
i = ue((x) => x.setInputMode),
|
|
4496
|
-
o = j((x) => {
|
|
4497
|
-
var T;
|
|
4498
|
-
return e ? (((T = x.deviceConnected) == null ? void 0 : T[e]) ?? !1) : !1;
|
|
4499
|
-
}),
|
|
4500
|
-
[l, u] = d.useState(!1),
|
|
4501
|
-
c = !!(s && o),
|
|
4502
|
-
y = () => {
|
|
4503
|
-
i(r === 'direct' ? 'editor' : 'direct');
|
|
4504
|
-
},
|
|
4505
|
-
M = () => {
|
|
4506
|
-
window.dispatchEvent(new CustomEvent('tmex:jump-to-latest'));
|
|
4507
|
-
},
|
|
4508
|
-
O = () => {
|
|
4509
|
-
u(!0);
|
|
4510
|
-
},
|
|
4511
|
-
P = () => {
|
|
4512
|
-
window.location.reload();
|
|
4513
|
-
};
|
|
4514
|
-
return m.jsxs(m.Fragment, {
|
|
4515
|
-
children: [
|
|
4516
|
-
m.jsx(we, {
|
|
4517
|
-
variant: 'ghost',
|
|
4518
|
-
size: 'icon-sm',
|
|
4519
|
-
onClick: O,
|
|
4520
|
-
'aria-label': n('nav.refreshPage'),
|
|
4521
|
-
title: n('nav.refreshPage'),
|
|
4522
|
-
children: m.jsx(wn, { className: 'h-4 w-4' }),
|
|
4523
|
-
}),
|
|
4524
|
-
m.jsx(we, {
|
|
4525
|
-
variant: 'ghost',
|
|
4526
|
-
size: 'icon-sm',
|
|
4527
|
-
onClick: y,
|
|
4528
|
-
disabled: !c,
|
|
4529
|
-
'data-testid': 'terminal-input-mode-toggle',
|
|
4530
|
-
'aria-label': n(r === 'direct' ? 'nav.switchToEditor' : 'nav.switchToDirect'),
|
|
4531
|
-
title: n(r === 'direct' ? 'nav.switchToEditor' : 'nav.switchToDirect'),
|
|
4532
|
-
children:
|
|
4533
|
-
r === 'direct'
|
|
4534
|
-
? m.jsx(mn, { className: 'h-4 w-4' })
|
|
4535
|
-
: m.jsx(yn, { className: 'h-4 w-4' }),
|
|
4536
|
-
}),
|
|
4537
|
-
m.jsx(we, {
|
|
4538
|
-
variant: 'ghost',
|
|
4539
|
-
size: 'icon-sm',
|
|
4540
|
-
onClick: M,
|
|
4541
|
-
disabled: !c,
|
|
4542
|
-
'aria-label': n('nav.jumpToLatest'),
|
|
4543
|
-
title: n('nav.jumpToLatest'),
|
|
4544
|
-
children: m.jsx(hn, { className: 'h-4 w-4' }),
|
|
4545
|
-
}),
|
|
4546
|
-
m.jsx(tn, {
|
|
4547
|
-
open: l,
|
|
4548
|
-
onOpenChange: u,
|
|
4549
|
-
children: m.jsxs(nn, {
|
|
4550
|
-
children: [
|
|
4551
|
-
m.jsxs(sn, {
|
|
4552
|
-
children: [
|
|
4553
|
-
m.jsx(rn, { children: n('nav.refreshPage') }),
|
|
4554
|
-
m.jsx(on, { children: n('nav.refreshPageConfirm') }),
|
|
4555
|
-
],
|
|
4556
|
-
}),
|
|
4557
|
-
m.jsxs(ln, {
|
|
4558
|
-
children: [
|
|
4559
|
-
m.jsx(an, { onClick: () => u(!1), children: n('common.cancel') }),
|
|
4560
|
-
m.jsx(cn, { onClick: P, children: n('common.confirm') }),
|
|
4561
|
-
],
|
|
4562
|
-
}),
|
|
4563
|
-
],
|
|
4564
|
-
}),
|
|
4565
|
-
}),
|
|
4566
|
-
],
|
|
4567
|
-
});
|
|
4568
|
-
}
|
|
4569
|
-
export { Ir as PageActions, kr as PageTitle, Or as default };
|
|
4570
|
-
//# sourceMappingURL=DevicePage-iSkEDEpS.js.map
|