shelldeck 0.0.1__py3-none-any.whl
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.
- shelldeck/__init__.py +0 -0
- shelldeck/__main__.py +4 -0
- shelldeck/addons/__init__.py +1 -0
- shelldeck/addons/fast_context.py +1346 -0
- shelldeck/auth.py +207 -0
- shelldeck/cli.py +587 -0
- shelldeck/db.py +794 -0
- shelldeck/gitgraph.py +150 -0
- shelldeck/integration/bash.sh +27 -0
- shelldeck/integration/shelldeck.fish +5 -0
- shelldeck/integration/shelldeck.ps1 +35 -0
- shelldeck/integration/zsh/.zshenv +6 -0
- shelldeck/integration/zsh/.zshrc +10 -0
- shelldeck/pty.py +352 -0
- shelldeck/runner.py +75 -0
- shelldeck/scheduler.py +283 -0
- shelldeck/server.py +1216 -0
- shelldeck/shells.py +174 -0
- shelldeck/static/app.css +2288 -0
- shelldeck/static/app.js +1863 -0
- shelldeck/static/gitgraph.js +142 -0
- shelldeck/static/history.js +172 -0
- shelldeck/static/icon-192.png +0 -0
- shelldeck/static/icon-32.png +0 -0
- shelldeck/static/icon-512.png +0 -0
- shelldeck/static/icon.svg +1 -0
- shelldeck/static/index.html +102 -0
- shelldeck/static/manifest.webmanifest +1 -0
- shelldeck/static/monitor.js +143 -0
- shelldeck/static/ui.js +316 -0
- shelldeck/static/vendor/LICENSE-xterm.txt +21 -0
- shelldeck/static/vendor/addon-fit.js +2 -0
- shelldeck/static/vendor/addon-search.js +2 -0
- shelldeck/static/vendor/addon-serialize.js +2 -0
- shelldeck/static/vendor/addon-web-links.js +2 -0
- shelldeck/static/vendor/addon-webgl.js +2 -0
- shelldeck/static/vendor/xterm.css +218 -0
- shelldeck/static/vendor/xterm.js +2 -0
- shelldeck/static/views.js +658 -0
- shelldeck/stats.py +128 -0
- shelldeck-0.0.1.dist-info/METADATA +254 -0
- shelldeck-0.0.1.dist-info/RECORD +45 -0
- shelldeck-0.0.1.dist-info/WHEEL +4 -0
- shelldeck-0.0.1.dist-info/entry_points.txt +3 -0
- shelldeck-0.0.1.dist-info/licenses/LICENSE +21 -0
shelldeck/static/ui.js
ADDED
|
@@ -0,0 +1,316 @@
|
|
|
1
|
+
// Shared UI helpers: API, icons, dialogs, menus, toasts.
|
|
2
|
+
|
|
3
|
+
export const $ = (sel, root = document) => root.querySelector(sel);
|
|
4
|
+
export const $$ = (sel, root = document) => [...root.querySelectorAll(sel)];
|
|
5
|
+
|
|
6
|
+
export function esc(s) {
|
|
7
|
+
return String(s ?? "").replace(/[&<>"']/g, (c) => ({ "&": "&", "<": "<", ">": ">", '"': """, "'": "'" })[c]);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export const bus = new EventTarget();
|
|
11
|
+
|
|
12
|
+
export async function api(path, { method = "GET", body } = {}) {
|
|
13
|
+
const res = await fetch(path, {
|
|
14
|
+
method,
|
|
15
|
+
headers: body === undefined ? {} : { "Content-Type": "application/json" },
|
|
16
|
+
body: body === undefined ? undefined : JSON.stringify(body),
|
|
17
|
+
});
|
|
18
|
+
let data = null;
|
|
19
|
+
try {
|
|
20
|
+
data = await res.json();
|
|
21
|
+
} catch {
|
|
22
|
+
/* empty body */
|
|
23
|
+
}
|
|
24
|
+
if (res.status === 401 && (data?.error === "locked" || data?.error === "setup_required")) bus.dispatchEvent(new Event("locked"));
|
|
25
|
+
if (!res.ok) {
|
|
26
|
+
const e = new Error(data?.error || `HTTP ${res.status}`);
|
|
27
|
+
e.data = data;
|
|
28
|
+
throw e;
|
|
29
|
+
}
|
|
30
|
+
return data;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const AUTH_ERRORS = {
|
|
34
|
+
invalid_password: "Wrong password.",
|
|
35
|
+
wrong_current_password: "The current password is wrong.",
|
|
36
|
+
password_too_short: "Use at least 8 characters.",
|
|
37
|
+
passwords_do_not_match: "The new password and its confirmation don't match.",
|
|
38
|
+
invalid_setup_code: "That setup code is wrong. It is printed where shelldeck runs (and saved in its data folder as setup-code).",
|
|
39
|
+
password_already_set: "A password already exists. Reload to log in.",
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
/** Human text for an auth API error. */
|
|
43
|
+
export function authError(e) {
|
|
44
|
+
if (e.message === "too_many_attempts") return `Too many attempts. Try again in ${e.data?.retry_after || "a few"} seconds.`;
|
|
45
|
+
return AUTH_ERRORS[e.message] || e.message;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** Give every password field in `root` a show/hide eye button. */
|
|
49
|
+
export function withEyes(root) {
|
|
50
|
+
for (const input of root.querySelectorAll('input[type="password"]:not([data-eye])')) {
|
|
51
|
+
input.dataset.eye = "1";
|
|
52
|
+
const wrap = document.createElement("span");
|
|
53
|
+
wrap.className = "pw-wrap";
|
|
54
|
+
input.replaceWith(wrap);
|
|
55
|
+
const btn = document.createElement("button");
|
|
56
|
+
btn.type = "button";
|
|
57
|
+
btn.className = "pw-eye";
|
|
58
|
+
btn.setAttribute("aria-label", "Show password");
|
|
59
|
+
btn.setAttribute("aria-pressed", "false");
|
|
60
|
+
btn.title = "Show password";
|
|
61
|
+
btn.innerHTML = icon("eye");
|
|
62
|
+
btn.addEventListener("click", () => {
|
|
63
|
+
const show = input.type === "password";
|
|
64
|
+
input.type = show ? "text" : "password";
|
|
65
|
+
btn.innerHTML = icon(show ? "eye-off" : "eye");
|
|
66
|
+
btn.setAttribute("aria-pressed", String(show));
|
|
67
|
+
btn.setAttribute("aria-label", show ? "Hide password" : "Show password");
|
|
68
|
+
btn.title = show ? "Hide password" : "Show password";
|
|
69
|
+
input.focus();
|
|
70
|
+
});
|
|
71
|
+
wrap.append(input, btn);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// Icons: lucide-style strokes (ISC). Inline so the app works offline.
|
|
76
|
+
const P = {
|
|
77
|
+
plus: '<path d="M12 5v14M5 12h14"/>',
|
|
78
|
+
x: '<path d="M18 6 6 18M6 6l12 12"/>',
|
|
79
|
+
search: '<circle cx="11" cy="11" r="7"/><path d="m20 20-3.5-3.5"/>',
|
|
80
|
+
folder: '<path d="M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z"/>',
|
|
81
|
+
"folder-plus": '<path d="M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z"/><path d="M12 10v6M9 13h6"/>',
|
|
82
|
+
terminal: '<path d="m4 17 6-6-6-6M12 19h8"/>',
|
|
83
|
+
bookmark: '<path d="m19 21-7-4-7 4V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2Z"/>',
|
|
84
|
+
clock: '<circle cx="12" cy="12" r="9"/><path d="M12 7v5l3 2"/>',
|
|
85
|
+
kanban: '<rect x="3" y="3" width="18" height="18" rx="2"/><path d="M8 7v7M12 7v4M16 7v9"/>',
|
|
86
|
+
settings: '<path d="M4 21v-7M4 10V3M12 21v-9M12 8V3M20 21v-5M20 12V3M1 14h6M9 8h6M17 16h6"/>',
|
|
87
|
+
panel: '<rect x="3" y="3" width="18" height="18" rx="2"/><path d="M9 3v18"/>',
|
|
88
|
+
"split-h": '<rect x="3" y="3" width="18" height="18" rx="2"/><path d="M12 3v18"/>',
|
|
89
|
+
"split-v": '<rect x="3" y="3" width="18" height="18" rx="2"/><path d="M3 12h18"/>',
|
|
90
|
+
chevron: '<path d="m6 9 6 6 6-6"/>',
|
|
91
|
+
activity: '<path d="M22 12h-4l-3 9L9 3l-3 9H2"/>',
|
|
92
|
+
"chevron-up": '<path d="m18 15-6-6-6 6"/>',
|
|
93
|
+
more: '<circle cx="5" cy="12" r="1"/><circle cx="12" cy="12" r="1"/><circle cx="19" cy="12" r="1"/>',
|
|
94
|
+
maximize: '<path d="M8 3H5a2 2 0 0 0-2 2v3m18 0V5a2 2 0 0 0-2-2h-3m0 18h3a2 2 0 0 0 2-2v-3M3 16v3a2 2 0 0 0 2 2h3"/>',
|
|
95
|
+
minimize: '<path d="M8 3v3a2 2 0 0 1-2 2H3m18 0h-3a2 2 0 0 1-2-2V3m0 18v-3a2 2 0 0 1 2-2h3M3 16h3a2 2 0 0 1 2 2v3"/>',
|
|
96
|
+
play: '<path d="M6 3 20 12 6 21Z"/>',
|
|
97
|
+
history: '<path d="M3 12a9 9 0 1 0 3-6.7L3 8"/><path d="M3 3v5h5"/><path d="M12 7v5l3 2"/>',
|
|
98
|
+
external: '<path d="M15 3h6v6M10 14 21 3M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"/>',
|
|
99
|
+
pencil: '<path d="M12 20h9M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4Z"/>',
|
|
100
|
+
trash: '<path d="M3 6h18M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"/>',
|
|
101
|
+
lock: '<rect x="3" y="11" width="18" height="11" rx="2"/><path d="M7 11V7a5 5 0 0 1 10 0v4"/>',
|
|
102
|
+
up: '<path d="M12 19V5M5 12l7-7 7 7"/>',
|
|
103
|
+
clipboard: '<rect x="8" y="2" width="8" height="4" rx="1"/><path d="M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2"/>',
|
|
104
|
+
keyboard: '<rect x="2" y="4" width="20" height="16" rx="2"/><path d="M6 8h.01M10 8h.01M14 8h.01M18 8h.01M8 12h8M7 16h10"/>',
|
|
105
|
+
power: '<path d="M12 2v10M18.4 6.6a9 9 0 1 1-12.77.04"/>',
|
|
106
|
+
eye: '<path d="M2 12s3.5-7 10-7 10 7 10 7-3.5 7-10 7S2 12 2 12Z"/><circle cx="12" cy="12" r="3"/>',
|
|
107
|
+
"eye-off": '<path d="M9.9 4.2A10 10 0 0 1 12 4c6.5 0 10 8 10 8a17 17 0 0 1-2.2 3.2M6.6 6.6C3.9 8.3 2 12 2 12s3.5 8 10 8a9.7 9.7 0 0 0 5.4-1.6M9.9 9.9a3 3 0 0 0 4.2 4.2M2 2l20 20"/>',
|
|
108
|
+
grid: '<rect x="3" y="3" width="7" height="7" rx="1.5"/><rect x="14" y="3" width="7" height="7" rx="1.5"/><rect x="3" y="14" width="7" height="7" rx="1.5"/><rect x="14" y="14" width="7" height="7" rx="1.5"/>',
|
|
109
|
+
sun: '<circle cx="12" cy="12" r="4"/><path d="M12 2v2M12 20v2M4.9 4.9l1.4 1.4M17.7 17.7l1.4 1.4M2 12h2M20 12h2M4.9 19.1l1.4-1.4M17.7 6.3l1.4-1.4"/>',
|
|
110
|
+
"git-branch": '<line x1="6" y1="3" x2="6" y2="15"/><circle cx="18" cy="6" r="3"/><circle cx="6" cy="18" r="3"/><path d="M18 9a9 9 0 0 1-9 9"/>',
|
|
111
|
+
refresh: '<path d="M21 12a9 9 0 1 1-2.6-6.36M21 3v6h-6"/>',
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
export function icon(name) {
|
|
115
|
+
return `<i data-icon="${name}"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round">${P[name] || ""}</svg></i>`;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export function hydrateIcons(root = document) {
|
|
119
|
+
for (const el of $$("i[data-icon]:empty", root)) el.outerHTML = icon(el.dataset.icon);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// ---------------------------------------------------------------- dialogs
|
|
123
|
+
|
|
124
|
+
const dialogs = [];
|
|
125
|
+
|
|
126
|
+
export function topDialog() {
|
|
127
|
+
return dialogs.at(-1);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/** Opens a dialog. `body` is HTML. Returns {el, close}. */
|
|
131
|
+
export function dialog({ title = "", body = "", foot = "", wide = false, cls = "", onClose } = {}) {
|
|
132
|
+
const bg = document.createElement("div");
|
|
133
|
+
bg.className = "dialog-bg";
|
|
134
|
+
bg.innerHTML = `<div class="dialog ${wide ? "wide" : ""} ${cls}" role="dialog" aria-modal="true" aria-label="${esc(title)}" tabindex="-1">
|
|
135
|
+
${title ? `<div class="dialog-head"><h2>${esc(title)}</h2><button class="icon-btn" data-close aria-label="Close">${icon("x")}</button></div>` : ""}
|
|
136
|
+
<div class="dialog-body">${body}</div>
|
|
137
|
+
${foot ? `<div class="dialog-foot">${foot}</div>` : ""}
|
|
138
|
+
</div>`;
|
|
139
|
+
const prevFocus = document.activeElement;
|
|
140
|
+
const d = {
|
|
141
|
+
el: bg.firstElementChild,
|
|
142
|
+
close() {
|
|
143
|
+
if (!bg.isConnected) return;
|
|
144
|
+
bg.remove();
|
|
145
|
+
dialogs.splice(dialogs.indexOf(d), 1);
|
|
146
|
+
onClose?.();
|
|
147
|
+
prevFocus?.focus?.();
|
|
148
|
+
},
|
|
149
|
+
};
|
|
150
|
+
bg.addEventListener("mousedown", (e) => {
|
|
151
|
+
if (e.target === bg) d.close();
|
|
152
|
+
});
|
|
153
|
+
bg.addEventListener("click", (e) => {
|
|
154
|
+
if (e.target.closest("[data-close]")) d.close();
|
|
155
|
+
});
|
|
156
|
+
$("#dialog-root").append(bg);
|
|
157
|
+
dialogs.push(d);
|
|
158
|
+
hydrateIcons(bg);
|
|
159
|
+
// focus the dialog itself when it has no field, or keys (Escape) keep going to the terminal behind it
|
|
160
|
+
setTimeout(() => ($("[autofocus], input, select, textarea, button.primary", d.el) || d.el).focus(), 0);
|
|
161
|
+
return d;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
export function confirmDialog(message, { ok = "Confirm", danger = false } = {}) {
|
|
165
|
+
return new Promise((resolve) => {
|
|
166
|
+
let result = false;
|
|
167
|
+
const d = dialog({
|
|
168
|
+
title: "Are you sure?",
|
|
169
|
+
body: `<p class="muted" style="margin:0">${esc(message)}</p>`,
|
|
170
|
+
foot: `<button class="btn" data-close>Cancel</button><button class="btn primary ${danger ? "danger" : ""}" data-ok>${esc(ok)}</button>`,
|
|
171
|
+
onClose: () => resolve(result),
|
|
172
|
+
});
|
|
173
|
+
$("[data-ok]", d.el).onclick = () => {
|
|
174
|
+
result = true;
|
|
175
|
+
d.close();
|
|
176
|
+
};
|
|
177
|
+
setTimeout(() => $("[data-ok]", d.el).focus(), 0);
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
export function promptDialog(title, value = "", { label = "Name", ok = "Save" } = {}) {
|
|
182
|
+
return new Promise((resolve) => {
|
|
183
|
+
let result = null;
|
|
184
|
+
const d = dialog({
|
|
185
|
+
title,
|
|
186
|
+
body: `<form><label class="field"><span>${esc(label)}</span><input type="text" name="v" value="${esc(value)}" autofocus required /></label></form>`,
|
|
187
|
+
foot: `<button class="btn" data-close>Cancel</button><button class="btn primary" data-ok>${esc(ok)}</button>`,
|
|
188
|
+
onClose: () => resolve(result),
|
|
189
|
+
});
|
|
190
|
+
const submit = (e) => {
|
|
191
|
+
e?.preventDefault();
|
|
192
|
+
const v = $("input", d.el).value.trim();
|
|
193
|
+
if (!v) return;
|
|
194
|
+
result = v;
|
|
195
|
+
d.close();
|
|
196
|
+
};
|
|
197
|
+
$("form", d.el).onsubmit = submit;
|
|
198
|
+
$("[data-ok]", d.el).onclick = submit;
|
|
199
|
+
setTimeout(() => $("input", d.el).select(), 0);
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
// ------------------------------------------------------------------ menus
|
|
204
|
+
|
|
205
|
+
let openMenu = null;
|
|
206
|
+
|
|
207
|
+
export function closeMenu() {
|
|
208
|
+
openMenu?.remove();
|
|
209
|
+
openMenu = null;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/** items: {label, icon, danger, onClick, hint} | "sep" | {header} */
|
|
213
|
+
export function menu(anchor, items) {
|
|
214
|
+
closeMenu();
|
|
215
|
+
const m = document.createElement("div");
|
|
216
|
+
m.className = "menu";
|
|
217
|
+
m.setAttribute("role", "menu");
|
|
218
|
+
m.innerHTML = items
|
|
219
|
+
.map((it, i) => {
|
|
220
|
+
if (it === "sep") return "<hr />";
|
|
221
|
+
if (it.header) return `<div class="menu-label">${esc(it.header)}</div>`;
|
|
222
|
+
return `<button role="menuitem" data-i="${i}" class="${it.danger ? "danger" : ""}">${it.icon ? icon(it.icon) : ""}<span style="flex:1">${esc(it.label)}</span>${it.hint ? `<span class="faint">${esc(it.hint)}</span>` : ""}</button>`;
|
|
223
|
+
})
|
|
224
|
+
.join("");
|
|
225
|
+
m.addEventListener("click", (e) => {
|
|
226
|
+
const b = e.target.closest("button[data-i]");
|
|
227
|
+
if (!b) return;
|
|
228
|
+
closeMenu();
|
|
229
|
+
items[+b.dataset.i].onClick?.();
|
|
230
|
+
});
|
|
231
|
+
$("#menu-root").append(m);
|
|
232
|
+
const r = anchor.getBoundingClientRect ? anchor.getBoundingClientRect() : { left: anchor.x, right: anchor.x, top: anchor.y, bottom: anchor.y };
|
|
233
|
+
const mw = m.offsetWidth;
|
|
234
|
+
const mh = m.offsetHeight;
|
|
235
|
+
const left = Math.min(r.left, innerWidth - mw - 8);
|
|
236
|
+
const top = r.bottom + 4 + mh > innerHeight ? Math.max(8, r.top - mh - 4) : r.bottom + 4;
|
|
237
|
+
m.style.left = `${Math.max(8, left)}px`;
|
|
238
|
+
m.style.top = `${top}px`;
|
|
239
|
+
openMenu = m;
|
|
240
|
+
m.querySelector("button")?.focus();
|
|
241
|
+
return m;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
document.addEventListener("pointerdown", (e) => {
|
|
245
|
+
if (openMenu && !openMenu.contains(e.target)) closeMenu();
|
|
246
|
+
});
|
|
247
|
+
document.addEventListener("keydown", (e) => {
|
|
248
|
+
if (e.key === "Escape" && openMenu) {
|
|
249
|
+
closeMenu();
|
|
250
|
+
e.stopPropagation();
|
|
251
|
+
} else if (e.key === "Escape" && dialogs.length) {
|
|
252
|
+
e.preventDefault();
|
|
253
|
+
e.stopPropagation();
|
|
254
|
+
topDialog().close();
|
|
255
|
+
}
|
|
256
|
+
});
|
|
257
|
+
|
|
258
|
+
// ----------------------------------------------------------------- toasts
|
|
259
|
+
|
|
260
|
+
export function toast({ title, body = "", kind = "", actions = [], timeout = 5000 }) {
|
|
261
|
+
const t = document.createElement("div");
|
|
262
|
+
t.className = `toast ${kind}`;
|
|
263
|
+
t.innerHTML = `<div class="t-title">${esc(title)}</div>${body ? `<div class="t-body">${esc(body)}</div>` : ""}${
|
|
264
|
+
actions.length ? `<div class="row">${actions.map((a, i) => `<button class="btn sm ${i === 0 ? "primary" : ""}" data-i="${i}">${esc(a.label)}</button>`).join("")}</div>` : ""
|
|
265
|
+
}`;
|
|
266
|
+
const close = () => t.remove();
|
|
267
|
+
t.addEventListener("click", (e) => {
|
|
268
|
+
const b = e.target.closest("button[data-i]");
|
|
269
|
+
if (!b) return;
|
|
270
|
+
actions[+b.dataset.i].onClick?.();
|
|
271
|
+
close();
|
|
272
|
+
});
|
|
273
|
+
$("#toasts").append(t);
|
|
274
|
+
if (timeout) setTimeout(close, timeout);
|
|
275
|
+
return { el: t, close };
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
export function toastError(err) {
|
|
279
|
+
toast({ title: "Something went wrong", body: err?.message || String(err), kind: "error" });
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
// ------------------------------------------------------------------ misc
|
|
283
|
+
|
|
284
|
+
export function fmtTime(iso) {
|
|
285
|
+
if (!iso) return "";
|
|
286
|
+
const d = new Date(iso);
|
|
287
|
+
if (Number.isNaN(+d)) return iso;
|
|
288
|
+
return d.toLocaleString(undefined, { month: "short", day: "numeric", hour: "2-digit", minute: "2-digit" });
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
/** ISO string -> value for <input type="datetime-local"> in local time. */
|
|
292
|
+
export function toLocalInput(iso) {
|
|
293
|
+
if (!iso) return "";
|
|
294
|
+
const d = new Date(iso);
|
|
295
|
+
if (Number.isNaN(+d)) return "";
|
|
296
|
+
const pad = (n) => String(n).padStart(2, "0");
|
|
297
|
+
return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}T${pad(d.getHours())}:${pad(d.getMinutes())}`;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
export function fromLocalInput(value) {
|
|
301
|
+
return value ? new Date(value).toISOString() : null;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
export const store = {
|
|
305
|
+
get(key, fallback) {
|
|
306
|
+
try {
|
|
307
|
+
const v = localStorage.getItem(`shelldeck.${key}`);
|
|
308
|
+
return v === null ? fallback : JSON.parse(v);
|
|
309
|
+
} catch {
|
|
310
|
+
return fallback;
|
|
311
|
+
}
|
|
312
|
+
},
|
|
313
|
+
set(key, value) {
|
|
314
|
+
localStorage.setItem(`shelldeck.${key}`, JSON.stringify(value));
|
|
315
|
+
},
|
|
316
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
Copyright (c) 2017-2019, The xterm.js authors (https://github.com/xtermjs/xterm.js)
|
|
2
|
+
Copyright (c) 2014-2016, SourceLair Private Company (https://www.sourcelair.com)
|
|
3
|
+
Copyright (c) 2012-2013, Christopher Jeffrey (https://github.com/chjj/)
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.FitAddon=t():e.FitAddon=t()}(self,(()=>(()=>{"use strict";var e={};return(()=>{var t=e;Object.defineProperty(t,"__esModule",{value:!0}),t.FitAddon=void 0,t.FitAddon=class{activate(e){this._terminal=e}dispose(){}fit(){const e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;const t=this._terminal._core;this._terminal.rows===e.rows&&this._terminal.cols===e.cols||(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){if(!this._terminal)return;if(!this._terminal.element||!this._terminal.element.parentElement)return;const e=this._terminal._core,t=e._renderService.dimensions;if(0===t.css.cell.width||0===t.css.cell.height)return;const r=0===this._terminal.options.scrollback?0:e.viewport.scrollBarWidth,i=window.getComputedStyle(this._terminal.element.parentElement),o=parseInt(i.getPropertyValue("height")),s=Math.max(0,parseInt(i.getPropertyValue("width"))),n=window.getComputedStyle(this._terminal.element),l=o-(parseInt(n.getPropertyValue("padding-top"))+parseInt(n.getPropertyValue("padding-bottom"))),a=s-(parseInt(n.getPropertyValue("padding-right"))+parseInt(n.getPropertyValue("padding-left")))-r;return{cols:Math.max(2,Math.floor(a/t.css.cell.width)),rows:Math.max(1,Math.floor(l/t.css.cell.height))}}}})(),e})()));
|
|
2
|
+
//# sourceMappingURL=addon-fit.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.SearchAddon=t():e.SearchAddon=t()}(self,(()=>(()=>{"use strict";var e={345:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.runAndSubscribe=t.forwardEvent=t.EventEmitter=void 0,t.EventEmitter=class{constructor(){this._listeners=[],this._disposed=!1}get event(){return this._event||(this._event=e=>(this._listeners.push(e),{dispose:()=>{if(!this._disposed)for(let t=0;t<this._listeners.length;t++)if(this._listeners[t]===e)return void this._listeners.splice(t,1)}})),this._event}fire(e,t){const i=[];for(let e=0;e<this._listeners.length;e++)i.push(this._listeners[e]);for(let s=0;s<i.length;s++)i[s].call(void 0,e,t)}dispose(){this.clearListeners(),this._disposed=!0}clearListeners(){this._listeners&&(this._listeners.length=0)}},t.forwardEvent=function(e,t){return e((e=>t.fire(e)))},t.runAndSubscribe=function(e,t){return t(void 0),e((e=>t(e)))}},859:(e,t)=>{function i(e){for(const t of e)t.dispose();e.length=0}Object.defineProperty(t,"__esModule",{value:!0}),t.getDisposeArrayDisposable=t.disposeArray=t.toDisposable=t.MutableDisposable=t.Disposable=void 0,t.Disposable=class{constructor(){this._disposables=[],this._isDisposed=!1}dispose(){this._isDisposed=!0;for(const e of this._disposables)e.dispose();this._disposables.length=0}register(e){return this._disposables.push(e),e}unregister(e){const t=this._disposables.indexOf(e);-1!==t&&this._disposables.splice(t,1)}},t.MutableDisposable=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(e){this._isDisposed||e===this._value||(this._value?.dispose(),this._value=e)}clear(){this.value=void 0}dispose(){this._isDisposed=!0,this._value?.dispose(),this._value=void 0}},t.toDisposable=function(e){return{dispose:e}},t.disposeArray=i,t.getDisposeArrayDisposable=function(e){return{dispose:()=>i(e)}}}},t={};function i(s){var r=t[s];if(void 0!==r)return r.exports;var o=t[s]={exports:{}};return e[s](o,o.exports,i),o.exports}var s={};return(()=>{var e=s;Object.defineProperty(e,"__esModule",{value:!0}),e.SearchAddon=void 0;const t=i(345),r=i(859),o=" ~!@#$%^&*()+`-=[]{}|\\;:\"',./<>?";class n extends r.Disposable{constructor(e){super(),this._highlightedLines=new Set,this._highlightDecorations=[],this._selectedDecoration=this.register(new r.MutableDisposable),this._linesCacheTimeoutId=0,this._linesCacheDisposables=new r.MutableDisposable,this._onDidChangeResults=this.register(new t.EventEmitter),this.onDidChangeResults=this._onDidChangeResults.event,this._highlightLimit=e?.highlightLimit??1e3}activate(e){this._terminal=e,this.register(this._terminal.onWriteParsed((()=>this._updateMatches()))),this.register(this._terminal.onResize((()=>this._updateMatches()))),this.register((0,r.toDisposable)((()=>this.clearDecorations())))}_updateMatches(){this._highlightTimeout&&window.clearTimeout(this._highlightTimeout),this._cachedSearchTerm&&this._lastSearchOptions?.decorations&&(this._highlightTimeout=setTimeout((()=>{const e=this._cachedSearchTerm;this._cachedSearchTerm=void 0,this.findPrevious(e,{...this._lastSearchOptions,incremental:!0,noScroll:!0})}),200))}clearDecorations(e){this._selectedDecoration.clear(),(0,r.disposeArray)(this._highlightDecorations),this._highlightDecorations=[],this._highlightedLines.clear(),e||(this._cachedSearchTerm=void 0)}clearActiveDecoration(){this._selectedDecoration.clear()}findNext(e,t){if(!this._terminal)throw new Error("Cannot use addon until it has been loaded");const i=!this._lastSearchOptions||this._didOptionsChange(this._lastSearchOptions,t);this._lastSearchOptions=t,t?.decorations&&(void 0===this._cachedSearchTerm||e!==this._cachedSearchTerm||i)&&this._highlightAllMatches(e,t);const s=this._findNextAndSelect(e,t);return this._fireResults(t),this._cachedSearchTerm=e,s}_highlightAllMatches(e,t){if(!this._terminal)throw new Error("Cannot use addon until it has been loaded");if(!e||0===e.length)return void this.clearDecorations();t=t||{},this.clearDecorations(!0);const i=[];let s,r=this._find(e,0,0,t);for(;r&&(s?.row!==r.row||s?.col!==r.col)&&!(i.length>=this._highlightLimit);)s=r,i.push(s),r=this._find(e,s.col+s.term.length>=this._terminal.cols?s.row+1:s.row,s.col+s.term.length>=this._terminal.cols?0:s.col+1,t);for(const e of i){const i=this._createResultDecoration(e,t.decorations);i&&(this._highlightedLines.add(i.marker.line),this._highlightDecorations.push({decoration:i,match:e,dispose(){i.dispose()}}))}}_find(e,t,i,s){if(!this._terminal||!e||0===e.length)return this._terminal?.clearSelection(),void this.clearDecorations();if(i>this._terminal.cols)throw new Error(`Invalid col: ${i} to search in terminal of ${this._terminal.cols} cols`);let r;this._initLinesCache();const o={startRow:t,startCol:i};if(r=this._findInLine(e,o,s),!r)for(let i=t+1;i<this._terminal.buffer.active.baseY+this._terminal.rows&&(o.startRow=i,o.startCol=0,r=this._findInLine(e,o,s),!r);i++);return r}_findNextAndSelect(e,t){if(!this._terminal||!e||0===e.length)return this._terminal?.clearSelection(),this.clearDecorations(),!1;const i=this._terminal.getSelectionPosition();this._terminal.clearSelection();let s=0,r=0;i&&(this._cachedSearchTerm===e?(s=i.end.x,r=i.end.y):(s=i.start.x,r=i.start.y)),this._initLinesCache();const o={startRow:r,startCol:s};let n=this._findInLine(e,o,t);if(!n)for(let i=r+1;i<this._terminal.buffer.active.baseY+this._terminal.rows&&(o.startRow=i,o.startCol=0,n=this._findInLine(e,o,t),!n);i++);if(!n&&0!==r)for(let i=0;i<r&&(o.startRow=i,o.startCol=0,n=this._findInLine(e,o,t),!n);i++);return!n&&i&&(o.startRow=i.start.y,o.startCol=0,n=this._findInLine(e,o,t)),this._selectResult(n,t?.decorations,t?.noScroll)}findPrevious(e,t){if(!this._terminal)throw new Error("Cannot use addon until it has been loaded");const i=!this._lastSearchOptions||this._didOptionsChange(this._lastSearchOptions,t);this._lastSearchOptions=t,t?.decorations&&(void 0===this._cachedSearchTerm||e!==this._cachedSearchTerm||i)&&this._highlightAllMatches(e,t);const s=this._findPreviousAndSelect(e,t);return this._fireResults(t),this._cachedSearchTerm=e,s}_didOptionsChange(e,t){return!!t&&(e.caseSensitive!==t.caseSensitive||e.regex!==t.regex||e.wholeWord!==t.wholeWord)}_fireResults(e){if(e?.decorations){let e=-1;if(this._selectedDecoration.value){const t=this._selectedDecoration.value.match;for(let i=0;i<this._highlightDecorations.length;i++){const s=this._highlightDecorations[i].match;if(s.row===t.row&&s.col===t.col&&s.size===t.size){e=i;break}}}this._onDidChangeResults.fire({resultIndex:e,resultCount:this._highlightDecorations.length})}}_findPreviousAndSelect(e,t){if(!this._terminal)throw new Error("Cannot use addon until it has been loaded");if(!this._terminal||!e||0===e.length)return this._terminal?.clearSelection(),this.clearDecorations(),!1;const i=this._terminal.getSelectionPosition();this._terminal.clearSelection();let s=this._terminal.buffer.active.baseY+this._terminal.rows-1,r=this._terminal.cols;const o=!0;this._initLinesCache();const n={startRow:s,startCol:r};let h;if(i&&(n.startRow=s=i.start.y,n.startCol=r=i.start.x,this._cachedSearchTerm!==e&&(h=this._findInLine(e,n,t,!1),h||(n.startRow=s=i.end.y,n.startCol=r=i.end.x))),h||(h=this._findInLine(e,n,t,o)),!h){n.startCol=Math.max(n.startCol,this._terminal.cols);for(let i=s-1;i>=0&&(n.startRow=i,h=this._findInLine(e,n,t,o),!h);i--);}if(!h&&s!==this._terminal.buffer.active.baseY+this._terminal.rows-1)for(let i=this._terminal.buffer.active.baseY+this._terminal.rows-1;i>=s&&(n.startRow=i,h=this._findInLine(e,n,t,o),!h);i--);return this._selectResult(h,t?.decorations,t?.noScroll)}_initLinesCache(){const e=this._terminal;this._linesCache||(this._linesCache=new Array(e.buffer.active.length),this._linesCacheDisposables.value=(0,r.getDisposeArrayDisposable)([e.onLineFeed((()=>this._destroyLinesCache())),e.onCursorMove((()=>this._destroyLinesCache())),e.onResize((()=>this._destroyLinesCache()))])),window.clearTimeout(this._linesCacheTimeoutId),this._linesCacheTimeoutId=window.setTimeout((()=>this._destroyLinesCache()),15e3)}_destroyLinesCache(){this._linesCache=void 0,this._linesCacheDisposables.clear(),this._linesCacheTimeoutId&&(window.clearTimeout(this._linesCacheTimeoutId),this._linesCacheTimeoutId=0)}_isWholeWord(e,t,i){return(0===e||o.includes(t[e-1]))&&(e+i.length===t.length||o.includes(t[e+i.length]))}_findInLine(e,t,i={},s=!1){const r=this._terminal,o=t.startRow,n=t.startCol,h=r.buffer.active.getLine(o);if(h?.isWrapped)return s?void(t.startCol+=r.cols):(t.startRow--,t.startCol+=r.cols,this._findInLine(e,t,i));let a=this._linesCache?.[o];a||(a=this._translateBufferLineToStringWithWrap(o,!0),this._linesCache&&(this._linesCache[o]=a));const[l,c]=a,d=this._bufferColsToStringOffset(o,n),_=i.caseSensitive?e:e.toLowerCase(),u=i.caseSensitive?l:l.toLowerCase();let f=-1;if(i.regex){const t=RegExp(_,"g");let i;if(s)for(;i=t.exec(u.slice(0,d));)f=t.lastIndex-i[0].length,e=i[0],t.lastIndex-=e.length-1;else i=t.exec(u.slice(d)),i&&i[0].length>0&&(f=d+(t.lastIndex-i[0].length),e=i[0])}else s?d-_.length>=0&&(f=u.lastIndexOf(_,d-_.length)):f=u.indexOf(_,d);if(f>=0){if(i.wholeWord&&!this._isWholeWord(f,u,e))return;let t=0;for(;t<c.length-1&&f>=c[t+1];)t++;let s=t;for(;s<c.length-1&&f+e.length>=c[s+1];)s++;const n=f-c[t],h=f+e.length-c[s],a=this._stringLengthToBufferSize(o+t,n);return{term:e,col:a,row:o+t,size:this._stringLengthToBufferSize(o+s,h)-a+r.cols*(s-t)}}}_stringLengthToBufferSize(e,t){const i=this._terminal.buffer.active.getLine(e);if(!i)return 0;for(let e=0;e<t;e++){const s=i.getCell(e);if(!s)break;const r=s.getChars();r.length>1&&(t-=r.length-1);const o=i.getCell(e+1);o&&0===o.getWidth()&&t++}return t}_bufferColsToStringOffset(e,t){const i=this._terminal;let s=e,r=0,o=i.buffer.active.getLine(s);for(;t>0&&o;){for(let e=0;e<t&&e<i.cols;e++){const t=o.getCell(e);if(!t)break;t.getWidth()&&(r+=0===t.getCode()?1:t.getChars().length)}if(s++,o=i.buffer.active.getLine(s),o&&!o.isWrapped)break;t-=i.cols}return r}_translateBufferLineToStringWithWrap(e,t){const i=this._terminal,s=[],r=[0];let o=i.buffer.active.getLine(e);for(;o;){const n=i.buffer.active.getLine(e+1),h=!!n&&n.isWrapped;let a=o.translateToString(!h&&t);if(h&&n){const e=o.getCell(o.length-1);e&&0===e.getCode()&&1===e.getWidth()&&2===n.getCell(0)?.getWidth()&&(a=a.slice(0,-1))}if(s.push(a),!h)break;r.push(r[r.length-1]+a.length),e++,o=n}return[s.join(""),r]}_selectResult(e,t,i){const s=this._terminal;if(this._selectedDecoration.clear(),!e)return s.clearSelection(),!1;if(s.select(e.col,e.row,e.size),t){const i=s.registerMarker(-s.buffer.active.baseY-s.buffer.active.cursorY+e.row);if(i){const o=s.registerDecoration({marker:i,x:e.col,width:e.size,backgroundColor:t.activeMatchBackground,layer:"top",overviewRulerOptions:{color:t.activeMatchColorOverviewRuler}});if(o){const s=[];s.push(i),s.push(o.onRender((e=>this._applyStyles(e,t.activeMatchBorder,!0)))),s.push(o.onDispose((()=>(0,r.disposeArray)(s)))),this._selectedDecoration.value={decoration:o,match:e,dispose(){o.dispose()}}}}}if(!i&&(e.row>=s.buffer.active.viewportY+s.rows||e.row<s.buffer.active.viewportY)){let t=e.row-s.buffer.active.viewportY;t-=Math.floor(s.rows/2),s.scrollLines(t)}return!0}_applyStyles(e,t,i){e.classList.contains("xterm-find-result-decoration")||(e.classList.add("xterm-find-result-decoration"),t&&(e.style.outline=`1px solid ${t}`)),i&&e.classList.add("xterm-find-active-result-decoration")}_createResultDecoration(e,t){const i=this._terminal,s=i.registerMarker(-i.buffer.active.baseY-i.buffer.active.cursorY+e.row);if(!s)return;const o=i.registerDecoration({marker:s,x:e.col,width:e.size,backgroundColor:t.matchBackground,overviewRulerOptions:this._highlightedLines.has(s.line)?void 0:{color:t.matchOverviewRuler,position:"center"}});if(o){const e=[];e.push(s),e.push(o.onRender((e=>this._applyStyles(e,t.matchBorder,!1)))),e.push(o.onDispose((()=>(0,r.disposeArray)(e))))}return o}}e.SearchAddon=n})(),s})()));
|
|
2
|
+
//# sourceMappingURL=addon-search.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.SerializeAddon=t():e.SerializeAddon=t()}(this,(()=>(()=>{"use strict";var e={930:(e,t,s)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ColorContrastCache=void 0;const r=s(485);t.ColorContrastCache=class{constructor(){this._color=new r.TwoKeyMap,this._css=new r.TwoKeyMap}setCss(e,t,s){this._css.set(e,t,s)}getCss(e,t){return this._css.get(e,t)}setColor(e,t,s){this._color.set(e,t,s)}getColor(e,t){return this._color.get(e,t)}clear(){this._color.clear(),this._css.clear()}}},997:function(e,t,s){var r=this&&this.__decorate||function(e,t,s,r){var o,i=arguments.length,n=i<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,s):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,s,r);else for(var l=e.length-1;l>=0;l--)(o=e[l])&&(n=(i<3?o(n):i>3?o(t,s,n):o(t,s))||n);return i>3&&n&&Object.defineProperty(t,s,n),n},o=this&&this.__param||function(e,t){return function(s,r){t(s,r,e)}};Object.defineProperty(t,"__esModule",{value:!0}),t.ThemeService=t.DEFAULT_ANSI_COLORS=void 0;const i=s(930),n=s(160),l=s(345),a=s(859),c=s(97),h=n.css.toColor("#ffffff"),u=n.css.toColor("#000000"),_=n.css.toColor("#ffffff"),d=n.css.toColor("#000000"),C={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117};t.DEFAULT_ANSI_COLORS=Object.freeze((()=>{const e=[n.css.toColor("#2e3436"),n.css.toColor("#cc0000"),n.css.toColor("#4e9a06"),n.css.toColor("#c4a000"),n.css.toColor("#3465a4"),n.css.toColor("#75507b"),n.css.toColor("#06989a"),n.css.toColor("#d3d7cf"),n.css.toColor("#555753"),n.css.toColor("#ef2929"),n.css.toColor("#8ae234"),n.css.toColor("#fce94f"),n.css.toColor("#729fcf"),n.css.toColor("#ad7fa8"),n.css.toColor("#34e2e2"),n.css.toColor("#eeeeec")],t=[0,95,135,175,215,255];for(let s=0;s<216;s++){const r=t[s/36%6|0],o=t[s/6%6|0],i=t[s%6];e.push({css:n.channels.toCss(r,o,i),rgba:n.channels.toRgba(r,o,i)})}for(let t=0;t<24;t++){const s=8+10*t;e.push({css:n.channels.toCss(s,s,s),rgba:n.channels.toRgba(s,s,s)})}return e})());let f=t.ThemeService=class extends a.Disposable{get colors(){return this._colors}constructor(e){super(),this._optionsService=e,this._contrastCache=new i.ColorContrastCache,this._halfContrastCache=new i.ColorContrastCache,this._onChangeColors=this.register(new l.EventEmitter),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:h,background:u,cursor:_,cursorAccent:d,selectionForeground:void 0,selectionBackgroundTransparent:C,selectionBackgroundOpaque:n.color.blend(u,C),selectionInactiveBackgroundTransparent:C,selectionInactiveBackgroundOpaque:n.color.blend(u,C),ansi:t.DEFAULT_ANSI_COLORS.slice(),contrastCache:this._contrastCache,halfContrastCache:this._halfContrastCache},this._updateRestoreColors(),this._setTheme(this._optionsService.rawOptions.theme),this.register(this._optionsService.onSpecificOptionChange("minimumContrastRatio",(()=>this._contrastCache.clear()))),this.register(this._optionsService.onSpecificOptionChange("theme",(()=>this._setTheme(this._optionsService.rawOptions.theme))))}_setTheme(e={}){const s=this._colors;if(s.foreground=g(e.foreground,h),s.background=g(e.background,u),s.cursor=g(e.cursor,_),s.cursorAccent=g(e.cursorAccent,d),s.selectionBackgroundTransparent=g(e.selectionBackground,C),s.selectionBackgroundOpaque=n.color.blend(s.background,s.selectionBackgroundTransparent),s.selectionInactiveBackgroundTransparent=g(e.selectionInactiveBackground,s.selectionBackgroundTransparent),s.selectionInactiveBackgroundOpaque=n.color.blend(s.background,s.selectionInactiveBackgroundTransparent),s.selectionForeground=e.selectionForeground?g(e.selectionForeground,n.NULL_COLOR):void 0,s.selectionForeground===n.NULL_COLOR&&(s.selectionForeground=void 0),n.color.isOpaque(s.selectionBackgroundTransparent)){const e=.3;s.selectionBackgroundTransparent=n.color.opacity(s.selectionBackgroundTransparent,e)}if(n.color.isOpaque(s.selectionInactiveBackgroundTransparent)){const e=.3;s.selectionInactiveBackgroundTransparent=n.color.opacity(s.selectionInactiveBackgroundTransparent,e)}if(s.ansi=t.DEFAULT_ANSI_COLORS.slice(),s.ansi[0]=g(e.black,t.DEFAULT_ANSI_COLORS[0]),s.ansi[1]=g(e.red,t.DEFAULT_ANSI_COLORS[1]),s.ansi[2]=g(e.green,t.DEFAULT_ANSI_COLORS[2]),s.ansi[3]=g(e.yellow,t.DEFAULT_ANSI_COLORS[3]),s.ansi[4]=g(e.blue,t.DEFAULT_ANSI_COLORS[4]),s.ansi[5]=g(e.magenta,t.DEFAULT_ANSI_COLORS[5]),s.ansi[6]=g(e.cyan,t.DEFAULT_ANSI_COLORS[6]),s.ansi[7]=g(e.white,t.DEFAULT_ANSI_COLORS[7]),s.ansi[8]=g(e.brightBlack,t.DEFAULT_ANSI_COLORS[8]),s.ansi[9]=g(e.brightRed,t.DEFAULT_ANSI_COLORS[9]),s.ansi[10]=g(e.brightGreen,t.DEFAULT_ANSI_COLORS[10]),s.ansi[11]=g(e.brightYellow,t.DEFAULT_ANSI_COLORS[11]),s.ansi[12]=g(e.brightBlue,t.DEFAULT_ANSI_COLORS[12]),s.ansi[13]=g(e.brightMagenta,t.DEFAULT_ANSI_COLORS[13]),s.ansi[14]=g(e.brightCyan,t.DEFAULT_ANSI_COLORS[14]),s.ansi[15]=g(e.brightWhite,t.DEFAULT_ANSI_COLORS[15]),e.extendedAnsi){const r=Math.min(s.ansi.length-16,e.extendedAnsi.length);for(let o=0;o<r;o++)s.ansi[o+16]=g(e.extendedAnsi[o],t.DEFAULT_ANSI_COLORS[o+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(e){this._restoreColor(e),this._onChangeColors.fire(this.colors)}_restoreColor(e){if(void 0!==e)switch(e){case 256:this._colors.foreground=this._restoreColors.foreground;break;case 257:this._colors.background=this._restoreColors.background;break;case 258:this._colors.cursor=this._restoreColors.cursor;break;default:this._colors.ansi[e]=this._restoreColors.ansi[e]}else for(let e=0;e<this._restoreColors.ansi.length;++e)this._colors.ansi[e]=this._restoreColors.ansi[e]}modifyColors(e){e(this._colors),this._onChangeColors.fire(this.colors)}_updateRestoreColors(){this._restoreColors={foreground:this._colors.foreground,background:this._colors.background,cursor:this._colors.cursor,ansi:this._colors.ansi.slice()}}};function g(e,t){if(void 0!==e)try{return n.css.toColor(e)}catch{}return t}t.ThemeService=f=r([o(0,c.IOptionsService)],f)},160:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.contrastRatio=t.toPaddedHex=t.rgba=t.rgb=t.css=t.color=t.channels=t.NULL_COLOR=void 0;let s=0,r=0,o=0,i=0;var n,l,a,c,h;function u(e){const t=e.toString(16);return t.length<2?"0"+t:t}function _(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}t.NULL_COLOR={css:"#00000000",rgba:0},function(e){e.toCss=function(e,t,s,r){return void 0!==r?`#${u(e)}${u(t)}${u(s)}${u(r)}`:`#${u(e)}${u(t)}${u(s)}`},e.toRgba=function(e,t,s,r=255){return(e<<24|t<<16|s<<8|r)>>>0},e.toColor=function(t,s,r,o){return{css:e.toCss(t,s,r,o),rgba:e.toRgba(t,s,r,o)}}}(n||(t.channels=n={})),function(e){function t(e,t){return i=Math.round(255*t),[s,r,o]=h.toChannels(e.rgba),{css:n.toCss(s,r,o,i),rgba:n.toRgba(s,r,o,i)}}e.blend=function(e,t){if(i=(255&t.rgba)/255,1===i)return{css:t.css,rgba:t.rgba};const l=t.rgba>>24&255,a=t.rgba>>16&255,c=t.rgba>>8&255,h=e.rgba>>24&255,u=e.rgba>>16&255,_=e.rgba>>8&255;return s=h+Math.round((l-h)*i),r=u+Math.round((a-u)*i),o=_+Math.round((c-_)*i),{css:n.toCss(s,r,o),rgba:n.toRgba(s,r,o)}},e.isOpaque=function(e){return 255==(255&e.rgba)},e.ensureContrastRatio=function(e,t,s){const r=h.ensureContrastRatio(e.rgba,t.rgba,s);if(r)return n.toColor(r>>24&255,r>>16&255,r>>8&255)},e.opaque=function(e){const t=(255|e.rgba)>>>0;return[s,r,o]=h.toChannels(t),{css:n.toCss(s,r,o),rgba:t}},e.opacity=t,e.multiplyOpacity=function(e,s){return i=255&e.rgba,t(e,i*s/255)},e.toColorRGB=function(e){return[e.rgba>>24&255,e.rgba>>16&255,e.rgba>>8&255]}}(l||(t.color=l={})),function(e){let t,l;try{const e=document.createElement("canvas");e.width=1,e.height=1;const s=e.getContext("2d",{willReadFrequently:!0});s&&(t=s,t.globalCompositeOperation="copy",l=t.createLinearGradient(0,0,1,1))}catch{}e.toColor=function(e){if(e.match(/#[\da-f]{3,8}/i))switch(e.length){case 4:return s=parseInt(e.slice(1,2).repeat(2),16),r=parseInt(e.slice(2,3).repeat(2),16),o=parseInt(e.slice(3,4).repeat(2),16),n.toColor(s,r,o);case 5:return s=parseInt(e.slice(1,2).repeat(2),16),r=parseInt(e.slice(2,3).repeat(2),16),o=parseInt(e.slice(3,4).repeat(2),16),i=parseInt(e.slice(4,5).repeat(2),16),n.toColor(s,r,o,i);case 7:return{css:e,rgba:(parseInt(e.slice(1),16)<<8|255)>>>0};case 9:return{css:e,rgba:parseInt(e.slice(1),16)>>>0}}const a=e.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(a)return s=parseInt(a[1]),r=parseInt(a[2]),o=parseInt(a[3]),i=Math.round(255*(void 0===a[5]?1:parseFloat(a[5]))),n.toColor(s,r,o,i);if(!t||!l)throw new Error("css.toColor: Unsupported css format");if(t.fillStyle=l,t.fillStyle=e,"string"!=typeof t.fillStyle)throw new Error("css.toColor: Unsupported css format");if(t.fillRect(0,0,1,1),[s,r,o,i]=t.getImageData(0,0,1,1).data,255!==i)throw new Error("css.toColor: Unsupported css format");return{rgba:n.toRgba(s,r,o,i),css:e}}}(a||(t.css=a={})),function(e){function t(e,t,s){const r=e/255,o=t/255,i=s/255;return.2126*(r<=.03928?r/12.92:Math.pow((r+.055)/1.055,2.4))+.7152*(o<=.03928?o/12.92:Math.pow((o+.055)/1.055,2.4))+.0722*(i<=.03928?i/12.92:Math.pow((i+.055)/1.055,2.4))}e.relativeLuminance=function(e){return t(e>>16&255,e>>8&255,255&e)},e.relativeLuminance2=t}(c||(t.rgb=c={})),function(e){function t(e,t,s){const r=e>>24&255,o=e>>16&255,i=e>>8&255;let n=t>>24&255,l=t>>16&255,a=t>>8&255,h=_(c.relativeLuminance2(n,l,a),c.relativeLuminance2(r,o,i));for(;h<s&&(n>0||l>0||a>0);)n-=Math.max(0,Math.ceil(.1*n)),l-=Math.max(0,Math.ceil(.1*l)),a-=Math.max(0,Math.ceil(.1*a)),h=_(c.relativeLuminance2(n,l,a),c.relativeLuminance2(r,o,i));return(n<<24|l<<16|a<<8|255)>>>0}function l(e,t,s){const r=e>>24&255,o=e>>16&255,i=e>>8&255;let n=t>>24&255,l=t>>16&255,a=t>>8&255,h=_(c.relativeLuminance2(n,l,a),c.relativeLuminance2(r,o,i));for(;h<s&&(n<255||l<255||a<255);)n=Math.min(255,n+Math.ceil(.1*(255-n))),l=Math.min(255,l+Math.ceil(.1*(255-l))),a=Math.min(255,a+Math.ceil(.1*(255-a))),h=_(c.relativeLuminance2(n,l,a),c.relativeLuminance2(r,o,i));return(n<<24|l<<16|a<<8|255)>>>0}e.blend=function(e,t){if(i=(255&t)/255,1===i)return t;const l=t>>24&255,a=t>>16&255,c=t>>8&255,h=e>>24&255,u=e>>16&255,_=e>>8&255;return s=h+Math.round((l-h)*i),r=u+Math.round((a-u)*i),o=_+Math.round((c-_)*i),n.toRgba(s,r,o)},e.ensureContrastRatio=function(e,s,r){const o=c.relativeLuminance(e>>8),i=c.relativeLuminance(s>>8);if(_(o,i)<r){if(i<o){const i=t(e,s,r),n=_(o,c.relativeLuminance(i>>8));if(n<r){const t=l(e,s,r);return n>_(o,c.relativeLuminance(t>>8))?i:t}return i}const n=l(e,s,r),a=_(o,c.relativeLuminance(n>>8));if(a<r){const i=t(e,s,r);return a>_(o,c.relativeLuminance(i>>8))?n:i}return n}},e.reduceLuminance=t,e.increaseLuminance=l,e.toChannels=function(e){return[e>>24&255,e>>16&255,e>>8&255,255&e]}}(h||(t.rgba=h={})),t.toPaddedHex=u,t.contrastRatio=_},345:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.runAndSubscribe=t.forwardEvent=t.EventEmitter=void 0,t.EventEmitter=class{constructor(){this._listeners=[],this._disposed=!1}get event(){return this._event||(this._event=e=>(this._listeners.push(e),{dispose:()=>{if(!this._disposed)for(let t=0;t<this._listeners.length;t++)if(this._listeners[t]===e)return void this._listeners.splice(t,1)}})),this._event}fire(e,t){const s=[];for(let e=0;e<this._listeners.length;e++)s.push(this._listeners[e]);for(let r=0;r<s.length;r++)s[r].call(void 0,e,t)}dispose(){this.clearListeners(),this._disposed=!0}clearListeners(){this._listeners&&(this._listeners.length=0)}},t.forwardEvent=function(e,t){return e((e=>t.fire(e)))},t.runAndSubscribe=function(e,t){return t(void 0),e((e=>t(e)))}},859:(e,t)=>{function s(e){for(const t of e)t.dispose();e.length=0}Object.defineProperty(t,"__esModule",{value:!0}),t.getDisposeArrayDisposable=t.disposeArray=t.toDisposable=t.MutableDisposable=t.Disposable=void 0,t.Disposable=class{constructor(){this._disposables=[],this._isDisposed=!1}dispose(){this._isDisposed=!0;for(const e of this._disposables)e.dispose();this._disposables.length=0}register(e){return this._disposables.push(e),e}unregister(e){const t=this._disposables.indexOf(e);-1!==t&&this._disposables.splice(t,1)}},t.MutableDisposable=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(e){this._isDisposed||e===this._value||(this._value?.dispose(),this._value=e)}clear(){this.value=void 0}dispose(){this._isDisposed=!0,this._value?.dispose(),this._value=void 0}},t.toDisposable=function(e){return{dispose:e}},t.disposeArray=s,t.getDisposeArrayDisposable=function(e){return{dispose:()=>s(e)}}},485:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.FourKeyMap=t.TwoKeyMap=void 0;class s{constructor(){this._data={}}set(e,t,s){this._data[e]||(this._data[e]={}),this._data[e][t]=s}get(e,t){return this._data[e]?this._data[e][t]:void 0}clear(){this._data={}}}t.TwoKeyMap=s,t.FourKeyMap=class{constructor(){this._data=new s}set(e,t,r,o,i){this._data.get(e,t)||this._data.set(e,t,new s),this._data.get(e,t).set(r,o,i)}get(e,t,s,r){return this._data.get(e,t)?.get(s,r)}clear(){this._data.clear()}}},726:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.createDecorator=t.getServiceDependencies=t.serviceRegistry=void 0;const s="di$target",r="di$dependencies";t.serviceRegistry=new Map,t.getServiceDependencies=function(e){return e[r]||[]},t.createDecorator=function(e){if(t.serviceRegistry.has(e))return t.serviceRegistry.get(e);const o=function(e,t,i){if(3!==arguments.length)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");!function(e,t,o){t[s]===t?t[r].push({id:e,index:o}):(t[r]=[{id:e,index:o}],t[s]=t)}(o,e,i)};return o.toString=()=>e,t.serviceRegistry.set(e,o),o}},97:(e,t,s)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.IDecorationService=t.IUnicodeService=t.IOscLinkService=t.IOptionsService=t.ILogService=t.LogLevelEnum=t.IInstantiationService=t.ICharsetService=t.ICoreService=t.ICoreMouseService=t.IBufferService=void 0;const r=s(726);var o;t.IBufferService=(0,r.createDecorator)("BufferService"),t.ICoreMouseService=(0,r.createDecorator)("CoreMouseService"),t.ICoreService=(0,r.createDecorator)("CoreService"),t.ICharsetService=(0,r.createDecorator)("CharsetService"),t.IInstantiationService=(0,r.createDecorator)("InstantiationService"),function(e){e[e.TRACE=0]="TRACE",e[e.DEBUG=1]="DEBUG",e[e.INFO=2]="INFO",e[e.WARN=3]="WARN",e[e.ERROR=4]="ERROR",e[e.OFF=5]="OFF"}(o||(t.LogLevelEnum=o={})),t.ILogService=(0,r.createDecorator)("LogService"),t.IOptionsService=(0,r.createDecorator)("OptionsService"),t.IOscLinkService=(0,r.createDecorator)("OscLinkService"),t.IUnicodeService=(0,r.createDecorator)("UnicodeService"),t.IDecorationService=(0,r.createDecorator)("DecorationService")}},t={};function s(r){var o=t[r];if(void 0!==o)return o.exports;var i=t[r]={exports:{}};return e[r].call(i.exports,i,i.exports,s),i.exports}var r={};return(()=>{var e=r;Object.defineProperty(e,"__esModule",{value:!0}),e.HTMLSerializeHandler=e.SerializeAddon=void 0;const t=s(997);function o(e,t,s){return Math.max(t,Math.min(e,s))}class i{constructor(e){this._buffer=e}serialize(e,t){const s=this._buffer.getNullCell(),r=this._buffer.getNullCell();let o=s;const i=e.start.y,n=e.end.y,l=e.start.x,a=e.end.x;this._beforeSerialize(n-i,i,n);for(let t=i;t<=n;t++){const i=this._buffer.getLine(t);if(i){const n=t===e.start.y?l:0,c=t===e.end.y?a:i.length;for(let e=n;e<c;e++){const n=i.getCell(e,o===s?r:s);n?(this._nextCell(n,o,t,e),o=n):console.warn(`Can't get cell at row=${t}, col=${e}`)}}this._rowEnd(t,t===n)}return this._afterSerialize(),this._serializeString(t)}_nextCell(e,t,s,r){}_rowEnd(e,t){}_beforeSerialize(e,t,s){}_afterSerialize(){}_serializeString(e){return""}}function n(e,t){return e.getFgColorMode()===t.getFgColorMode()&&e.getFgColor()===t.getFgColor()}function l(e,t){return e.getBgColorMode()===t.getBgColorMode()&&e.getBgColor()===t.getBgColor()}function a(e,t){return e.isInverse()===t.isInverse()&&e.isBold()===t.isBold()&&e.isUnderline()===t.isUnderline()&&e.isOverline()===t.isOverline()&&e.isBlink()===t.isBlink()&&e.isInvisible()===t.isInvisible()&&e.isItalic()===t.isItalic()&&e.isDim()===t.isDim()&&e.isStrikethrough()===t.isStrikethrough()}class c extends i{constructor(e,t){super(e),this._terminal=t,this._rowIndex=0,this._allRows=new Array,this._allRowSeparators=new Array,this._currentRow="",this._nullCellCount=0,this._cursorStyle=this._buffer.getNullCell(),this._cursorStyleRow=0,this._cursorStyleCol=0,this._backgroundCell=this._buffer.getNullCell(),this._firstRow=0,this._lastCursorRow=0,this._lastCursorCol=0,this._lastContentCursorRow=0,this._lastContentCursorCol=0,this._thisRowLastChar=this._buffer.getNullCell(),this._thisRowLastSecondChar=this._buffer.getNullCell(),this._nextRowFirstChar=this._buffer.getNullCell()}_beforeSerialize(e,t,s){this._allRows=new Array(e),this._lastContentCursorRow=t,this._lastCursorRow=t,this._firstRow=t}_rowEnd(e,t){this._nullCellCount>0&&!l(this._cursorStyle,this._backgroundCell)&&(this._currentRow+=`[${this._nullCellCount}X`);let s="";if(!t){e-this._firstRow>=this._terminal.rows&&this._buffer.getLine(this._cursorStyleRow)?.getCell(this._cursorStyleCol,this._backgroundCell);const t=this._buffer.getLine(e),r=this._buffer.getLine(e+1);if(r.isWrapped){s="";const o=t.getCell(t.length-1,this._thisRowLastChar),i=t.getCell(t.length-2,this._thisRowLastSecondChar),n=r.getCell(0,this._nextRowFirstChar),a=n.getWidth()>1;let c=!1;(n.getChars()&&a?this._nullCellCount<=1:this._nullCellCount<=0)&&((o.getChars()||0===o.getWidth())&&l(o,n)&&(c=!0),a&&(i.getChars()||0===i.getWidth())&&l(o,n)&&l(i,n)&&(c=!0)),c||(s="-".repeat(this._nullCellCount+1),s+="[1D[1X",this._nullCellCount>0&&(s+="[A",s+=`[${t.length-this._nullCellCount}C`,s+=`[${this._nullCellCount}X`,s+=`[${t.length-this._nullCellCount}D`,s+="[B"),this._lastContentCursorRow=e+1,this._lastContentCursorCol=0,this._lastCursorRow=e+1,this._lastCursorCol=0)}else s="\r\n",this._lastCursorRow=e+1,this._lastCursorCol=0}this._allRows[this._rowIndex]=this._currentRow,this._allRowSeparators[this._rowIndex++]=s,this._currentRow="",this._nullCellCount=0}_diffStyle(e,t){const s=[],r=!n(e,t),o=!l(e,t),i=!a(e,t);if(r||o||i)if(e.isAttributeDefault())t.isAttributeDefault()||s.push(0);else{if(r){const t=e.getFgColor();e.isFgRGB()?s.push(38,2,t>>>16&255,t>>>8&255,255&t):e.isFgPalette()?t>=16?s.push(38,5,t):s.push(8&t?90+(7&t):30+(7&t)):s.push(39)}if(o){const t=e.getBgColor();e.isBgRGB()?s.push(48,2,t>>>16&255,t>>>8&255,255&t):e.isBgPalette()?t>=16?s.push(48,5,t):s.push(8&t?100+(7&t):40+(7&t)):s.push(49)}i&&(e.isInverse()!==t.isInverse()&&s.push(e.isInverse()?7:27),e.isBold()!==t.isBold()&&s.push(e.isBold()?1:22),e.isUnderline()!==t.isUnderline()&&s.push(e.isUnderline()?4:24),e.isOverline()!==t.isOverline()&&s.push(e.isOverline()?53:55),e.isBlink()!==t.isBlink()&&s.push(e.isBlink()?5:25),e.isInvisible()!==t.isInvisible()&&s.push(e.isInvisible()?8:28),e.isItalic()!==t.isItalic()&&s.push(e.isItalic()?3:23),e.isDim()!==t.isDim()&&s.push(e.isDim()?2:22),e.isStrikethrough()!==t.isStrikethrough()&&s.push(e.isStrikethrough()?9:29))}return s}_nextCell(e,t,s,r){if(0===e.getWidth())return;const o=""===e.getChars(),i=this._diffStyle(e,this._cursorStyle);if(o?!l(this._cursorStyle,e):i.length>0){this._nullCellCount>0&&(l(this._cursorStyle,this._backgroundCell)||(this._currentRow+=`[${this._nullCellCount}X`),this._currentRow+=`[${this._nullCellCount}C`,this._nullCellCount=0),this._lastContentCursorRow=this._lastCursorRow=s,this._lastContentCursorCol=this._lastCursorCol=r,this._currentRow+=`[${i.join(";")}m`;const e=this._buffer.getLine(s);void 0!==e&&(e.getCell(r,this._cursorStyle),this._cursorStyleRow=s,this._cursorStyleCol=r)}o?this._nullCellCount+=e.getWidth():(this._nullCellCount>0&&(l(this._cursorStyle,this._backgroundCell)||(this._currentRow+=`[${this._nullCellCount}X`),this._currentRow+=`[${this._nullCellCount}C`,this._nullCellCount=0),this._currentRow+=e.getChars(),this._lastContentCursorRow=this._lastCursorRow=s,this._lastContentCursorCol=this._lastCursorCol=r+e.getWidth())}_serializeString(e){let t=this._allRows.length;this._buffer.length-this._firstRow<=this._terminal.rows&&(t=this._lastContentCursorRow+1-this._firstRow,this._lastCursorCol=this._lastContentCursorCol,this._lastCursorRow=this._lastContentCursorRow);let s="";for(let e=0;e<t;e++)s+=this._allRows[e],e+1<t&&(s+=this._allRowSeparators[e]);if(!e){const e=this._buffer.baseY+this._buffer.cursorY,t=this._buffer.cursorX,o=e=>{e>0?s+=`[${e}C`:e<0&&(s+=`[${-e}D`)};(e!==this._lastCursorRow||t!==this._lastCursorCol)&&((r=e-this._lastCursorRow)>0?s+=`[${r}B`:r<0&&(s+=`[${-r}A`),o(t-this._lastCursorCol))}var r;const o=this._terminal._core._inputHandler._curAttrData,i=this._diffStyle(o,this._cursorStyle);return i.length>0&&(s+=`[${i.join(";")}m`),s}}e.SerializeAddon=class{activate(e){this._terminal=e}_serializeBufferByScrollback(e,t,s){const r=t.length,i=void 0===s?r:o(s+e.rows,0,r);return this._serializeBufferByRange(e,t,{start:r-i,end:r-1},!1)}_serializeBufferByRange(e,t,s,r){return new c(t,e).serialize({start:{x:0,y:"number"==typeof s.start?s.start:s.start.line},end:{x:e.cols,y:"number"==typeof s.end?s.end:s.end.line}},r)}_serializeBufferAsHTML(e,t){const s=e.buffer.active,r=new h(s,e,t);if(!t.onlySelection){const i=s.length,n=t.scrollback,l=void 0===n?i:o(n+e.rows,0,i);return r.serialize({start:{x:0,y:i-l},end:{x:e.cols,y:i-1}})}const i=this._terminal?.getSelectionPosition();return void 0!==i?r.serialize({start:{x:i.start.x,y:i.start.y},end:{x:i.end.x,y:i.end.y}}):""}_serializeModes(e){let t="";const s=e.modes;if(s.applicationCursorKeysMode&&(t+="[?1h"),s.applicationKeypadMode&&(t+="[?66h"),s.bracketedPasteMode&&(t+="[?2004h"),s.insertMode&&(t+="[4h"),s.originMode&&(t+="[?6h"),s.reverseWraparoundMode&&(t+="[?45h"),s.sendFocusMode&&(t+="[?1004h"),!1===s.wraparoundMode&&(t+="[?7l"),"none"!==s.mouseTrackingMode)switch(s.mouseTrackingMode){case"x10":t+="[?9h";break;case"vt200":t+="[?1000h";break;case"drag":t+="[?1002h";break;case"any":t+="[?1003h"}return t}serialize(e){if(!this._terminal)throw new Error("Cannot use addon until it has been loaded");let t=e?.range?this._serializeBufferByRange(this._terminal,this._terminal.buffer.normal,e.range,!0):this._serializeBufferByScrollback(this._terminal,this._terminal.buffer.normal,e?.scrollback);return e?.excludeAltBuffer||"alternate"!==this._terminal.buffer.active.type||(t+=`[?1049h[H${this._serializeBufferByScrollback(this._terminal,this._terminal.buffer.alternate,void 0)}`),e?.excludeModes||(t+=this._serializeModes(this._terminal)),t}serializeAsHTML(e){if(!this._terminal)throw new Error("Cannot use addon until it has been loaded");return this._serializeBufferAsHTML(this._terminal,e||{})}dispose(){}};class h extends i{constructor(e,s,r){super(e),this._terminal=s,this._options=r,this._currentRow="",this._htmlContent="",s._core._themeService?this._ansiColors=s._core._themeService.colors.ansi:this._ansiColors=t.DEFAULT_ANSI_COLORS}_padStart(e,t,s){return t>>=0,s=s??" ",e.length>t?e:((t-=e.length)>s.length&&(s+=s.repeat(t/s.length)),s.slice(0,t)+e)}_beforeSerialize(e,t,s){this._htmlContent+="<html><body>\x3c!--StartFragment--\x3e<pre>";let r="#000000",o="#ffffff";this._options.includeGlobalBackground&&(r=this._terminal.options.theme?.foreground??"#ffffff",o=this._terminal.options.theme?.background??"#000000");const i=[];i.push("color: "+r+";"),i.push("background-color: "+o+";"),i.push("font-family: "+this._terminal.options.fontFamily+";"),i.push("font-size: "+this._terminal.options.fontSize+"px;"),this._htmlContent+="<div style='"+i.join(" ")+"'>"}_afterSerialize(){this._htmlContent+="</div>",this._htmlContent+="</pre>\x3c!--EndFragment--\x3e</body></html>"}_rowEnd(e,t){this._htmlContent+="<div><span>"+this._currentRow+"</span></div>",this._currentRow=""}_getHexColor(e,t){const s=t?e.getFgColor():e.getBgColor();return(t?e.isFgRGB():e.isBgRGB())?"#"+[s>>16&255,s>>8&255,255&s].map((e=>this._padStart(e.toString(16),2,"0"))).join(""):(t?e.isFgPalette():e.isBgPalette())?this._ansiColors[s].css:void 0}_diffStyle(e,t){const s=[],r=!n(e,t),o=!l(e,t),i=!a(e,t);if(r||o||i){const t=this._getHexColor(e,!0);t&&s.push("color: "+t+";");const r=this._getHexColor(e,!1);return r&&s.push("background-color: "+r+";"),e.isInverse()&&s.push("color: #000000; background-color: #BFBFBF;"),e.isBold()&&s.push("font-weight: bold;"),e.isUnderline()&&e.isOverline()?s.push("text-decoration: overline underline;"):e.isUnderline()?s.push("text-decoration: underline;"):e.isOverline()&&s.push("text-decoration: overline;"),e.isBlink()&&s.push("text-decoration: blink;"),e.isInvisible()&&s.push("visibility: hidden;"),e.isItalic()&&s.push("font-style: italic;"),e.isDim()&&s.push("opacity: 0.5;"),e.isStrikethrough()&&s.push("text-decoration: line-through;"),s}}_nextCell(e,t,s,r){if(0===e.getWidth())return;const o=""===e.getChars(),i=this._diffStyle(e,t);i&&(this._currentRow+=0===i.length?"</span><span>":"</span><span style='"+i.join(" ")+"'>"),this._currentRow+=o?" ":e.getChars()}_serializeString(){return this._htmlContent}}e.HTMLSerializeHandler=h})(),r})()));
|
|
2
|
+
//# sourceMappingURL=addon-serialize.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.WebLinksAddon=t():e.WebLinksAddon=t()}(self,(()=>(()=>{"use strict";var e={6:(e,t)=>{function n(e){try{const t=new URL(e),n=t.password&&t.username?`${t.protocol}//${t.username}:${t.password}@${t.host}`:t.username?`${t.protocol}//${t.username}@${t.host}`:`${t.protocol}//${t.host}`;return e.toLocaleLowerCase().startsWith(n.toLocaleLowerCase())}catch(e){return!1}}Object.defineProperty(t,"__esModule",{value:!0}),t.LinkComputer=t.WebLinkProvider=void 0,t.WebLinkProvider=class{constructor(e,t,n,o={}){this._terminal=e,this._regex=t,this._handler=n,this._options=o}provideLinks(e,t){const n=o.computeLink(e,this._regex,this._terminal,this._handler);t(this._addCallbacks(n))}_addCallbacks(e){return e.map((e=>(e.leave=this._options.leave,e.hover=(t,n)=>{if(this._options.hover){const{range:o}=e;this._options.hover(t,n,o)}},e)))}};class o{static computeLink(e,t,r,i){const s=new RegExp(t.source,(t.flags||"")+"g"),[a,c]=o._getWindowedLineStrings(e-1,r),l=a.join("");let d;const p=[];for(;d=s.exec(l);){const e=d[0];if(!n(e))continue;const[t,s]=o._mapStrIdx(r,c,0,d.index),[a,l]=o._mapStrIdx(r,t,s,e.length);if(-1===t||-1===s||-1===a||-1===l)continue;const h={start:{x:s+1,y:t+1},end:{x:l,y:a+1}};p.push({range:h,text:e,activate:i})}return p}static _getWindowedLineStrings(e,t){let n,o=e,r=e,i=0,s="";const a=[];if(n=t.buffer.active.getLine(e)){const e=n.translateToString(!0);if(n.isWrapped&&" "!==e[0]){for(i=0;(n=t.buffer.active.getLine(--o))&&i<2048&&(s=n.translateToString(!0),i+=s.length,a.push(s),n.isWrapped&&-1===s.indexOf(" ")););a.reverse()}for(a.push(e),i=0;(n=t.buffer.active.getLine(++r))&&n.isWrapped&&i<2048&&(s=n.translateToString(!0),i+=s.length,a.push(s),-1===s.indexOf(" ")););}return[a,o]}static _mapStrIdx(e,t,n,o){const r=e.buffer.active,i=r.getNullCell();let s=n;for(;o;){const e=r.getLine(t);if(!e)return[-1,-1];for(let n=s;n<e.length;++n){e.getCell(n,i);const s=i.getChars();if(i.getWidth()&&(o-=s.length||1,n===e.length-1&&""===s)){const e=r.getLine(t+1);e&&e.isWrapped&&(e.getCell(0,i),2===i.getWidth()&&(o+=1))}if(o<0)return[t,n]}t++,s=0}return[t,s]}}t.LinkComputer=o}},t={};function n(o){var r=t[o];if(void 0!==r)return r.exports;var i=t[o]={exports:{}};return e[o](i,i.exports,n),i.exports}var o={};return(()=>{var e=o;Object.defineProperty(e,"__esModule",{value:!0}),e.WebLinksAddon=void 0;const t=n(6),r=/(https?|HTTPS?):[/]{2}[^\s"'!*(){}|\\\^<>`]*[^\s"':,.!?{}|\\\^~\[\]`()<>]/;function i(e,t){const n=window.open();if(n){try{n.opener=null}catch{}n.location.href=t}else console.warn("Opening link blocked as opener could not be cleared")}e.WebLinksAddon=class{constructor(e=i,t={}){this._handler=e,this._options=t}activate(e){this._terminal=e;const n=this._options,o=n.urlRegex||r;this._linkProvider=this._terminal.registerLinkProvider(new t.WebLinkProvider(this._terminal,o,this._handler,n))}dispose(){this._linkProvider?.dispose()}}})(),o})()));
|
|
2
|
+
//# sourceMappingURL=addon-web-links.js.map
|