@prozilla-os/terminal 2.0.1 → 2.0.5
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/README.md +3 -3
- package/dist/main.d.ts +5 -1635
- package/dist/main.js +368 -349
- package/dist/main.js.map +1 -1
- package/package.json +17 -12
package/dist/main.js
CHANGED
|
@@ -1,50 +1,54 @@
|
|
|
1
|
-
(function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode('.
|
|
2
|
-
import { useShell as
|
|
3
|
-
import { jsx as k, jsxs as I
|
|
1
|
+
(function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode('._Terminal_1y9ey_1{--char-width: .585rem;--char-height: 1.25rem;position:relative;display:flex;flex-direction:column;align-items:flex-start;padding:.5rem;overflow:auto;height:100%;cursor:text;box-sizing:border-box}._Terminal_1y9ey_1 *{font-family:var(--mono-font-family);letter-spacing:-.03em}._Terminal_1y9ey_1 p,._Terminal_1y9ey_1 pre{margin:0;height:var(--char-height);line-height:var(--char-height);font-size:1rem;letter-spacing:inherit}._VirtualCursor_1y9ey_29{position:absolute;margin-left:.5rem;margin-top:.5rem;width:var(--char-width);height:var(--char-height);background-color:var(--foreground-color-0);mix-blend-mode:difference;pointer-events:none;z-index:10;animation:_blink_1y9ey_1 1s step-end infinite}._History_1y9ey_44{width:100%}._Prefix_1y9ey_48{display:flex;width:max-content;white-space:nowrap}._Input_1y9ey_54,._Output_1y9ey_54{display:flex;flex-direction:row;align-items:center;width:100%;line-height:var(--char-height);font-size:1rem;text-align:start;white-space:pre}._Input_1y9ey_54{height:var(--char-height)}._Input-container_1y9ey_69{--cursor-width: var(--char-width);--cursor-offset: 0;position:relative;height:100%;width:fit-content}._Input-container_1y9ey_69:after{content:"";position:absolute;top:0;left:calc(var(--cursor-offset) * var(--char-width));width:var(--cursor-width);height:100%;background-color:var(--foreground-color-0);animation:_blink_1y9ey_1 1s step-end infinite}._Input-container_1y9ey_69 input{color:transparent;position:absolute;left:0;width:100%;padding:0;background:none;border:none;outline:none;font-size:inherit;caret-color:transparent}@keyframes _blink_1y9ey_1{0%,to{opacity:0}50%{opacity:1}}._Input_1y9ey_54 label{position:absolute;width:100%;height:100%;top:0;left:0;cursor:text}._InterruptButton_1y9ey_120{display:none;gap:.5rem;flex-direction:row-reverse;justify-content:center;align-items:center;position:absolute;bottom:1rem;right:1rem;padding:.5rem 1rem;border-radius:var(--border-radius-1)}._InterruptButton_1y9ey_120>svg{margin:0!important;width:auto}._InterruptButton_1y9ey_120 *{color:inherit}@media(pointer:coarse){._InterruptButton_1y9ey_120{display:flex}}._ansi-black-fg_1y9ey_148{color:var(--black-2)}._ansi-red-fg_1y9ey_149{color:var(--red-0)}._ansi-green-fg_1y9ey_150{color:var(--green-0)}._ansi-yellow-fg_1y9ey_151{color:var(--yellow-0)}._ansi-blue-fg_1y9ey_152{color:var(--blue-0)}._ansi-magenta-fg_1y9ey_153{color:var(--purple-0)}._ansi-cyan-fg_1y9ey_154{color:var(--cyan-0)}._ansi-white-fg_1y9ey_155{color:var(--foreground-color-0)}._ansi-bright-black-fg_1y9ey_157{color:var(--black-2)}._ansi-bright-red-fg_1y9ey_158{color:var(--red-0)}._ansi-bright-green-fg_1y9ey_159{color:var(--green-0)}._ansi-bright-yellow-fg_1y9ey_160{color:var(--yellow-0)}._ansi-bright-blue-fg_1y9ey_161{color:var(--blue-0)}._ansi-bright-magenta-fg_1y9ey_162{color:var(--purple-0)}._ansi-bright-cyan-fg_1y9ey_163{color:var(--cyan-0)}._ansi-bright-white-fg_1y9ey_164{color:var(--foreground-color-0)}._ansi-black-bg_1y9ey_166{background-color:var(--black-2)}._ansi-red-bg_1y9ey_167{background-color:var(--red-0)}._ansi-green-bg_1y9ey_168{background-color:var(--green-0)}._ansi-yellow-bg_1y9ey_169{background-color:var(--yellow-0)}._ansi-blue-bg_1y9ey_170{background-color:var(--blue-0)}._ansi-magenta-bg_1y9ey_171{background-color:var(--purple-0)}._ansi-cyan-bg_1y9ey_172{background-color:var(--cyan-0)}._ansi-white-bg_1y9ey_173{background-color:var(--foreground-color-0)}._ansi-dim_1y9ey_175{opacity:.65}')),document.head.appendChild(e)}}catch(r){console.error("vite-plugin-css-injected-by-js",r)}})();
|
|
2
|
+
import { useFontMetrics as Z, useShell as G, HistoryFlags as Q, Button as X, utilStyles as Y, App as ee, AppsConfig as te, ExecutableResolver as re } from "@prozilla-os/core";
|
|
3
|
+
import { jsx as k, jsxs as I } from "react/jsx-runtime";
|
|
4
4
|
import * as L from "react";
|
|
5
|
-
import { forwardRef as
|
|
6
|
-
import { Vector2 as
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
"
|
|
17
|
-
|
|
18
|
-
"ansi-
|
|
19
|
-
"ansi-
|
|
20
|
-
"ansi-
|
|
21
|
-
"ansi-
|
|
22
|
-
"ansi-
|
|
23
|
-
"ansi-
|
|
24
|
-
"ansi-
|
|
25
|
-
"ansi-
|
|
26
|
-
"ansi-bright-
|
|
27
|
-
"ansi-bright-
|
|
28
|
-
"ansi-bright-
|
|
29
|
-
"ansi-bright-
|
|
30
|
-
"ansi-
|
|
31
|
-
"ansi-
|
|
32
|
-
"ansi-
|
|
33
|
-
"ansi-
|
|
34
|
-
"ansi-
|
|
35
|
-
"ansi-
|
|
36
|
-
"ansi-
|
|
37
|
-
"ansi-
|
|
38
|
-
"ansi-
|
|
5
|
+
import { memo as se, forwardRef as ne, useState as j, useRef as O, useLayoutEffect as ie, useEffect as E, useMemo as D } from "react";
|
|
6
|
+
import { Vector2 as le, Ansi as oe } from "@prozilla-os/shared";
|
|
7
|
+
import { faStop as ae } from "@fortawesome/free-solid-svg-icons";
|
|
8
|
+
const ce = "_Terminal_1y9ey_1", ue = "_VirtualCursor_1y9ey_29", fe = "_blink_1y9ey_1", ge = "_History_1y9ey_44", he = "_Prefix_1y9ey_48", pe = "_Input_1y9ey_54", ye = "_Output_1y9ey_54", _e = "_InterruptButton_1y9ey_120", C = {
|
|
9
|
+
Terminal: ce,
|
|
10
|
+
VirtualCursor: ue,
|
|
11
|
+
blink: fe,
|
|
12
|
+
History: ge,
|
|
13
|
+
Prefix: he,
|
|
14
|
+
Input: pe,
|
|
15
|
+
Output: ye,
|
|
16
|
+
"Input-container": "_Input-container_1y9ey_69",
|
|
17
|
+
InterruptButton: _e,
|
|
18
|
+
"ansi-black-fg": "_ansi-black-fg_1y9ey_148",
|
|
19
|
+
"ansi-red-fg": "_ansi-red-fg_1y9ey_149",
|
|
20
|
+
"ansi-green-fg": "_ansi-green-fg_1y9ey_150",
|
|
21
|
+
"ansi-yellow-fg": "_ansi-yellow-fg_1y9ey_151",
|
|
22
|
+
"ansi-blue-fg": "_ansi-blue-fg_1y9ey_152",
|
|
23
|
+
"ansi-magenta-fg": "_ansi-magenta-fg_1y9ey_153",
|
|
24
|
+
"ansi-cyan-fg": "_ansi-cyan-fg_1y9ey_154",
|
|
25
|
+
"ansi-white-fg": "_ansi-white-fg_1y9ey_155",
|
|
26
|
+
"ansi-bright-black-fg": "_ansi-bright-black-fg_1y9ey_157",
|
|
27
|
+
"ansi-bright-red-fg": "_ansi-bright-red-fg_1y9ey_158",
|
|
28
|
+
"ansi-bright-green-fg": "_ansi-bright-green-fg_1y9ey_159",
|
|
29
|
+
"ansi-bright-yellow-fg": "_ansi-bright-yellow-fg_1y9ey_160",
|
|
30
|
+
"ansi-bright-blue-fg": "_ansi-bright-blue-fg_1y9ey_161",
|
|
31
|
+
"ansi-bright-magenta-fg": "_ansi-bright-magenta-fg_1y9ey_162",
|
|
32
|
+
"ansi-bright-cyan-fg": "_ansi-bright-cyan-fg_1y9ey_163",
|
|
33
|
+
"ansi-bright-white-fg": "_ansi-bright-white-fg_1y9ey_164",
|
|
34
|
+
"ansi-black-bg": "_ansi-black-bg_1y9ey_166",
|
|
35
|
+
"ansi-red-bg": "_ansi-red-bg_1y9ey_167",
|
|
36
|
+
"ansi-green-bg": "_ansi-green-bg_1y9ey_168",
|
|
37
|
+
"ansi-yellow-bg": "_ansi-yellow-bg_1y9ey_169",
|
|
38
|
+
"ansi-blue-bg": "_ansi-blue-bg_1y9ey_170",
|
|
39
|
+
"ansi-magenta-bg": "_ansi-magenta-bg_1y9ey_171",
|
|
40
|
+
"ansi-cyan-bg": "_ansi-cyan-bg_1y9ey_172",
|
|
41
|
+
"ansi-white-bg": "_ansi-white-bg_1y9ey_173",
|
|
42
|
+
"ansi-dim": "_ansi-dim_1y9ey_175"
|
|
39
43
|
};
|
|
40
|
-
function
|
|
41
|
-
return
|
|
44
|
+
function de(n) {
|
|
45
|
+
return n && n.__esModule && Object.prototype.hasOwnProperty.call(n, "default") ? n.default : n;
|
|
42
46
|
}
|
|
43
|
-
var P,
|
|
44
|
-
function
|
|
45
|
-
if (
|
|
46
|
-
|
|
47
|
-
const
|
|
47
|
+
var P, N;
|
|
48
|
+
function me() {
|
|
49
|
+
if (N) return P;
|
|
50
|
+
N = 1;
|
|
51
|
+
const n = [
|
|
48
52
|
[
|
|
49
53
|
{ color: "0, 0, 0", class: "ansi-black" },
|
|
50
54
|
{ color: "187, 0, 0", class: "ansi-red" },
|
|
@@ -65,7 +69,7 @@ function ne() {
|
|
|
65
69
|
{ color: "85, 255, 255", class: "ansi-bright-cyan" },
|
|
66
70
|
{ color: "255, 255, 255", class: "ansi-bright-white" }
|
|
67
71
|
]
|
|
68
|
-
],
|
|
72
|
+
], c = /(https?:\/\/(?:[A-Za-z0-9#;/?:@=+$',_.!~*()[\]-]|&|%[A-Fa-f0-9]{2})+)/gm;
|
|
69
73
|
class g {
|
|
70
74
|
/**
|
|
71
75
|
* Anser.escapeForHtml
|
|
@@ -80,8 +84,8 @@ function ne() {
|
|
|
80
84
|
* @param {String} txt The input text (containing the ANSI snippets).
|
|
81
85
|
* @returns {String} The escaped html.
|
|
82
86
|
*/
|
|
83
|
-
static escapeForHtml(
|
|
84
|
-
return new g().escapeForHtml(
|
|
87
|
+
static escapeForHtml(t) {
|
|
88
|
+
return new g().escapeForHtml(t);
|
|
85
89
|
}
|
|
86
90
|
/**
|
|
87
91
|
* Anser.linkify
|
|
@@ -95,8 +99,8 @@ function ne() {
|
|
|
95
99
|
* @param {String} txt The input text.
|
|
96
100
|
* @returns {String} The HTML containing the <a> tags (unescaped).
|
|
97
101
|
*/
|
|
98
|
-
static linkify(
|
|
99
|
-
return new g().linkify(
|
|
102
|
+
static linkify(t) {
|
|
103
|
+
return new g().linkify(t);
|
|
100
104
|
}
|
|
101
105
|
/**
|
|
102
106
|
* Anser.ansiToHtml
|
|
@@ -122,8 +126,8 @@ function ne() {
|
|
|
122
126
|
* @param {Object} options The options passed to the ansiToHTML method.
|
|
123
127
|
* @returns {String} The HTML output.
|
|
124
128
|
*/
|
|
125
|
-
static ansiToHtml(
|
|
126
|
-
return new g().ansiToHtml(
|
|
129
|
+
static ansiToHtml(t, e) {
|
|
130
|
+
return new g().ansiToHtml(t, e);
|
|
127
131
|
}
|
|
128
132
|
/**
|
|
129
133
|
* Anser.ansiToJson
|
|
@@ -135,8 +139,8 @@ function ne() {
|
|
|
135
139
|
* @param {Object} options The options passed to the ansiToHTML method.
|
|
136
140
|
* @returns {String} The HTML output.
|
|
137
141
|
*/
|
|
138
|
-
static ansiToJson(
|
|
139
|
-
return new g().ansiToJson(
|
|
142
|
+
static ansiToJson(t, e) {
|
|
143
|
+
return new g().ansiToJson(t, e);
|
|
140
144
|
}
|
|
141
145
|
/**
|
|
142
146
|
* Anser.ansiToText
|
|
@@ -147,8 +151,8 @@ function ne() {
|
|
|
147
151
|
* @param {String} txt The input text.
|
|
148
152
|
* @returns {String} The text output.
|
|
149
153
|
*/
|
|
150
|
-
static ansiToText(
|
|
151
|
-
return new g().ansiToText(
|
|
154
|
+
static ansiToText(t) {
|
|
155
|
+
return new g().ansiToText(t);
|
|
152
156
|
}
|
|
153
157
|
/**
|
|
154
158
|
* Anser
|
|
@@ -170,16 +174,16 @@ function ne() {
|
|
|
170
174
|
*/
|
|
171
175
|
setupPalette() {
|
|
172
176
|
this.PALETTE_COLORS = [];
|
|
173
|
-
for (let
|
|
177
|
+
for (let r = 0; r < 2; ++r)
|
|
174
178
|
for (let l = 0; l < 8; ++l)
|
|
175
|
-
this.PALETTE_COLORS.push(
|
|
176
|
-
let
|
|
177
|
-
for (let
|
|
179
|
+
this.PALETTE_COLORS.push(n[r][l].color);
|
|
180
|
+
let t = [0, 95, 135, 175, 215, 255], e = (r, l, a) => t[r] + ", " + t[l] + ", " + t[a];
|
|
181
|
+
for (let r = 0; r < 6; ++r)
|
|
178
182
|
for (let l = 0; l < 6; ++l)
|
|
179
183
|
for (let a = 0; a < 6; ++a)
|
|
180
|
-
this.PALETTE_COLORS.push(
|
|
184
|
+
this.PALETTE_COLORS.push(e(r, l, a));
|
|
181
185
|
let h = 8;
|
|
182
|
-
for (let
|
|
186
|
+
for (let r = 0; r < 24; ++r, h += 10)
|
|
183
187
|
this.PALETTE_COLORS.push(h + ", " + h + ", " + h);
|
|
184
188
|
}
|
|
185
189
|
/**
|
|
@@ -191,10 +195,10 @@ function ne() {
|
|
|
191
195
|
* @param {String} txt The input text.
|
|
192
196
|
* @returns {String} The escpaed HTML output.
|
|
193
197
|
*/
|
|
194
|
-
escapeForHtml(
|
|
195
|
-
return
|
|
198
|
+
escapeForHtml(t) {
|
|
199
|
+
return t.replace(
|
|
196
200
|
/[&<>\"]/gm,
|
|
197
|
-
(
|
|
201
|
+
(e) => e == "&" ? "&" : e == '"' ? """ : e == "<" ? "<" : e == ">" ? ">" : ""
|
|
198
202
|
);
|
|
199
203
|
}
|
|
200
204
|
/**
|
|
@@ -206,8 +210,8 @@ function ne() {
|
|
|
206
210
|
* @param {String} txt The input text.
|
|
207
211
|
* @returns {String} The HTML output containing link elements.
|
|
208
212
|
*/
|
|
209
|
-
linkify(
|
|
210
|
-
return
|
|
213
|
+
linkify(t) {
|
|
214
|
+
return t.replace(c, (e) => `<a href="${e}">${e}</a>`);
|
|
211
215
|
}
|
|
212
216
|
/**
|
|
213
217
|
* ansiToHtml
|
|
@@ -219,8 +223,8 @@ function ne() {
|
|
|
219
223
|
* @param {Object} options The options passed ot the `process` method.
|
|
220
224
|
* @returns {String} The HTML output.
|
|
221
225
|
*/
|
|
222
|
-
ansiToHtml(
|
|
223
|
-
return this.process(
|
|
226
|
+
ansiToHtml(t, e) {
|
|
227
|
+
return this.process(t, e, !0);
|
|
224
228
|
}
|
|
225
229
|
/**
|
|
226
230
|
* ansiToJson
|
|
@@ -232,8 +236,8 @@ function ne() {
|
|
|
232
236
|
* @param {Object} options The options passed ot the `process` method.
|
|
233
237
|
* @returns {String} The JSON output.
|
|
234
238
|
*/
|
|
235
|
-
ansiToJson(
|
|
236
|
-
return
|
|
239
|
+
ansiToJson(t, e) {
|
|
240
|
+
return e = e || {}, e.json = !0, e.clearLine = !1, this.process(t, e, !0);
|
|
237
241
|
}
|
|
238
242
|
/**
|
|
239
243
|
* ansiToText
|
|
@@ -244,8 +248,8 @@ function ne() {
|
|
|
244
248
|
* @param {String} txt The input text.
|
|
245
249
|
* @returns {String} The text output.
|
|
246
250
|
*/
|
|
247
|
-
ansiToText(
|
|
248
|
-
return this.process(
|
|
251
|
+
ansiToText(t) {
|
|
252
|
+
return this.process(t, {}, !1);
|
|
249
253
|
}
|
|
250
254
|
/**
|
|
251
255
|
* process
|
|
@@ -261,16 +265,16 @@ function ne() {
|
|
|
261
265
|
*
|
|
262
266
|
* @param {Boolean} markup
|
|
263
267
|
*/
|
|
264
|
-
process(
|
|
265
|
-
let
|
|
266
|
-
|
|
267
|
-
let
|
|
268
|
-
if (
|
|
269
|
-
let
|
|
270
|
-
return
|
|
268
|
+
process(t, e, h) {
|
|
269
|
+
let r = this, l = t.split(/\033\[/), a = l.shift();
|
|
270
|
+
e == null && (e = {}), e.clearLine = /\r/.test(t);
|
|
271
|
+
let u = l.map((f) => this.processChunk(f, e, h));
|
|
272
|
+
if (e && e.json) {
|
|
273
|
+
let f = r.processChunkJson("");
|
|
274
|
+
return f.content = a, f.clearLine = e.clearLine, u.unshift(f), e.remove_empty && (u = u.filter((s) => !s.isEmpty())), u;
|
|
271
275
|
} else
|
|
272
|
-
|
|
273
|
-
return
|
|
276
|
+
u.unshift(a);
|
|
277
|
+
return u.join("");
|
|
274
278
|
}
|
|
275
279
|
/**
|
|
276
280
|
* processChunkJson
|
|
@@ -297,99 +301,99 @@ function ne() {
|
|
|
297
301
|
* - `isEmpty` (Function): A function returning `true` if the content is empty, or `false` otherwise.
|
|
298
302
|
*
|
|
299
303
|
*/
|
|
300
|
-
processChunkJson(
|
|
301
|
-
|
|
302
|
-
let
|
|
303
|
-
content:
|
|
304
|
+
processChunkJson(t, e, h) {
|
|
305
|
+
e = typeof e > "u" ? {} : e;
|
|
306
|
+
let r = e.use_classes = typeof e.use_classes < "u" && e.use_classes, l = e.key = r ? "class" : "color", a = {
|
|
307
|
+
content: t,
|
|
304
308
|
fg: null,
|
|
305
309
|
bg: null,
|
|
306
310
|
fg_truecolor: null,
|
|
307
311
|
bg_truecolor: null,
|
|
308
312
|
isInverted: !1,
|
|
309
|
-
clearLine:
|
|
313
|
+
clearLine: e.clearLine,
|
|
310
314
|
decoration: null,
|
|
311
315
|
decorations: [],
|
|
312
316
|
was_processed: !1,
|
|
313
317
|
isEmpty: () => !a.content
|
|
314
|
-
},
|
|
315
|
-
if (!
|
|
316
|
-
a.content =
|
|
317
|
-
let
|
|
318
|
-
if (
|
|
318
|
+
}, u = t.match(/^([!\x3c-\x3f]*)([\d;]*)([\x20-\x2c]*[\x40-\x7e])([\s\S]*)/m);
|
|
319
|
+
if (!u) return a;
|
|
320
|
+
a.content = u[4];
|
|
321
|
+
let f = u[2].split(";");
|
|
322
|
+
if (u[1] !== "" || u[3] !== "m" || !h)
|
|
319
323
|
return a;
|
|
320
|
-
let
|
|
321
|
-
for (;
|
|
322
|
-
let
|
|
324
|
+
let s = this;
|
|
325
|
+
for (; f.length > 0; ) {
|
|
326
|
+
let v = f.shift(), i = parseInt(v);
|
|
323
327
|
if (isNaN(i) || i === 0)
|
|
324
|
-
|
|
328
|
+
s.fg = s.bg = null, s.decorations = [];
|
|
325
329
|
else if (i === 1)
|
|
326
|
-
|
|
330
|
+
s.decorations.push("bold");
|
|
327
331
|
else if (i === 2)
|
|
328
|
-
|
|
332
|
+
s.decorations.push("dim");
|
|
329
333
|
else if (i === 3)
|
|
330
|
-
|
|
334
|
+
s.decorations.push("italic");
|
|
331
335
|
else if (i === 4)
|
|
332
|
-
|
|
336
|
+
s.decorations.push("underline");
|
|
333
337
|
else if (i === 5)
|
|
334
|
-
|
|
338
|
+
s.decorations.push("blink");
|
|
335
339
|
else if (i === 7)
|
|
336
|
-
|
|
340
|
+
s.decorations.push("reverse");
|
|
337
341
|
else if (i === 8)
|
|
338
|
-
|
|
342
|
+
s.decorations.push("hidden");
|
|
339
343
|
else if (i === 9)
|
|
340
|
-
|
|
344
|
+
s.decorations.push("strikethrough");
|
|
341
345
|
else if (i === 21)
|
|
342
|
-
|
|
346
|
+
s.removeDecoration("bold");
|
|
343
347
|
else if (i === 22)
|
|
344
|
-
|
|
348
|
+
s.removeDecoration("bold"), s.removeDecoration("dim");
|
|
345
349
|
else if (i === 23)
|
|
346
|
-
|
|
350
|
+
s.removeDecoration("italic");
|
|
347
351
|
else if (i === 24)
|
|
348
|
-
|
|
352
|
+
s.removeDecoration("underline");
|
|
349
353
|
else if (i === 25)
|
|
350
|
-
|
|
354
|
+
s.removeDecoration("blink");
|
|
351
355
|
else if (i === 27)
|
|
352
|
-
|
|
356
|
+
s.removeDecoration("reverse");
|
|
353
357
|
else if (i === 28)
|
|
354
|
-
|
|
358
|
+
s.removeDecoration("hidden");
|
|
355
359
|
else if (i === 29)
|
|
356
|
-
|
|
360
|
+
s.removeDecoration("strikethrough");
|
|
357
361
|
else if (i === 39)
|
|
358
|
-
|
|
362
|
+
s.fg = null;
|
|
359
363
|
else if (i === 49)
|
|
360
|
-
|
|
364
|
+
s.bg = null;
|
|
361
365
|
else if (i >= 30 && i < 38)
|
|
362
|
-
|
|
366
|
+
s.fg = n[0][i % 10][l];
|
|
363
367
|
else if (i >= 90 && i < 98)
|
|
364
|
-
|
|
368
|
+
s.fg = n[1][i % 10][l];
|
|
365
369
|
else if (i >= 40 && i < 48)
|
|
366
|
-
|
|
370
|
+
s.bg = n[0][i % 10][l];
|
|
367
371
|
else if (i >= 100 && i < 108)
|
|
368
|
-
|
|
372
|
+
s.bg = n[1][i % 10][l];
|
|
369
373
|
else if (i === 38 || i === 48) {
|
|
370
|
-
let
|
|
371
|
-
if (
|
|
372
|
-
let
|
|
373
|
-
if (
|
|
374
|
-
let
|
|
375
|
-
if (
|
|
376
|
-
if (!
|
|
377
|
-
this.PALETTE_COLORS ||
|
|
374
|
+
let b = i === 38;
|
|
375
|
+
if (f.length >= 1) {
|
|
376
|
+
let w = f.shift();
|
|
377
|
+
if (w === "5" && f.length >= 1) {
|
|
378
|
+
let _ = parseInt(f.shift());
|
|
379
|
+
if (_ >= 0 && _ <= 255)
|
|
380
|
+
if (!r)
|
|
381
|
+
this.PALETTE_COLORS || s.setupPalette(), b ? s.fg = this.PALETTE_COLORS[_] : s.bg = this.PALETTE_COLORS[_];
|
|
378
382
|
else {
|
|
379
|
-
let
|
|
380
|
-
|
|
383
|
+
let d = _ >= 16 ? "ansi-palette-" + _ : n[_ > 7 ? 1 : 0][_ % 8].class;
|
|
384
|
+
b ? s.fg = d : s.bg = d;
|
|
381
385
|
}
|
|
382
|
-
} else if (
|
|
383
|
-
let
|
|
384
|
-
if (
|
|
385
|
-
let
|
|
386
|
-
|
|
386
|
+
} else if (w === "2" && f.length >= 3) {
|
|
387
|
+
let _ = parseInt(f.shift()), d = parseInt(f.shift()), o = parseInt(f.shift());
|
|
388
|
+
if (_ >= 0 && _ <= 255 && d >= 0 && d <= 255 && o >= 0 && o <= 255) {
|
|
389
|
+
let T = _ + ", " + d + ", " + o;
|
|
390
|
+
r ? b ? (s.fg = "ansi-truecolor", s.fg_truecolor = T) : (s.bg = "ansi-truecolor", s.bg_truecolor = T) : b ? s.fg = T : s.bg = T;
|
|
387
391
|
}
|
|
388
392
|
}
|
|
389
393
|
}
|
|
390
394
|
}
|
|
391
395
|
}
|
|
392
|
-
return
|
|
396
|
+
return s.fg === null && s.bg === null && s.decorations.length === 0 || (a.fg = s.fg, a.bg = s.bg, a.fg_truecolor = s.fg_truecolor, a.bg_truecolor = s.bg_truecolor, a.decorations = s.decorations, a.decoration = s.decorations.slice(-1).pop() || null, a.was_processed = !0), a;
|
|
393
397
|
}
|
|
394
398
|
/**
|
|
395
399
|
* processChunk
|
|
@@ -406,207 +410,207 @@ function ne() {
|
|
|
406
410
|
* @param {Boolean} markup If false, the colors will not be parsed.
|
|
407
411
|
* @return {Object|String} The result (object if `json` is wanted back or string otherwise).
|
|
408
412
|
*/
|
|
409
|
-
processChunk(
|
|
410
|
-
|
|
411
|
-
let
|
|
412
|
-
if (
|
|
413
|
+
processChunk(t, e, h) {
|
|
414
|
+
e = e || {};
|
|
415
|
+
let r = this.processChunkJson(t, e, h), l = e.use_classes;
|
|
416
|
+
if (r.decorations = r.decorations.filter((i) => {
|
|
413
417
|
if (i === "reverse") {
|
|
414
|
-
|
|
415
|
-
let
|
|
416
|
-
|
|
417
|
-
let
|
|
418
|
-
return
|
|
418
|
+
r.fg || (r.fg = n[0][7][l ? "class" : "color"]), r.bg || (r.bg = n[0][0][l ? "class" : "color"]);
|
|
419
|
+
let b = r.fg;
|
|
420
|
+
r.fg = r.bg, r.bg = b;
|
|
421
|
+
let w = r.fg_truecolor;
|
|
422
|
+
return r.fg_truecolor = r.bg_truecolor, r.bg_truecolor = w, r.isInverted = !0, !1;
|
|
419
423
|
}
|
|
420
424
|
return !0;
|
|
421
|
-
}),
|
|
422
|
-
return
|
|
423
|
-
if (
|
|
425
|
+
}), e.json)
|
|
426
|
+
return r;
|
|
427
|
+
if (r.isEmpty())
|
|
424
428
|
return "";
|
|
425
|
-
if (!
|
|
426
|
-
return
|
|
427
|
-
let a = [],
|
|
428
|
-
let
|
|
429
|
-
for (
|
|
430
|
-
i.hasOwnProperty(
|
|
431
|
-
return
|
|
429
|
+
if (!r.was_processed)
|
|
430
|
+
return r.content;
|
|
431
|
+
let a = [], u = [], f = [], s = {}, v = (i) => {
|
|
432
|
+
let b = [], w;
|
|
433
|
+
for (w in i)
|
|
434
|
+
i.hasOwnProperty(w) && b.push("data-" + w + '="' + this.escapeForHtml(i[w]) + '"');
|
|
435
|
+
return b.length > 0 ? " " + b.join(" ") : "";
|
|
432
436
|
};
|
|
433
|
-
return
|
|
437
|
+
return r.isInverted && (s["ansi-is-inverted"] = "true"), r.fg && (l ? (a.push(r.fg + "-fg"), r.fg_truecolor !== null && (s["ansi-truecolor-fg"] = r.fg_truecolor, r.fg_truecolor = null)) : a.push("color:rgb(" + r.fg + ")")), r.bg && (l ? (a.push(r.bg + "-bg"), r.bg_truecolor !== null && (s["ansi-truecolor-bg"] = r.bg_truecolor, r.bg_truecolor = null)) : a.push("background-color:rgb(" + r.bg + ")")), r.decorations.forEach((i) => {
|
|
434
438
|
if (l) {
|
|
435
|
-
|
|
439
|
+
u.push("ansi-" + i);
|
|
436
440
|
return;
|
|
437
441
|
}
|
|
438
|
-
i === "bold" ?
|
|
439
|
-
}),
|
|
442
|
+
i === "bold" ? u.push("font-weight:bold") : i === "dim" ? u.push("opacity:0.5") : i === "italic" ? u.push("font-style:italic") : i === "hidden" ? u.push("visibility:hidden") : i === "strikethrough" ? f.push("line-through") : f.push(i);
|
|
443
|
+
}), f.length && u.push("text-decoration:" + f.join(" ")), l ? '<span class="' + a.concat(u).join(" ") + '"' + v(s) + ">" + r.content + "</span>" : '<span style="' + a.concat(u).join(";") + '"' + v(s) + ">" + r.content + "</span>";
|
|
440
444
|
}
|
|
441
|
-
removeDecoration(
|
|
442
|
-
const
|
|
443
|
-
|
|
445
|
+
removeDecoration(t) {
|
|
446
|
+
const e = this.decorations.indexOf(t);
|
|
447
|
+
e >= 0 && this.decorations.splice(e, 1);
|
|
444
448
|
}
|
|
445
449
|
}
|
|
446
450
|
return P = g, P;
|
|
447
451
|
}
|
|
448
|
-
var
|
|
449
|
-
const
|
|
450
|
-
var
|
|
451
|
-
function
|
|
452
|
-
if (
|
|
453
|
-
|
|
454
|
-
function
|
|
455
|
-
if (!
|
|
456
|
-
if (!/\r/.test(
|
|
457
|
-
for (
|
|
458
|
-
`); /\r./.test(
|
|
459
|
-
|
|
460
|
-
return
|
|
452
|
+
var be = me();
|
|
453
|
+
const we = /* @__PURE__ */ de(be);
|
|
454
|
+
var x = { exports: {} }, H;
|
|
455
|
+
function ke() {
|
|
456
|
+
if (H) return x.exports;
|
|
457
|
+
H = 1;
|
|
458
|
+
function n(t) {
|
|
459
|
+
if (!t) return "";
|
|
460
|
+
if (!/\r/.test(t)) return t;
|
|
461
|
+
for (t = t.replace(/\r+\n/gm, `
|
|
462
|
+
`); /\r./.test(t); )
|
|
463
|
+
t = t.replace(/^([^\r\n]*)\r+([^\r\n]+)/gm, function(e, h, r) {
|
|
464
|
+
return r + h.slice(r.length);
|
|
461
465
|
});
|
|
462
|
-
return r;
|
|
463
|
-
}
|
|
464
|
-
function o(r) {
|
|
465
|
-
for (var t = 0, h = 0; h < r.length; h++)
|
|
466
|
-
r[t].length <= r[h].length && (t = h);
|
|
467
466
|
return t;
|
|
468
467
|
}
|
|
469
|
-
function
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
468
|
+
function c(t) {
|
|
469
|
+
for (var e = 0, h = 0; h < t.length; h++)
|
|
470
|
+
t[e].length <= t[h].length && (e = h);
|
|
471
|
+
return e;
|
|
472
|
+
}
|
|
473
|
+
function g(t) {
|
|
474
|
+
if (!/\r/.test(t)) return t;
|
|
475
|
+
for (var e = t.split("\r"), h = []; e.length > 0; ) {
|
|
476
|
+
var r = c(e);
|
|
477
|
+
h.push(e[r]), e = e.slice(r + 1);
|
|
474
478
|
}
|
|
475
479
|
return h.join("\r");
|
|
476
480
|
}
|
|
477
|
-
function
|
|
478
|
-
if (!
|
|
479
|
-
if (!/\r/.test(
|
|
480
|
-
if (!/\n/.test(
|
|
481
|
-
|
|
481
|
+
function y(t) {
|
|
482
|
+
if (!t) return "";
|
|
483
|
+
if (!/\r/.test(t)) return t;
|
|
484
|
+
if (!/\n/.test(t)) return g(t);
|
|
485
|
+
t = t.replace(/\r+\n/gm, `
|
|
482
486
|
`);
|
|
483
|
-
var
|
|
487
|
+
var e = t.lastIndexOf(`
|
|
484
488
|
`);
|
|
485
|
-
return
|
|
486
|
-
` + g(
|
|
489
|
+
return n(t.slice(0, e)) + `
|
|
490
|
+
` + g(t.slice(e + 1));
|
|
487
491
|
}
|
|
488
|
-
return
|
|
492
|
+
return x.exports = n, x.exports.escapeCarriageReturn = n, x.exports.escapeCarriageReturnSafe = y, x.exports;
|
|
489
493
|
}
|
|
490
|
-
var
|
|
491
|
-
function
|
|
492
|
-
return
|
|
494
|
+
var Ce = ke();
|
|
495
|
+
function ve(n, c) {
|
|
496
|
+
return n = Ce.escapeCarriageReturn(xe(n)), we.ansiToJson(n, {
|
|
493
497
|
json: !0,
|
|
494
498
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
495
499
|
remove_empty: !0,
|
|
496
500
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
497
|
-
use_classes:
|
|
501
|
+
use_classes: c
|
|
498
502
|
});
|
|
499
503
|
}
|
|
500
|
-
function
|
|
501
|
-
const
|
|
502
|
-
return
|
|
504
|
+
function Se(n) {
|
|
505
|
+
const c = [];
|
|
506
|
+
return n.bg && c.push(C[`${n.bg}-bg`]), n.fg && c.push(C[`${n.fg}-fg`]), n.decoration && c.push(C[`ansi-${n.decoration}`]), c.length === 0 ? null : c.join(" ");
|
|
503
507
|
}
|
|
504
|
-
function
|
|
505
|
-
const
|
|
506
|
-
switch (
|
|
508
|
+
function Te(n) {
|
|
509
|
+
const c = {};
|
|
510
|
+
switch (n.bg && (c.backgroundColor = `rgb(${n.bg})`), n.fg && (c.color = `rgb(${n.fg})`), n.decoration) {
|
|
507
511
|
case "bold":
|
|
508
|
-
|
|
512
|
+
c.fontWeight = "bold";
|
|
509
513
|
break;
|
|
510
514
|
case "dim":
|
|
511
|
-
|
|
515
|
+
c.opacity = "0.5";
|
|
512
516
|
break;
|
|
513
517
|
case "italic":
|
|
514
|
-
|
|
518
|
+
c.fontStyle = "italic";
|
|
515
519
|
break;
|
|
516
520
|
case "hidden":
|
|
517
|
-
|
|
521
|
+
c.visibility = "hidden";
|
|
518
522
|
break;
|
|
519
523
|
case "strikethrough":
|
|
520
|
-
|
|
524
|
+
c.textDecoration = "line-through";
|
|
521
525
|
break;
|
|
522
526
|
case "underline":
|
|
523
|
-
|
|
527
|
+
c.textDecoration = "underline";
|
|
524
528
|
break;
|
|
525
529
|
case "blink":
|
|
526
|
-
|
|
530
|
+
c.textDecoration = "blink";
|
|
527
531
|
break;
|
|
528
532
|
}
|
|
529
|
-
return
|
|
533
|
+
return c;
|
|
530
534
|
}
|
|
531
|
-
function
|
|
532
|
-
const
|
|
533
|
-
if (!
|
|
535
|
+
function Ee(n, c, g, y) {
|
|
536
|
+
const t = c ? null : Te(g), e = c ? Se(g) : null;
|
|
537
|
+
if (!n)
|
|
534
538
|
return L.createElement(
|
|
535
539
|
"pre",
|
|
536
|
-
{ style:
|
|
540
|
+
{ style: t, key: y, className: e },
|
|
537
541
|
g.content
|
|
538
542
|
);
|
|
539
|
-
const h = [],
|
|
543
|
+
const h = [], r = /(\s|^)(https?:\/\/(?:www\.|(?!www))[^\s.]+\.[^\s]{2,}|www\.[^\s]+\.[^\s]{2,})/g;
|
|
540
544
|
let l = 0, a;
|
|
541
|
-
for (; (a =
|
|
542
|
-
const [,
|
|
543
|
-
|
|
544
|
-
const
|
|
545
|
+
for (; (a = r.exec(g.content)) !== null; ) {
|
|
546
|
+
const [, u, f] = a, s = a.index + u.length;
|
|
547
|
+
s > l && h.push(g.content.substring(l, s));
|
|
548
|
+
const v = f.startsWith("www.") ? `http://${f}` : f;
|
|
545
549
|
h.push(
|
|
546
550
|
L.createElement(
|
|
547
551
|
"a",
|
|
548
552
|
{
|
|
549
553
|
key: l,
|
|
550
|
-
href:
|
|
554
|
+
href: v,
|
|
551
555
|
target: "_blank"
|
|
552
556
|
},
|
|
553
|
-
`${
|
|
557
|
+
`${f}`
|
|
554
558
|
)
|
|
555
|
-
), l =
|
|
559
|
+
), l = r.lastIndex;
|
|
556
560
|
}
|
|
557
|
-
return l < g.content.length && h.push(g.content.substring(l)), L.createElement("span", { style:
|
|
561
|
+
return l < g.content.length && h.push(g.content.substring(l)), L.createElement("span", { style: t, key: y, className: e }, h);
|
|
558
562
|
}
|
|
559
|
-
function
|
|
560
|
-
const { className:
|
|
563
|
+
function K(n) {
|
|
564
|
+
const { className: c, useClasses: g, children: y, linkify: t } = n;
|
|
561
565
|
return L.createElement(
|
|
562
566
|
"code",
|
|
563
|
-
{ className:
|
|
564
|
-
|
|
565
|
-
|
|
567
|
+
{ className: c },
|
|
568
|
+
ve(y ?? "", g ?? !1).map(
|
|
569
|
+
Ee.bind(null, t ?? !1, g ?? !1)
|
|
566
570
|
)
|
|
567
571
|
);
|
|
568
572
|
}
|
|
569
|
-
function
|
|
570
|
-
let
|
|
573
|
+
function xe(n) {
|
|
574
|
+
let c = n;
|
|
571
575
|
do
|
|
572
|
-
|
|
573
|
-
while (
|
|
574
|
-
return
|
|
576
|
+
n = c, c = n.replace(/[^\n]\x08/gm, "");
|
|
577
|
+
while (c.length < n.length);
|
|
578
|
+
return n;
|
|
575
579
|
}
|
|
576
|
-
const A =
|
|
577
|
-
const g =
|
|
580
|
+
const A = se(ne(({ text: n }, c) => {
|
|
581
|
+
const g = n?.split(`
|
|
578
582
|
`);
|
|
579
|
-
return /* @__PURE__ */ k("div", { ref:
|
|
580
|
-
(
|
|
583
|
+
return /* @__PURE__ */ k("div", { ref: c, children: g?.map(
|
|
584
|
+
(y, t) => /* @__PURE__ */ k(K, { className: C.Output, useClasses: !0, children: y === "" ? " " : y }, t)
|
|
581
585
|
) });
|
|
582
|
-
});
|
|
583
|
-
function
|
|
584
|
-
const [h,
|
|
585
|
-
|
|
586
|
-
const
|
|
587
|
-
|
|
588
|
-
}, [
|
|
586
|
+
}));
|
|
587
|
+
function Re({ value: n, prefix: c, onChange: g, onKeyUp: y, onKeyDown: t, inputRef: e }) {
|
|
588
|
+
const [h, r] = j(0), l = O(null);
|
|
589
|
+
ie(() => {
|
|
590
|
+
const u = e.current;
|
|
591
|
+
u && l.current !== null ? (u.setSelectionRange(l.current, l.current), r(l.current), l.current = null) : u && u.selectionStart !== null && r(u.selectionStart);
|
|
592
|
+
}, [n, e]);
|
|
589
593
|
const a = () => {
|
|
590
|
-
const
|
|
591
|
-
|
|
594
|
+
const u = e.current?.selectionStart;
|
|
595
|
+
u != null && r(u);
|
|
592
596
|
};
|
|
593
597
|
return /* @__PURE__ */ I("span", { className: C.Input, children: [
|
|
594
|
-
|
|
598
|
+
c && /* @__PURE__ */ k(K, { className: C.Prefix, useClasses: !0, children: c }),
|
|
595
599
|
/* @__PURE__ */ I("span", { className: C["Input-container"], style: { "--cursor-offset": h }, children: [
|
|
596
|
-
/* @__PURE__ */ k("span", { "aria-hidden": "true", children:
|
|
600
|
+
/* @__PURE__ */ k("span", { "aria-hidden": "true", children: n }),
|
|
597
601
|
/* @__PURE__ */ k(
|
|
598
602
|
"input",
|
|
599
603
|
{
|
|
600
604
|
id: "input",
|
|
601
|
-
value:
|
|
605
|
+
value: n,
|
|
602
606
|
"aria-label": "Command input",
|
|
603
|
-
onChange: (
|
|
604
|
-
l.current =
|
|
607
|
+
onChange: (u) => {
|
|
608
|
+
l.current = u.target.selectionStart, g(u);
|
|
605
609
|
},
|
|
606
|
-
ref:
|
|
607
|
-
onKeyUp:
|
|
608
|
-
onKeyDown: (
|
|
609
|
-
|
|
610
|
+
ref: e,
|
|
611
|
+
onKeyUp: y,
|
|
612
|
+
onKeyDown: (u) => {
|
|
613
|
+
t?.(u), a();
|
|
610
614
|
},
|
|
611
615
|
onClick: a,
|
|
612
616
|
onSelect: a,
|
|
@@ -618,130 +622,145 @@ function he({ value: s, prefix: o, onChange: g, onKeyUp: d, onKeyDown: r, inputR
|
|
|
618
622
|
] })
|
|
619
623
|
] });
|
|
620
624
|
}
|
|
621
|
-
function
|
|
622
|
-
const
|
|
623
|
-
app:
|
|
624
|
-
path:
|
|
625
|
+
function Le({ app: n, path: c, input: g, setTitle: y, close: t, active: e, focus: h, autoSubmit: r }) {
|
|
626
|
+
const l = O(null), a = O(null), u = O(le.ZERO), { charSize: f, containerSize: s, sentinel: v } = Z({ containerRef: l }), [i, b] = j(0), [w, _] = j(!1), [d, o] = G({
|
|
627
|
+
app: n,
|
|
628
|
+
path: c,
|
|
625
629
|
input: g,
|
|
626
|
-
exit:
|
|
627
|
-
sizeRef:
|
|
630
|
+
exit: t,
|
|
631
|
+
sizeRef: u
|
|
628
632
|
});
|
|
629
633
|
E(() => {
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
}, [
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
634
|
+
r && g && o.prompt && !w && (_(!0), window.confirm(`Do you want to run the following command?
|
|
635
|
+
|
|
636
|
+
${g}`) && (d.run(g), b((p) => p + 1)));
|
|
637
|
+
}, [r, g, w, o.prompt, d]), E(() => {
|
|
638
|
+
y?.(oe.strip(o.prompt).trim());
|
|
639
|
+
}, [o.prompt, y]), E(() => {
|
|
640
|
+
e && (o.stream ? l.current?.focus() : a.current?.focus());
|
|
641
|
+
}, [e, o.stream]), E(() => {
|
|
642
|
+
if (a.current && !o.stream) {
|
|
643
|
+
const p = o.line.length;
|
|
644
|
+
a.current.setSelectionRange(p, p);
|
|
637
645
|
}
|
|
638
|
-
}, [
|
|
639
|
-
const
|
|
640
|
-
|
|
646
|
+
}, [o.historyOffset]);
|
|
647
|
+
const T = () => {
|
|
648
|
+
l.current && (l.current.scrollTop = l.current.scrollHeight);
|
|
641
649
|
};
|
|
642
650
|
E(() => {
|
|
643
|
-
|
|
644
|
-
}, [
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
if ((f.ctrlKey || f.metaKey) && _ === "c" && !f.shiftKey) {
|
|
659
|
-
f.preventDefault(), n.interrupt();
|
|
660
|
-
return;
|
|
661
|
-
}
|
|
662
|
-
if (!u.stream)
|
|
663
|
-
if (_ === "Tab")
|
|
664
|
-
f.preventDefault(), n.autoComplete();
|
|
665
|
-
else if (_ === "Enter") {
|
|
666
|
-
const w = f.target.value;
|
|
667
|
-
n.run(w), p((S) => S + 1);
|
|
668
|
-
} else _ === "ArrowUp" ? (f.preventDefault(), n.historySearch(1)) : _ === "ArrowDown" && (f.preventDefault(), n.historySearch(-1));
|
|
669
|
-
}, y = (f) => {
|
|
670
|
-
n.setLine(f.target.value);
|
|
671
|
-
}, b = () => {
|
|
672
|
-
if (u.isUsingAltScreen)
|
|
673
|
-
return u.ttyBuffer ? /* @__PURE__ */ k(A, { text: u.ttyBuffer }) : null;
|
|
674
|
-
let f = 0;
|
|
675
|
-
for (let _ = u.history.length - 1; _ >= 0; _--)
|
|
676
|
-
if (u.history[_].clear) {
|
|
677
|
-
f = _ + 1;
|
|
651
|
+
T();
|
|
652
|
+
}, [o.history.length, o.line, o.ttyBuffer]), E(() => {
|
|
653
|
+
u.current.set(s.x, s.y);
|
|
654
|
+
}, [s]);
|
|
655
|
+
const F = (p) => {
|
|
656
|
+
d.handleKeyDown(p), p.key === "Enter" && !o.stream && b((m) => m + 1);
|
|
657
|
+
}, M = (p) => {
|
|
658
|
+
d.setLine(p.target.value);
|
|
659
|
+
}, z = D(() => {
|
|
660
|
+
if (o.isUsingAltScreen)
|
|
661
|
+
return o.ttyBuffer ? /* @__PURE__ */ k(A, { text: o.ttyBuffer }) : null;
|
|
662
|
+
let p = 0;
|
|
663
|
+
for (let m = o.history.length - 1; m >= 0; m--)
|
|
664
|
+
if ((o.history[m].flags & Q.Clear) !== 0) {
|
|
665
|
+
p = m + 1;
|
|
678
666
|
break;
|
|
679
667
|
}
|
|
680
|
-
return
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
668
|
+
return o.history.slice(p).map(
|
|
669
|
+
(m, S) => /* @__PURE__ */ k(A, { text: m.displayText }, S)
|
|
670
|
+
);
|
|
671
|
+
}, [o.history, o.isUsingAltScreen, o.ttyBuffer]), J = (p) => {
|
|
672
|
+
h?.(p), p.button === 2 && (p.preventDefault(), navigator.clipboard.readText().then((m) => {
|
|
673
|
+
if (o.isRawMode) {
|
|
674
|
+
for (const R of m)
|
|
675
|
+
d.handleKeyDown({
|
|
676
|
+
key: R,
|
|
677
|
+
ctrlKey: p.ctrlKey,
|
|
678
|
+
metaKey: p.metaKey,
|
|
679
|
+
shiftKey: p.shiftKey,
|
|
680
|
+
preventDefault: p.preventDefault.bind(p)
|
|
681
|
+
});
|
|
682
|
+
return;
|
|
683
|
+
}
|
|
684
|
+
const S = a.current;
|
|
685
|
+
if (!S)
|
|
686
|
+
return;
|
|
687
|
+
const $ = S.selectionStart ?? o.line.length, W = S.selectionEnd ?? o.line.length;
|
|
688
|
+
d.setLine((R) => R.substring(0, $) + m + R.substring(W));
|
|
689
|
+
const B = $ + m.length;
|
|
693
690
|
setTimeout(() => {
|
|
694
|
-
|
|
691
|
+
S.focus(), S.setSelectionRange(B, B);
|
|
695
692
|
}, 0);
|
|
696
|
-
}).catch((
|
|
697
|
-
console.error(
|
|
693
|
+
}).catch((m) => {
|
|
694
|
+
console.error(m);
|
|
698
695
|
}));
|
|
699
|
-
},
|
|
700
|
-
|
|
701
|
-
}
|
|
696
|
+
}, U = (p) => {
|
|
697
|
+
p.preventDefault();
|
|
698
|
+
}, q = D(() => f.x === 0 || f.y === 0 ? {} : {
|
|
699
|
+
"--char-width": `${f.x}px`,
|
|
700
|
+
"--char-height": `${f.y}px`
|
|
701
|
+
}, [f]), V = D(() => !o.isRawMode || f.x === 0 || f.y === 0 ? {} : {
|
|
702
|
+
left: o.cursorPosition.x * f.x,
|
|
703
|
+
top: o.cursorPosition.y * f.y
|
|
704
|
+
}, [o.cursorPosition, o.isRawMode, f]);
|
|
702
705
|
return /* @__PURE__ */ I(
|
|
703
706
|
"div",
|
|
704
707
|
{
|
|
705
|
-
ref:
|
|
708
|
+
ref: l,
|
|
706
709
|
tabIndex: 0,
|
|
707
710
|
className: C.Terminal,
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
711
|
+
style: q,
|
|
712
|
+
onKeyDown: F,
|
|
713
|
+
onMouseDown: J,
|
|
714
|
+
onContextMenu: U,
|
|
715
|
+
onClick: (p) => {
|
|
716
|
+
window.getSelection()?.toString().length || (p.preventDefault(), o.stream ? l.current?.focus() : a.current?.focus());
|
|
713
717
|
},
|
|
714
718
|
children: [
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
719
|
+
v,
|
|
720
|
+
/* @__PURE__ */ I("div", { className: C.History, children: [
|
|
721
|
+
z,
|
|
722
|
+
o.isRawMode && /* @__PURE__ */ k("div", { className: C.VirtualCursor, style: V })
|
|
723
|
+
] }),
|
|
724
|
+
!o.isUsingAltScreen && !o.stream && /* @__PURE__ */ k(
|
|
725
|
+
Re,
|
|
718
726
|
{
|
|
719
|
-
value:
|
|
720
|
-
prefix:
|
|
721
|
-
onChange:
|
|
722
|
-
inputRef:
|
|
727
|
+
value: o.line,
|
|
728
|
+
prefix: (o.ttyBuffer ?? "") + o.prompt,
|
|
729
|
+
onChange: M,
|
|
730
|
+
inputRef: a
|
|
723
731
|
},
|
|
724
|
-
|
|
725
|
-
)
|
|
732
|
+
i
|
|
733
|
+
),
|
|
734
|
+
!o.isUsingAltScreen && o.stream && o.ttyBuffer && /* @__PURE__ */ k(A, { text: o.ttyBuffer }),
|
|
735
|
+
o.stream && /* @__PURE__ */ k(
|
|
736
|
+
X,
|
|
737
|
+
{
|
|
738
|
+
className: `${C.InterruptButton} ${Y.TextBold}`,
|
|
739
|
+
onClick: () => d.interrupt(),
|
|
740
|
+
title: "Interrupt (Ctrl+C)",
|
|
741
|
+
icon: ae,
|
|
742
|
+
children: "Stop"
|
|
743
|
+
}
|
|
744
|
+
)
|
|
726
745
|
]
|
|
727
746
|
}
|
|
728
747
|
);
|
|
729
748
|
}
|
|
730
|
-
class
|
|
749
|
+
class Oe extends ee {
|
|
731
750
|
constructor() {
|
|
732
|
-
super("Terminal", "terminal",
|
|
751
|
+
super("Terminal", "terminal", Le), this.setIconUrl("https://os.prozilla.dev/assets/apps/icons/terminal.svg"), this.setRole(te.APP_ROLES.terminal), this.setCategory("Utilities & tools");
|
|
733
752
|
}
|
|
734
|
-
addCommands(
|
|
735
|
-
return
|
|
753
|
+
addCommands(c) {
|
|
754
|
+
return c.forEach((g) => this.addCommand(g)), this;
|
|
736
755
|
}
|
|
737
|
-
addCommand(
|
|
738
|
-
return
|
|
756
|
+
addCommand(c) {
|
|
757
|
+
return re.builtins.push(c), this;
|
|
739
758
|
}
|
|
740
759
|
}
|
|
741
|
-
const
|
|
742
|
-
|
|
760
|
+
const Ie = new Oe();
|
|
761
|
+
Ie.setMetadata({ name: "@prozilla-os/terminal", version: "2.0.1", author: "Prozilla", website: "https://os.prozilla.dev/terminal" });
|
|
743
762
|
export {
|
|
744
|
-
|
|
745
|
-
|
|
763
|
+
Oe as TerminalApp,
|
|
764
|
+
Ie as terminal
|
|
746
765
|
};
|
|
747
766
|
//# sourceMappingURL=main.js.map
|