ssh-terminal
Version:
SSH Terminal component based on xterm.js for multiple frontend frameworks
660 lines (659 loc) • 463 kB
JavaScript
class xe {
constructor() {
this.tabId = this.getOrCreateTabId();
}
getOrCreateTabId() {
const b = `tab-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
return console.log("🆕 Created new Tab ID:", b), b;
}
getTabId() {
return this.tabId;
}
}
const De = new xe();
var be = { exports: {} };
(function(Q, b) {
(function(k, A) {
Q.exports = A();
})(self, () => (() => {
var k = { 4567: function(T, s, o) {
var a = this && this.__decorate || function(r, h, u, v) {
var m, l = arguments.length, p = l < 3 ? h : v === null ? v = Object.getOwnPropertyDescriptor(h, u) : v;
if (typeof Reflect == "object" && typeof Reflect.decorate == "function")
p = Reflect.decorate(r, h, u, v);
else
for (var w = r.length - 1; w >= 0; w--)
(m = r[w]) && (p = (l < 3 ? m(p) : l > 3 ? m(h, u, p) : m(h, u)) || p);
return l > 3 && p && Object.defineProperty(h, u, p), p;
}, f = this && this.__param || function(r, h) {
return function(u, v) {
h(u, v, r);
};
};
Object.defineProperty(s, "__esModule", { value: !0 }), s.AccessibilityManager = void 0;
const n = o(9042), c = o(6114), _ = o(9924), g = o(844), d = o(5596), e = o(4725), i = o(3656);
let t = s.AccessibilityManager = class extends g.Disposable {
constructor(r, h) {
super(), this._terminal = r, this._renderService = h, this._liveRegionLineCount = 0, this._charsToConsume = [], this._charsToAnnounce = "", this._accessibilityContainer = document.createElement("div"), this._accessibilityContainer.classList.add("xterm-accessibility"), this._rowContainer = document.createElement("div"), this._rowContainer.setAttribute("role", "list"), this._rowContainer.classList.add("xterm-accessibility-tree"), this._rowElements = [];
for (let u = 0; u < this._terminal.rows; u++)
this._rowElements[u] = this._createAccessibilityTreeNode(), this._rowContainer.appendChild(this._rowElements[u]);
if (this._topBoundaryFocusListener = (u) => this._handleBoundaryFocus(u, 0), this._bottomBoundaryFocusListener = (u) => this._handleBoundaryFocus(u, 1), this._rowElements[0].addEventListener("focus", this._topBoundaryFocusListener), this._rowElements[this._rowElements.length - 1].addEventListener("focus", this._bottomBoundaryFocusListener), this._refreshRowsDimensions(), this._accessibilityContainer.appendChild(this._rowContainer), this._liveRegion = document.createElement("div"), this._liveRegion.classList.add("live-region"), this._liveRegion.setAttribute("aria-live", "assertive"), this._accessibilityContainer.appendChild(this._liveRegion), this._liveRegionDebouncer = this.register(new _.TimeBasedDebouncer(this._renderRows.bind(this))), !this._terminal.element)
throw new Error("Cannot enable accessibility before Terminal.open");
this._terminal.element.insertAdjacentElement("afterbegin", this._accessibilityContainer), this.register(this._terminal.onResize((u) => this._handleResize(u.rows))), this.register(this._terminal.onRender((u) => this._refreshRows(u.start, u.end))), this.register(this._terminal.onScroll(() => this._refreshRows())), this.register(this._terminal.onA11yChar((u) => this._handleChar(u))), this.register(this._terminal.onLineFeed(() => this._handleChar(`
`))), this.register(this._terminal.onA11yTab((u) => this._handleTab(u))), this.register(this._terminal.onKey((u) => this._handleKey(u.key))), this.register(this._terminal.onBlur(() => this._clearLiveRegion())), this.register(this._renderService.onDimensionsChange(() => this._refreshRowsDimensions())), this._screenDprMonitor = new d.ScreenDprMonitor(window), this.register(this._screenDprMonitor), this._screenDprMonitor.setListener(() => this._refreshRowsDimensions()), this.register((0, i.addDisposableDomListener)(window, "resize", () => this._refreshRowsDimensions())), this._refreshRows(), this.register((0, g.toDisposable)(() => {
this._accessibilityContainer.remove(), this._rowElements.length = 0;
}));
}
_handleTab(r) {
for (let h = 0; h < r; h++)
this._handleChar(" ");
}
_handleChar(r) {
this._liveRegionLineCount < 21 && (this._charsToConsume.length > 0 ? this._charsToConsume.shift() !== r && (this._charsToAnnounce += r) : this._charsToAnnounce += r, r === `
` && (this._liveRegionLineCount++, this._liveRegionLineCount === 21 && (this._liveRegion.textContent += n.tooMuchOutput)), c.isMac && this._liveRegion.textContent && this._liveRegion.textContent.length > 0 && !this._liveRegion.parentNode && setTimeout(() => {
this._accessibilityContainer.appendChild(this._liveRegion);
}, 0));
}
_clearLiveRegion() {
this._liveRegion.textContent = "", this._liveRegionLineCount = 0, c.isMac && this._liveRegion.remove();
}
_handleKey(r) {
this._clearLiveRegion(), /\p{Control}/u.test(r) || this._charsToConsume.push(r);
}
_refreshRows(r, h) {
this._liveRegionDebouncer.refresh(r, h, this._terminal.rows);
}
_renderRows(r, h) {
const u = this._terminal.buffer, v = u.lines.length.toString();
for (let m = r; m <= h; m++) {
const l = u.translateBufferLineToString(u.ydisp + m, !0), p = (u.ydisp + m + 1).toString(), w = this._rowElements[m];
w && (l.length === 0 ? w.innerText = " " : w.textContent = l, w.setAttribute("aria-posinset", p), w.setAttribute("aria-setsize", v));
}
this._announceCharacters();
}
_announceCharacters() {
this._charsToAnnounce.length !== 0 && (this._liveRegion.textContent += this._charsToAnnounce, this._charsToAnnounce = "");
}
_handleBoundaryFocus(r, h) {
const u = r.target, v = this._rowElements[h === 0 ? 1 : this._rowElements.length - 2];
if (u.getAttribute("aria-posinset") === (h === 0 ? "1" : `${this._terminal.buffer.lines.length}`) || r.relatedTarget !== v)
return;
let m, l;
if (h === 0 ? (m = u, l = this._rowElements.pop(), this._rowContainer.removeChild(l)) : (m = this._rowElements.shift(), l = u, this._rowContainer.removeChild(m)), m.removeEventListener("focus", this._topBoundaryFocusListener), l.removeEventListener("focus", this._bottomBoundaryFocusListener), h === 0) {
const p = this._createAccessibilityTreeNode();
this._rowElements.unshift(p), this._rowContainer.insertAdjacentElement("afterbegin", p);
} else {
const p = this._createAccessibilityTreeNode();
this._rowElements.push(p), this._rowContainer.appendChild(p);
}
this._rowElements[0].addEventListener("focus", this._topBoundaryFocusListener), this._rowElements[this._rowElements.length - 1].addEventListener("focus", this._bottomBoundaryFocusListener), this._terminal.scrollLines(h === 0 ? -1 : 1), this._rowElements[h === 0 ? 1 : this._rowElements.length - 2].focus(), r.preventDefault(), r.stopImmediatePropagation();
}
_handleResize(r) {
this._rowElements[this._rowElements.length - 1].removeEventListener("focus", this._bottomBoundaryFocusListener);
for (let h = this._rowContainer.children.length; h < this._terminal.rows; h++)
this._rowElements[h] = this._createAccessibilityTreeNode(), this._rowContainer.appendChild(this._rowElements[h]);
for (; this._rowElements.length > r; )
this._rowContainer.removeChild(this._rowElements.pop());
this._rowElements[this._rowElements.length - 1].addEventListener("focus", this._bottomBoundaryFocusListener), this._refreshRowsDimensions();
}
_createAccessibilityTreeNode() {
const r = document.createElement("div");
return r.setAttribute("role", "listitem"), r.tabIndex = -1, this._refreshRowDimensions(r), r;
}
_refreshRowsDimensions() {
if (this._renderService.dimensions.css.cell.height) {
this._accessibilityContainer.style.width = `${this._renderService.dimensions.css.canvas.width}px`, this._rowElements.length !== this._terminal.rows && this._handleResize(this._terminal.rows);
for (let r = 0; r < this._terminal.rows; r++)
this._refreshRowDimensions(this._rowElements[r]);
}
}
_refreshRowDimensions(r) {
r.style.height = `${this._renderService.dimensions.css.cell.height}px`;
}
};
s.AccessibilityManager = t = a([f(1, e.IRenderService)], t);
}, 3614: (T, s) => {
function o(c) {
return c.replace(/\r?\n/g, "\r");
}
function a(c, _) {
return _ ? "\x1B[200~" + c + "\x1B[201~" : c;
}
function f(c, _, g, d) {
c = a(c = o(c), g.decPrivateModes.bracketedPasteMode && d.rawOptions.ignoreBracketedPasteMode !== !0), g.triggerDataEvent(c, !0), _.value = "";
}
function n(c, _, g) {
const d = g.getBoundingClientRect(), e = c.clientX - d.left - 10, i = c.clientY - d.top - 10;
_.style.width = "20px", _.style.height = "20px", _.style.left = `${e}px`, _.style.top = `${i}px`, _.style.zIndex = "1000", _.focus();
}
Object.defineProperty(s, "__esModule", { value: !0 }), s.rightClickHandler = s.moveTextAreaUnderMouseCursor = s.paste = s.handlePasteEvent = s.copyHandler = s.bracketTextForPaste = s.prepareTextForTerminal = void 0, s.prepareTextForTerminal = o, s.bracketTextForPaste = a, s.copyHandler = function(c, _) {
c.clipboardData && c.clipboardData.setData("text/plain", _.selectionText), c.preventDefault();
}, s.handlePasteEvent = function(c, _, g, d) {
c.stopPropagation(), c.clipboardData && f(c.clipboardData.getData("text/plain"), _, g, d);
}, s.paste = f, s.moveTextAreaUnderMouseCursor = n, s.rightClickHandler = function(c, _, g, d, e) {
n(c, _, g), e && d.rightClickSelect(c), _.value = d.selectionText, _.select();
};
}, 7239: (T, s, o) => {
Object.defineProperty(s, "__esModule", { value: !0 }), s.ColorContrastCache = void 0;
const a = o(1505);
s.ColorContrastCache = class {
constructor() {
this._color = new a.TwoKeyMap(), this._css = new a.TwoKeyMap();
}
setCss(f, n, c) {
this._css.set(f, n, c);
}
getCss(f, n) {
return this._css.get(f, n);
}
setColor(f, n, c) {
this._color.set(f, n, c);
}
getColor(f, n) {
return this._color.get(f, n);
}
clear() {
this._color.clear(), this._css.clear();
}
};
}, 3656: (T, s) => {
Object.defineProperty(s, "__esModule", { value: !0 }), s.addDisposableDomListener = void 0, s.addDisposableDomListener = function(o, a, f, n) {
o.addEventListener(a, f, n);
let c = !1;
return { dispose: () => {
c || (c = !0, o.removeEventListener(a, f, n));
} };
};
}, 6465: function(T, s, o) {
var a = this && this.__decorate || function(e, i, t, r) {
var h, u = arguments.length, v = u < 3 ? i : r === null ? r = Object.getOwnPropertyDescriptor(i, t) : r;
if (typeof Reflect == "object" && typeof Reflect.decorate == "function")
v = Reflect.decorate(e, i, t, r);
else
for (var m = e.length - 1; m >= 0; m--)
(h = e[m]) && (v = (u < 3 ? h(v) : u > 3 ? h(i, t, v) : h(i, t)) || v);
return u > 3 && v && Object.defineProperty(i, t, v), v;
}, f = this && this.__param || function(e, i) {
return function(t, r) {
i(t, r, e);
};
};
Object.defineProperty(s, "__esModule", { value: !0 }), s.Linkifier2 = void 0;
const n = o(3656), c = o(8460), _ = o(844), g = o(2585);
let d = s.Linkifier2 = class extends _.Disposable {
get currentLink() {
return this._currentLink;
}
constructor(e) {
super(), this._bufferService = e, this._linkProviders = [], this._linkCacheDisposables = [], this._isMouseOut = !0, this._wasResized = !1, this._activeLine = -1, this._onShowLinkUnderline = this.register(new c.EventEmitter()), this.onShowLinkUnderline = this._onShowLinkUnderline.event, this._onHideLinkUnderline = this.register(new c.EventEmitter()), this.onHideLinkUnderline = this._onHideLinkUnderline.event, this.register((0, _.getDisposeArrayDisposable)(this._linkCacheDisposables)), this.register((0, _.toDisposable)(() => {
this._lastMouseEvent = void 0;
})), this.register(this._bufferService.onResize(() => {
this._clearCurrentLink(), this._wasResized = !0;
}));
}
registerLinkProvider(e) {
return this._linkProviders.push(e), { dispose: () => {
const i = this._linkProviders.indexOf(e);
i !== -1 && this._linkProviders.splice(i, 1);
} };
}
attachToDom(e, i, t) {
this._element = e, this._mouseService = i, this._renderService = t, this.register((0, n.addDisposableDomListener)(this._element, "mouseleave", () => {
this._isMouseOut = !0, this._clearCurrentLink();
})), this.register((0, n.addDisposableDomListener)(this._element, "mousemove", this._handleMouseMove.bind(this))), this.register((0, n.addDisposableDomListener)(this._element, "mousedown", this._handleMouseDown.bind(this))), this.register((0, n.addDisposableDomListener)(this._element, "mouseup", this._handleMouseUp.bind(this)));
}
_handleMouseMove(e) {
if (this._lastMouseEvent = e, !this._element || !this._mouseService)
return;
const i = this._positionFromMouseEvent(e, this._element, this._mouseService);
if (!i)
return;
this._isMouseOut = !1;
const t = e.composedPath();
for (let r = 0; r < t.length; r++) {
const h = t[r];
if (h.classList.contains("xterm"))
break;
if (h.classList.contains("xterm-hover"))
return;
}
this._lastBufferCell && i.x === this._lastBufferCell.x && i.y === this._lastBufferCell.y || (this._handleHover(i), this._lastBufferCell = i);
}
_handleHover(e) {
if (this._activeLine !== e.y || this._wasResized)
return this._clearCurrentLink(), this._askForLink(e, !1), void (this._wasResized = !1);
this._currentLink && this._linkAtPosition(this._currentLink.link, e) || (this._clearCurrentLink(), this._askForLink(e, !0));
}
_askForLink(e, i) {
var t, r;
this._activeProviderReplies && i || ((t = this._activeProviderReplies) === null || t === void 0 || t.forEach((u) => {
u?.forEach((v) => {
v.link.dispose && v.link.dispose();
});
}), this._activeProviderReplies = /* @__PURE__ */ new Map(), this._activeLine = e.y);
let h = !1;
for (const [u, v] of this._linkProviders.entries())
i ? !((r = this._activeProviderReplies) === null || r === void 0) && r.get(u) && (h = this._checkLinkProviderResult(u, e, h)) : v.provideLinks(e.y, (m) => {
var l, p;
if (this._isMouseOut)
return;
const w = m?.map((D) => ({ link: D }));
(l = this._activeProviderReplies) === null || l === void 0 || l.set(u, w), h = this._checkLinkProviderResult(u, e, h), ((p = this._activeProviderReplies) === null || p === void 0 ? void 0 : p.size) === this._linkProviders.length && this._removeIntersectingLinks(e.y, this._activeProviderReplies);
});
}
_removeIntersectingLinks(e, i) {
const t = /* @__PURE__ */ new Set();
for (let r = 0; r < i.size; r++) {
const h = i.get(r);
if (h)
for (let u = 0; u < h.length; u++) {
const v = h[u], m = v.link.range.start.y < e ? 0 : v.link.range.start.x, l = v.link.range.end.y > e ? this._bufferService.cols : v.link.range.end.x;
for (let p = m; p <= l; p++) {
if (t.has(p)) {
h.splice(u--, 1);
break;
}
t.add(p);
}
}
}
}
_checkLinkProviderResult(e, i, t) {
var r;
if (!this._activeProviderReplies)
return t;
const h = this._activeProviderReplies.get(e);
let u = !1;
for (let v = 0; v < e; v++)
this._activeProviderReplies.has(v) && !this._activeProviderReplies.get(v) || (u = !0);
if (!u && h) {
const v = h.find((m) => this._linkAtPosition(m.link, i));
v && (t = !0, this._handleNewLink(v));
}
if (this._activeProviderReplies.size === this._linkProviders.length && !t)
for (let v = 0; v < this._activeProviderReplies.size; v++) {
const m = (r = this._activeProviderReplies.get(v)) === null || r === void 0 ? void 0 : r.find((l) => this._linkAtPosition(l.link, i));
if (m) {
t = !0, this._handleNewLink(m);
break;
}
}
return t;
}
_handleMouseDown() {
this._mouseDownLink = this._currentLink;
}
_handleMouseUp(e) {
if (!this._element || !this._mouseService || !this._currentLink)
return;
const i = this._positionFromMouseEvent(e, this._element, this._mouseService);
i && this._mouseDownLink === this._currentLink && this._linkAtPosition(this._currentLink.link, i) && this._currentLink.link.activate(e, this._currentLink.link.text);
}
_clearCurrentLink(e, i) {
this._element && this._currentLink && this._lastMouseEvent && (!e || !i || this._currentLink.link.range.start.y >= e && this._currentLink.link.range.end.y <= i) && (this._linkLeave(this._element, this._currentLink.link, this._lastMouseEvent), this._currentLink = void 0, (0, _.disposeArray)(this._linkCacheDisposables));
}
_handleNewLink(e) {
if (!this._element || !this._lastMouseEvent || !this._mouseService)
return;
const i = this._positionFromMouseEvent(this._lastMouseEvent, this._element, this._mouseService);
i && this._linkAtPosition(e.link, i) && (this._currentLink = e, this._currentLink.state = { decorations: { underline: e.link.decorations === void 0 || e.link.decorations.underline, pointerCursor: e.link.decorations === void 0 || e.link.decorations.pointerCursor }, isHovered: !0 }, this._linkHover(this._element, e.link, this._lastMouseEvent), e.link.decorations = {}, Object.defineProperties(e.link.decorations, { pointerCursor: { get: () => {
var t, r;
return (r = (t = this._currentLink) === null || t === void 0 ? void 0 : t.state) === null || r === void 0 ? void 0 : r.decorations.pointerCursor;
}, set: (t) => {
var r, h;
!((r = this._currentLink) === null || r === void 0) && r.state && this._currentLink.state.decorations.pointerCursor !== t && (this._currentLink.state.decorations.pointerCursor = t, this._currentLink.state.isHovered && ((h = this._element) === null || h === void 0 || h.classList.toggle("xterm-cursor-pointer", t)));
} }, underline: { get: () => {
var t, r;
return (r = (t = this._currentLink) === null || t === void 0 ? void 0 : t.state) === null || r === void 0 ? void 0 : r.decorations.underline;
}, set: (t) => {
var r, h, u;
!((r = this._currentLink) === null || r === void 0) && r.state && ((u = (h = this._currentLink) === null || h === void 0 ? void 0 : h.state) === null || u === void 0 ? void 0 : u.decorations.underline) !== t && (this._currentLink.state.decorations.underline = t, this._currentLink.state.isHovered && this._fireUnderlineEvent(e.link, t));
} } }), this._renderService && this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange((t) => {
if (!this._currentLink)
return;
const r = t.start === 0 ? 0 : t.start + 1 + this._bufferService.buffer.ydisp, h = this._bufferService.buffer.ydisp + 1 + t.end;
if (this._currentLink.link.range.start.y >= r && this._currentLink.link.range.end.y <= h && (this._clearCurrentLink(r, h), this._lastMouseEvent && this._element)) {
const u = this._positionFromMouseEvent(this._lastMouseEvent, this._element, this._mouseService);
u && this._askForLink(u, !1);
}
})));
}
_linkHover(e, i, t) {
var r;
!((r = this._currentLink) === null || r === void 0) && r.state && (this._currentLink.state.isHovered = !0, this._currentLink.state.decorations.underline && this._fireUnderlineEvent(i, !0), this._currentLink.state.decorations.pointerCursor && e.classList.add("xterm-cursor-pointer")), i.hover && i.hover(t, i.text);
}
_fireUnderlineEvent(e, i) {
const t = e.range, r = this._bufferService.buffer.ydisp, h = this._createLinkUnderlineEvent(t.start.x - 1, t.start.y - r - 1, t.end.x, t.end.y - r - 1, void 0);
(i ? this._onShowLinkUnderline : this._onHideLinkUnderline).fire(h);
}
_linkLeave(e, i, t) {
var r;
!((r = this._currentLink) === null || r === void 0) && r.state && (this._currentLink.state.isHovered = !1, this._currentLink.state.decorations.underline && this._fireUnderlineEvent(i, !1), this._currentLink.state.decorations.pointerCursor && e.classList.remove("xterm-cursor-pointer")), i.leave && i.leave(t, i.text);
}
_linkAtPosition(e, i) {
const t = e.range.start.y * this._bufferService.cols + e.range.start.x, r = e.range.end.y * this._bufferService.cols + e.range.end.x, h = i.y * this._bufferService.cols + i.x;
return t <= h && h <= r;
}
_positionFromMouseEvent(e, i, t) {
const r = t.getCoords(e, i, this._bufferService.cols, this._bufferService.rows);
if (r)
return { x: r[0], y: r[1] + this._bufferService.buffer.ydisp };
}
_createLinkUnderlineEvent(e, i, t, r, h) {
return { x1: e, y1: i, x2: t, y2: r, cols: this._bufferService.cols, fg: h };
}
};
s.Linkifier2 = d = a([f(0, g.IBufferService)], d);
}, 9042: (T, s) => {
Object.defineProperty(s, "__esModule", { value: !0 }), s.tooMuchOutput = s.promptLabel = void 0, s.promptLabel = "Terminal input", s.tooMuchOutput = "Too much output to announce, navigate to rows manually to read";
}, 3730: function(T, s, o) {
var a = this && this.__decorate || function(d, e, i, t) {
var r, h = arguments.length, u = h < 3 ? e : t === null ? t = Object.getOwnPropertyDescriptor(e, i) : t;
if (typeof Reflect == "object" && typeof Reflect.decorate == "function")
u = Reflect.decorate(d, e, i, t);
else
for (var v = d.length - 1; v >= 0; v--)
(r = d[v]) && (u = (h < 3 ? r(u) : h > 3 ? r(e, i, u) : r(e, i)) || u);
return h > 3 && u && Object.defineProperty(e, i, u), u;
}, f = this && this.__param || function(d, e) {
return function(i, t) {
e(i, t, d);
};
};
Object.defineProperty(s, "__esModule", { value: !0 }), s.OscLinkProvider = void 0;
const n = o(511), c = o(2585);
let _ = s.OscLinkProvider = class {
constructor(d, e, i) {
this._bufferService = d, this._optionsService = e, this._oscLinkService = i;
}
provideLinks(d, e) {
var i;
const t = this._bufferService.buffer.lines.get(d - 1);
if (!t)
return void e(void 0);
const r = [], h = this._optionsService.rawOptions.linkHandler, u = new n.CellData(), v = t.getTrimmedLength();
let m = -1, l = -1, p = !1;
for (let w = 0; w < v; w++)
if (l !== -1 || t.hasContent(w)) {
if (t.loadCell(w, u), u.hasExtendedAttrs() && u.extended.urlId) {
if (l === -1) {
l = w, m = u.extended.urlId;
continue;
}
p = u.extended.urlId !== m;
} else
l !== -1 && (p = !0);
if (p || l !== -1 && w === v - 1) {
const D = (i = this._oscLinkService.getLinkData(m)) === null || i === void 0 ? void 0 : i.uri;
if (D) {
const E = { start: { x: l + 1, y: d }, end: { x: w + (p || w !== v - 1 ? 0 : 1), y: d } };
let R = !1;
if (!h?.allowNonHttpProtocols)
try {
const M = new URL(D);
["http:", "https:"].includes(M.protocol) || (R = !0);
} catch {
R = !0;
}
R || r.push({ text: D, range: E, activate: (M, O) => h ? h.activate(M, O, E) : g(0, O), hover: (M, O) => {
var U;
return (U = h?.hover) === null || U === void 0 ? void 0 : U.call(h, M, O, E);
}, leave: (M, O) => {
var U;
return (U = h?.leave) === null || U === void 0 ? void 0 : U.call(h, M, O, E);
} });
}
p = !1, u.hasExtendedAttrs() && u.extended.urlId ? (l = w, m = u.extended.urlId) : (l = -1, m = -1);
}
}
e(r);
}
};
function g(d, e) {
if (confirm(`Do you want to navigate to ${e}?
WARNING: This link could potentially be dangerous`)) {
const i = window.open();
if (i) {
try {
i.opener = null;
} catch {
}
i.location.href = e;
} else
console.warn("Opening link blocked as opener could not be cleared");
}
}
s.OscLinkProvider = _ = a([f(0, c.IBufferService), f(1, c.IOptionsService), f(2, c.IOscLinkService)], _);
}, 6193: (T, s) => {
Object.defineProperty(s, "__esModule", { value: !0 }), s.RenderDebouncer = void 0, s.RenderDebouncer = class {
constructor(o, a) {
this._parentWindow = o, this._renderCallback = a, this._refreshCallbacks = [];
}
dispose() {
this._animationFrame && (this._parentWindow.cancelAnimationFrame(this._animationFrame), this._animationFrame = void 0);
}
addRefreshCallback(o) {
return this._refreshCallbacks.push(o), this._animationFrame || (this._animationFrame = this._parentWindow.requestAnimationFrame(() => this._innerRefresh())), this._animationFrame;
}
refresh(o, a, f) {
this._rowCount = f, o = o !== void 0 ? o : 0, a = a !== void 0 ? a : this._rowCount - 1, this._rowStart = this._rowStart !== void 0 ? Math.min(this._rowStart, o) : o, this._rowEnd = this._rowEnd !== void 0 ? Math.max(this._rowEnd, a) : a, this._animationFrame || (this._animationFrame = this._parentWindow.requestAnimationFrame(() => this._innerRefresh()));
}
_innerRefresh() {
if (this._animationFrame = void 0, this._rowStart === void 0 || this._rowEnd === void 0 || this._rowCount === void 0)
return void this._runRefreshCallbacks();
const o = Math.max(this._rowStart, 0), a = Math.min(this._rowEnd, this._rowCount - 1);
this._rowStart = void 0, this._rowEnd = void 0, this._renderCallback(o, a), this._runRefreshCallbacks();
}
_runRefreshCallbacks() {
for (const o of this._refreshCallbacks)
o(0);
this._refreshCallbacks = [];
}
};
}, 5596: (T, s, o) => {
Object.defineProperty(s, "__esModule", { value: !0 }), s.ScreenDprMonitor = void 0;
const a = o(844);
class f extends a.Disposable {
constructor(c) {
super(), this._parentWindow = c, this._currentDevicePixelRatio = this._parentWindow.devicePixelRatio, this.register((0, a.toDisposable)(() => {
this.clearListener();
}));
}
setListener(c) {
this._listener && this.clearListener(), this._listener = c, this._outerListener = () => {
this._listener && (this._listener(this._parentWindow.devicePixelRatio, this._currentDevicePixelRatio), this._updateDpr());
}, this._updateDpr();
}
_updateDpr() {
var c;
this._outerListener && ((c = this._resolutionMediaMatchList) === null || c === void 0 || c.removeListener(this._outerListener), this._currentDevicePixelRatio = this._parentWindow.devicePixelRatio, this._resolutionMediaMatchList = this._parentWindow.matchMedia(`screen and (resolution: ${this._parentWindow.devicePixelRatio}dppx)`), this._resolutionMediaMatchList.addListener(this._outerListener));
}
clearListener() {
this._resolutionMediaMatchList && this._listener && this._outerListener && (this._resolutionMediaMatchList.removeListener(this._outerListener), this._resolutionMediaMatchList = void 0, this._listener = void 0, this._outerListener = void 0);
}
}
s.ScreenDprMonitor = f;
}, 3236: (T, s, o) => {
Object.defineProperty(s, "__esModule", { value: !0 }), s.Terminal = void 0;
const a = o(3614), f = o(3656), n = o(6465), c = o(9042), _ = o(3730), g = o(1680), d = o(3107), e = o(5744), i = o(2950), t = o(1296), r = o(428), h = o(4269), u = o(5114), v = o(8934), m = o(3230), l = o(9312), p = o(4725), w = o(6731), D = o(8055), E = o(8969), R = o(8460), M = o(844), O = o(6114), U = o(8437), F = o(2584), S = o(7399), x = o(5941), y = o(9074), L = o(2585), W = o(5435), $ = o(4567), K = typeof window < "u" ? window.document : null;
class j extends E.CoreTerminal {
get onFocus() {
return this._onFocus.event;
}
get onBlur() {
return this._onBlur.event;
}
get onA11yChar() {
return this._onA11yCharEmitter.event;
}
get onA11yTab() {
return this._onA11yTabEmitter.event;
}
get onWillOpen() {
return this._onWillOpen.event;
}
constructor(C = {}) {
super(C), this.browser = O, this._keyDownHandled = !1, this._keyDownSeen = !1, this._keyPressHandled = !1, this._unprocessedDeadKey = !1, this._accessibilityManager = this.register(new M.MutableDisposable()), this._onCursorMove = this.register(new R.EventEmitter()), this.onCursorMove = this._onCursorMove.event, this._onKey = this.register(new R.EventEmitter()), this.onKey = this._onKey.event, this._onRender = this.register(new R.EventEmitter()), this.onRender = this._onRender.event, this._onSelectionChange = this.register(new R.EventEmitter()), this.onSelectionChange = this._onSelectionChange.event, this._onTitleChange = this.register(new R.EventEmitter()), this.onTitleChange = this._onTitleChange.event, this._onBell = this.register(new R.EventEmitter()), this.onBell = this._onBell.event, this._onFocus = this.register(new R.EventEmitter()), this._onBlur = this.register(new R.EventEmitter()), this._onA11yCharEmitter = this.register(new R.EventEmitter()), this._onA11yTabEmitter = this.register(new R.EventEmitter()), this._onWillOpen = this.register(new R.EventEmitter()), this._setup(), this.linkifier2 = this.register(this._instantiationService.createInstance(n.Linkifier2)), this.linkifier2.registerLinkProvider(this._instantiationService.createInstance(_.OscLinkProvider)), this._decorationService = this._instantiationService.createInstance(y.DecorationService), this._instantiationService.setService(L.IDecorationService, this._decorationService), this.register(this._inputHandler.onRequestBell(() => this._onBell.fire())), this.register(this._inputHandler.onRequestRefreshRows((B, H) => this.refresh(B, H))), this.register(this._inputHandler.onRequestSendFocus(() => this._reportFocus())), this.register(this._inputHandler.onRequestReset(() => this.reset())), this.register(this._inputHandler.onRequestWindowsOptionsReport((B) => this._reportWindowsOptions(B))), this.register(this._inputHandler.onColor((B) => this._handleColorEvent(B))), this.register((0, R.forwardEvent)(this._inputHandler.onCursorMove, this._onCursorMove)), this.register((0, R.forwardEvent)(this._inputHandler.onTitleChange, this._onTitleChange)), this.register((0, R.forwardEvent)(this._inputHandler.onA11yChar, this._onA11yCharEmitter)), this.register((0, R.forwardEvent)(this._inputHandler.onA11yTab, this._onA11yTabEmitter)), this.register(this._bufferService.onResize((B) => this._afterResize(B.cols, B.rows))), this.register((0, M.toDisposable)(() => {
var B, H;
this._customKeyEventHandler = void 0, (H = (B = this.element) === null || B === void 0 ? void 0 : B.parentNode) === null || H === void 0 || H.removeChild(this.element);
}));
}
_handleColorEvent(C) {
if (this._themeService)
for (const B of C) {
let H, I = "";
switch (B.index) {
case 256:
H = "foreground", I = "10";
break;
case 257:
H = "background", I = "11";
break;
case 258:
H = "cursor", I = "12";
break;
default:
H = "ansi", I = "4;" + B.index;
}
switch (B.type) {
case 0:
const q = D.color.toColorRGB(H === "ansi" ? this._themeService.colors.ansi[B.index] : this._themeService.colors[H]);
this.coreService.triggerDataEvent(`${F.C0.ESC}]${I};${(0, x.toRgbString)(q)}${F.C1_ESCAPED.ST}`);
break;
case 1:
if (H === "ansi")
this._themeService.modifyColors((z) => z.ansi[B.index] = D.rgba.toColor(...B.color));
else {
const z = H;
this._themeService.modifyColors((G) => G[z] = D.rgba.toColor(...B.color));
}
break;
case 2:
this._themeService.restoreColor(B.index);
}
}
}
_setup() {
super._setup(), this._customKeyEventHandler = void 0;
}
get buffer() {
return this.buffers.active;
}
focus() {
this.textarea && this.textarea.focus({ preventScroll: !0 });
}
_handleScreenReaderModeOptionChange(C) {
C ? !this._accessibilityManager.value && this._renderService && (this._accessibilityManager.value = this._instantiationService.createInstance($.AccessibilityManager, this)) : this._accessibilityManager.clear();
}
_handleTextAreaFocus(C) {
this.coreService.decPrivateModes.sendFocus && this.coreService.triggerDataEvent(F.C0.ESC + "[I"), this.updateCursorStyle(C), this.element.classList.add("focus"), this._showCursor(), this._onFocus.fire();
}
blur() {
var C;
return (C = this.textarea) === null || C === void 0 ? void 0 : C.blur();
}
_handleTextAreaBlur() {
this.textarea.value = "", this.refresh(this.buffer.y, this.buffer.y), this.coreService.decPrivateModes.sendFocus && this.coreService.triggerDataEvent(F.C0.ESC + "[O"), this.element.classList.remove("focus"), this._onBlur.fire();
}
_syncTextArea() {
if (!this.textarea || !this.buffer.isCursorInViewport || this._compositionHelper.isComposing || !this._renderService)
return;
const C = this.buffer.ybase + this.buffer.y, B = this.buffer.lines.get(C);
if (!B)
return;
const H = Math.min(this.buffer.x, this.cols - 1), I = this._renderService.dimensions.css.cell.height, q = B.getWidth(H), z = this._renderService.dimensions.css.cell.width * q, G = this.buffer.y * this._renderService.dimensions.css.cell.height, J = H * this._renderService.dimensions.css.cell.width;
this.textarea.style.left = J + "px", this.textarea.style.top = G + "px", this.textarea.style.width = z + "px", this.textarea.style.height = I + "px", this.textarea.style.lineHeight = I + "px", this.textarea.style.zIndex = "-5";
}
_initGlobal() {
this._bindKeys(), this.register((0, f.addDisposableDomListener)(this.element, "copy", (B) => {
this.hasSelection() && (0, a.copyHandler)(B, this._selectionService);
}));
const C = (B) => (0, a.handlePasteEvent)(B, this.textarea, this.coreService, this.optionsService);
this.register((0, f.addDisposableDomListener)(this.textarea, "paste", C)), this.register((0, f.addDisposableDomListener)(this.element, "paste", C)), O.isFirefox ? this.register((0, f.addDisposableDomListener)(this.element, "mousedown", (B) => {
B.button === 2 && (0, a.rightClickHandler)(B, this.textarea, this.screenElement, this._selectionService, this.options.rightClickSelectsWord);
})) : this.register((0, f.addDisposableDomListener)(this.element, "contextmenu", (B) => {
(0, a.rightClickHandler)(B, this.textarea, this.screenElement, this._selectionService, this.options.rightClickSelectsWord);
})), O.isLinux && this.register((0, f.addDisposableDomListener)(this.element, "auxclick", (B) => {
B.button === 1 && (0, a.moveTextAreaUnderMouseCursor)(B, this.textarea, this.screenElement);
}));
}
_bindKeys() {
this.register((0, f.addDisposableDomListener)(this.textarea, "keyup", (C) => this._keyUp(C), !0)), this.register((0, f.addDisposableDomListener)(this.textarea, "keydown", (C) => this._keyDown(C), !0)), this.register((0, f.addDisposableDomListener)(this.textarea, "keypress", (C) => this._keyPress(C), !0)), this.register((0, f.addDisposableDomListener)(this.textarea, "compositionstart", () => this._compositionHelper.compositionstart())), this.register((0, f.addDisposableDomListener)(this.textarea, "compositionupdate", (C) => this._compositionHelper.compositionupdate(C))), this.register((0, f.addDisposableDomListener)(this.textarea, "compositionend", () => this._compositionHelper.compositionend())), this.register((0, f.addDisposableDomListener)(this.textarea, "input", (C) => this._inputEvent(C), !0)), this.register(this.onRender(() => this._compositionHelper.updateCompositionElements()));
}
open(C) {
var B;
if (!C)
throw new Error("Terminal requires a parent element.");
C.isConnected || this._logService.debug("Terminal.open was called on an element that was not attached to the DOM"), this._document = C.ownerDocument, this.element = this._document.createElement("div"), this.element.dir = "ltr", this.element.classList.add("terminal"), this.element.classList.add("xterm"), C.appendChild(this.element);
const H = K.createDocumentFragment();
this._viewportElement = K.createElement("div"), this._viewportElement.classList.add("xterm-viewport"), H.appendChild(this._viewportElement), this._viewportScrollArea = K.createElement("div"), this._viewportScrollArea.classList.add("xterm-scroll-area"), this._viewportElement.appendChild(this._viewportScrollArea), this.screenElement = K.createElement("div"), this.screenElement.classList.add("xterm-screen"), this._helperContainer = K.createElement("div"), this._helperContainer.classList.add("xterm-helpers"), this.screenElement.appendChild(this._helperContainer), H.appendChild(this.screenElement), this.textarea = K.createElement("textarea"), this.textarea.classList.add("xterm-helper-textarea"), this.textarea.setAttribute("aria-label", c.promptLabel), O.isChromeOS || this.textarea.setAttribute("aria-multiline", "false"), this.textarea.setAttribute("autocorrect", "off"), this.textarea.setAttribute("autocapitalize", "off"), this.textarea.setAttribute("spellcheck", "false"), this.textarea.tabIndex = 0, this._coreBrowserService = this._instantiationService.createInstance(u.CoreBrowserService, this.textarea, (B = this._document.defaultView) !== null && B !== void 0 ? B : window), this._instantiationService.setService(p.ICoreBrowserService, this._coreBrowserService), this.register((0, f.addDisposableDomListener)(this.textarea, "focus", (I) => this._handleTextAreaFocus(I))), this.register((0, f.addDisposableDomListener)(this.textarea, "blur", () => this._handleTextAreaBlur())), this._helperContainer.appendChild(this.textarea), this._charSizeService = this._instantiationService.createInstance(r.CharSizeService, this._document, this._helperContainer), this._instantiationService.setService(p.ICharSizeService, this._charSizeService), this._themeService = this._instantiationService.createInstance(w.ThemeService), this._instantiationService.setService(p.IThemeService, this._themeService), this._characterJoinerService = this._instantiationService.createInstance(h.CharacterJoinerService), this._instantiationService.setService(p.ICharacterJoinerService, this._characterJoinerService), this._renderService = this.register(this._instantiationService.createInstance(m.RenderService, this.rows, this.screenElement)), this._instantiationService.setService(p.IRenderService, this._renderService), this.register(this._renderService.onRenderedViewportChange((I) => this._onRender.fire(I))), this.onResize((I) => this._renderService.resize(I.cols, I.rows)), this._compositionView = K.createElement("div"), this._compositionView.classList.add("composition-view"), this._compositionHelper = this._instantiationService.createInstance(i.CompositionHelper, this.textarea, this._compositionView), this._helperContainer.appendChild(this._compositionView), this.element.appendChild(H);
try {
this._onWillOpen.fire(this.element);
} catch {
}
this._renderService.hasRenderer() || this._renderService.setRenderer(this._createRenderer()), this._mouseService = this._instantiationService.createInstance(v.MouseService), this._instantiationService.setService(p.IMouseService, this._mouseService), this.viewport = this._instantiationService.createInstance(g.Viewport, this._viewportElement, this._viewportScrollArea), this.viewport.onRequestScrollLines((I) => this.scrollLines(I.amount, I.suppressScrollEvent, 1)), this.register(this._inputHandler.onRequestSyncScrollBar(() => this.viewport.syncScrollArea())), this.register(this.viewport), this.register(this.onCursorMove(() => {
this._renderService.handleCursorMove(), this._syncTextArea();
})), this.register(this.onResize(() => this._renderService.handleResize(this.cols, this.rows))), this.register(this.onBlur(() => this._renderService.handleBlur())), this.register(this.onFocus(() => this._renderService.handleFocus())), this.register(this._renderService.onDimensionsChange(() => this.viewport.syncScrollArea())), this._selectionService = this.register(this._instantiationService.createInstance(l.SelectionService, this.element, this.screenElement, this.linkifier2)), this._instantiationService.setService(p.ISelectionService, this._selectionService), this.register(this._selectionService.onRequestScrollLines((I) => this.scrollLines(I.amount, I.suppressScrollEvent))), this.register(this._selectionService.onSelectionChange(() => this._onSelectionChange.fire())), this.register(this._selectionService.onRequestRedraw((I) => this._renderService.handleSelectionChanged(I.start, I.end, I.columnSelectMode))), this.register(this._selectionService.onLinuxMouseSelection((I) => {
this.textarea.value = I, this.textarea.focus(), this.textarea.select();
})), this.register(this._onScroll.event((I) => {
this.viewport.syncScrollArea(), this._selectionService.refresh();
})), this.register((0, f.addDisposableDomListener)(this._viewportElement, "scroll", () => this._selectionService.refresh())), this.linkifier2.attachToDom(this.screenElement, this._mouseService, this._renderService), this.register(this._instantiationService.createInstance(d.BufferDecorationRenderer, this.screenElement)), this.register((0, f.addDisposableDomListener)(this.element, "mousedown", (I) => this._selectionService.handleMouseDown(I))), this.coreMouseService.areMouseEventsActive ? (this._selectionService.disable(), this.element.classList.add("enable-mouse-events")) : this._selectionService.enable(), this.options.screenReaderMode && (this._accessibilityManager.value = this._instantiationService.createInstance($.AccessibilityManager, this)), this.register(this.optionsService.onSpecificOptionChange("screenReaderMode", (I) => this._handleScreenReaderModeOptionChange(I))), this.options.overviewRulerWidth && (this._overviewRulerRenderer = this.register(this._instantiationService.createInstance(e.OverviewRulerRenderer, this._viewportElement, this.screenElement))), this.optionsService.onSpecificOptionChange("overviewRulerWidth", (I) => {
!this._overviewRulerRenderer && I && this._viewportElement && this.screenElement && (this._overviewRulerRenderer = this.register(this._instantiationService.createInstance(e.OverviewRulerRenderer, this._viewportElement, this.screenElement)));
}), this._charSizeService.measure(), this.refresh(0, this.rows - 1), this._initGlobal(), this.bindMouse();
}
_createRenderer() {
return this._instantiationService.createInstance(t.DomRenderer, this.element, this.screenElement, this._viewportElement, this.linkifier2);
}
bindMouse() {
const C = this, B = this.element;
function H(z) {
const G = C._mouseService.getMouseReportCoords(z, C.screenElement);
if (!G)
return !1;
let J, ee;
switch (z.overrideType || z.type) {
case "mousemove":
ee = 32, z.buttons === void 0 ? (J = 3, z.button !== void 0 && (J = z.button < 3 ? z.button : 3)) : J = 1 & z.buttons ? 0 : 4 & z.buttons ? 1 : 2 & z.buttons ? 2 : 3;
break;
case "mouseup":
ee = 0, J = z.button < 3 ? z.button : 3;
break;
case "mousedown":
ee = 1, J = z.button < 3 ? z.button : 3;
break;
case "wheel":
if (C.viewport.getLinesScrolled(z) === 0)
return !1;
ee = z.deltaY < 0 ? 0 : 1, J = 4;
break;
default:
return !1;
}
return !(ee === void 0 || J === void 0 || J > 4) && C.coreMouseService.triggerMouseEvent({ col: G.col, row: G.row, x: G.x, y: G.y, button: J, action: ee, ctrl: z.ctrlKey, alt: z.altKey, shift: z.shiftKey });
}
const I = { mouseup: null, wheel: null, mousedrag: null, mousemove: null }, q = { mouseup: (z) => (H(z), z.buttons || (this._document.removeEventListener("mouseup", I.mouseup), I.mousedrag && this._document.removeEventListener("mousemove", I.mousedrag)), this.cancel(z)), wheel: (z) => (H(z), this.cancel(z, !0)), mousedrag: (z) => {
z.buttons && H(z);
}, mousemove: (z) => {
z.buttons || H(z);
} };
this.register(this.coreMouseService.onProtocolChange((z) => {
z ? (this.optionsService.rawOptions.logLevel === "debug" && this._logService.debug("Binding to mouse events:", this.coreMouseService.explainEvents(z)), this.element.classList.add("enable-mouse-events"), this._selectionService.disable()) : (this._logService.debug("Unbinding from mouse events."), this.element.classList.remove("enable-mouse-events"), this._selectionService.enable()), 8 & z ? I.mousemove || (B.addEventListener("mousemove", q.mousemove), I.mousemove = q.mousemove) : (B.removeEventListener("mousemove", I.mousemove), I.mousemove = null), 16 & z ? I.wheel || (B.addEventListener("wheel", q.wheel, { passive: !1 }), I.wheel = q.wheel) : (B.removeEventListener("wheel", I.wheel), I.wheel = null), 2 & z ? I.mouseup || (B.addEventListener("mouseup", q.mouseup), I.mouseup = q.mouseup) : (this._document.removeEventListener("mouseup", I.mouseup), B.removeEventListener("mouseup", I.mouseup), I.mouseup = null), 4 & z ? I.mousedrag || (I.mousedrag = q.mousedrag) : (this._document.removeEventListener("mousemove", I.mousedrag), I.mousedrag = null);
})), this.coreMouseService.activeProtocol = this.coreMouseService.activeProtocol, this.register((0, f.addDisposableDomListener)(B, "mousedown", (z) => {
if (z.preventDefault(), this.focus(), this.coreMouseService.areMouseEventsActive && !this._selectionService.shouldForceSelection(z))
return H(z), I.mouseup && this._document.addEventListener("mouseup", I.mouseup), I.mousedrag && this._document.addEventListener("mousemove", I.mousedrag), this.cancel(z);
})), this.register((0, f.addDisposableDomListener)(B, "wheel", (z) => {
if (!I.wheel) {
if (!this.buffer.hasScrollback) {
const G = this.viewport.getLinesScrolled(z);
if (G === 0)
return;
const J = F.C0.ESC + (this.coreService.decPrivateModes.applicationCursorKeys ? "O" : "[") + (z.deltaY < 0 ? "A" : "B");
let ee = "";
for (let oe = 0; oe < Math.abs(G); oe++)
ee += J;
return this.coreService.triggerDataEvent(ee, !0), this.cancel(z, !0);
}
return this.viewport.handleWheel(z) ? this.cancel(z) : void 0;
}
}, { passive: !1 })), this.register((0, f.addDisposableDomListener)(B, "touchstart", (z) => {
if (!this.coreMou