ssh-terminal
Version:
SSH Terminal component based on xterm.js for multiple frontend frameworks
673 lines (672 loc) • 447 kB
JavaScript
var Re = Object.defineProperty;
var Se = Object.getOwnPropertySymbols;
var Ae = Object.prototype.hasOwnProperty, Te = Object.prototype.propertyIsEnumerable;
var Ce = (Y, M, A) => M in Y ? Re(Y, M, { enumerable: !0, configurable: !0, writable: !0, value: A }) : Y[M] = A, he = (Y, M) => {
for (var A in M || (M = {}))
Ae.call(M, A) && Ce(Y, A, M[A]);
if (Se)
for (var A of Se(M))
Te.call(M, A) && Ce(Y, A, M[A]);
return Y;
};
var Z = (Y, M, A) => new Promise((F, N) => {
var K = (o) => {
try {
s(A.next(o));
} catch (a) {
N(a);
}
}, R = (o) => {
try {
s(A.throw(o));
} catch (a) {
N(a);
}
}, s = (o) => o.done ? F(o.value) : Promise.resolve(o.value).then(K, R);
s((A = A.apply(Y, M)).next());
});
import oe from "./validation-d8717515.mjs";
import ye from "./logger-24c8a38f.mjs";
class Be {
constructor() {
this.tabId = this.getOrCreateTabId();
}
getOrCreateTabId() {
const M = `tab-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
return console.log("🆕 Created new Tab ID:", M), M;
}
getTabId() {
return this.tabId;
}
}
const Me = new Be(), Pe = Me;
var we = { exports: {} };
(function(Y, M) {
(function(A, F) {
Y.exports = F();
})(self, () => (() => {
var A = { 4567: function(R, s, o) {
var a = this && this.__decorate || function(r, h, _, g) {
var m, l = arguments.length, p = l < 3 ? h : g === null ? g = Object.getOwnPropertyDescriptor(h, _) : g;
if (typeof Reflect == "object" && typeof Reflect.decorate == "function")
p = Reflect.decorate(r, h, _, g);
else
for (var b = r.length - 1; b >= 0; b--)
(m = r[b]) && (p = (l < 3 ? m(p) : l > 3 ? m(h, _, p) : m(h, _)) || p);
return l > 3 && p && Object.defineProperty(h, _, p), p;
}, f = this && this.__param || function(r, h) {
return function(_, g) {
h(_, g, r);
};
};
Object.defineProperty(s, "__esModule", { value: !0 }), s.AccessibilityManager = void 0;
const n = o(9042), c = o(6114), u = o(9924), v = o(844), d = o(5596), e = o(4725), i = o(3656);
let t = s.AccessibilityManager = class extends v.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 _ = 0; _ < this._terminal.rows; _++)
this._rowElements[_] = this._createAccessibilityTreeNode(), this._rowContainer.appendChild(this._rowElements[_]);
if (this._topBoundaryFocusListener = (_) => this._handleBoundaryFocus(_, 0), this._bottomBoundaryFocusListener = (_) => this._handleBoundaryFocus(_, 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 u.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((_) => this._handleResize(_.rows))), this.register(this._terminal.onRender((_) => this._refreshRows(_.start, _.end))), this.register(this._terminal.onScroll(() => this._refreshRows())), this.register(this._terminal.onA11yChar((_) => this._handleChar(_))), this.register(this._terminal.onLineFeed(() => this._handleChar(`
`))), this.register(this._terminal.onA11yTab((_) => this._handleTab(_))), this.register(this._terminal.onKey((_) => this._handleKey(_.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, v.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(), new RegExp("\\p{Control}", "u").test(r) || this._charsToConsume.push(r);
}
_refreshRows(r, h) {
this._liveRegionDebouncer.refresh(r, h, this._terminal.rows);
}
_renderRows(r, h) {
const _ = this._terminal.buffer, g = _.lines.length.toString();
for (let m = r; m <= h; m++) {
const l = _.translateBufferLineToString(_.ydisp + m, !0), p = (_.ydisp + m + 1).toString(), b = this._rowElements[m];
b && (l.length === 0 ? b.innerText = " " : b.textContent = l, b.setAttribute("aria-posinset", p), b.setAttribute("aria-setsize", g));
}
this._announceCharacters();
}
_announceCharacters() {
this._charsToAnnounce.length !== 0 && (this._liveRegion.textContent += this._charsToAnnounce, this._charsToAnnounce = "");
}
_handleBoundaryFocus(r, h) {
const _ = r.target, g = this._rowElements[h === 0 ? 1 : this._rowElements.length - 2];
if (_.getAttribute("aria-posinset") === (h === 0 ? "1" : `${this._terminal.buffer.lines.length}`) || r.relatedTarget !== g)
return;
let m, l;
if (h === 0 ? (m = _, l = this._rowElements.pop(), this._rowContainer.removeChild(l)) : (m = this._rowElements.shift(), l = _, 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: (R, s) => {
function o(c) {
return c.replace(/\r?\n/g, "\r");
}
function a(c, u) {
return u ? "\x1B[200~" + c + "\x1B[201~" : c;
}
function f(c, u, v, d) {
c = a(c = o(c), v.decPrivateModes.bracketedPasteMode && d.rawOptions.ignoreBracketedPasteMode !== !0), v.triggerDataEvent(c, !0), u.value = "";
}
function n(c, u, v) {
const d = v.getBoundingClientRect(), e = c.clientX - d.left - 10, i = c.clientY - d.top - 10;
u.style.width = "20px", u.style.height = "20px", u.style.left = `${e}px`, u.style.top = `${i}px`, u.style.zIndex = "1000", u.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, u) {
c.clipboardData && c.clipboardData.setData("text/plain", u.selectionText), c.preventDefault();
}, s.handlePasteEvent = function(c, u, v, d) {
c.stopPropagation(), c.clipboardData && f(c.clipboardData.getData("text/plain"), u, v, d);
}, s.paste = f, s.moveTextAreaUnderMouseCursor = n, s.rightClickHandler = function(c, u, v, d, e) {
n(c, u, v), e && d.rightClickSelect(c), u.value = d.selectionText, u.select();
};
}, 7239: (R, 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: (R, 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(R, s, o) {
var a = this && this.__decorate || function(e, i, t, r) {
var h, _ = arguments.length, g = _ < 3 ? i : r === null ? r = Object.getOwnPropertyDescriptor(i, t) : r;
if (typeof Reflect == "object" && typeof Reflect.decorate == "function")
g = Reflect.decorate(e, i, t, r);
else
for (var m = e.length - 1; m >= 0; m--)
(h = e[m]) && (g = (_ < 3 ? h(g) : _ > 3 ? h(i, t, g) : h(i, t)) || g);
return _ > 3 && g && Object.defineProperty(i, t, g), g;
}, 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), u = o(844), v = o(2585);
let d = s.Linkifier2 = class extends u.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, u.getDisposeArrayDisposable)(this._linkCacheDisposables)), this.register((0, u.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((_) => {
_ == null || _.forEach((g) => {
g.link.dispose && g.link.dispose();
});
}), this._activeProviderReplies = /* @__PURE__ */ new Map(), this._activeLine = e.y);
let h = !1;
for (const [_, g] of this._linkProviders.entries())
i ? !((r = this._activeProviderReplies) === null || r === void 0) && r.get(_) && (h = this._checkLinkProviderResult(_, e, h)) : g.provideLinks(e.y, (m) => {
var l, p;
if (this._isMouseOut)
return;
const b = m == null ? void 0 : m.map((E) => ({ link: E }));
(l = this._activeProviderReplies) === null || l === void 0 || l.set(_, b), h = this._checkLinkProviderResult(_, 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 _ = 0; _ < h.length; _++) {
const g = h[_], m = g.link.range.start.y < e ? 0 : g.link.range.start.x, l = g.link.range.end.y > e ? this._bufferService.cols : g.link.range.end.x;
for (let p = m; p <= l; p++) {
if (t.has(p)) {
h.splice(_--, 1);
break;
}
t.add(p);
}
}
}
}
_checkLinkProviderResult(e, i, t) {
var r;
if (!this._activeProviderReplies)
return t;
const h = this._activeProviderReplies.get(e);
let _ = !1;
for (let g = 0; g < e; g++)
this._activeProviderReplies.has(g) && !this._activeProviderReplies.get(g) || (_ = !0);
if (!_ && h) {
const g = h.find((m) => this._linkAtPosition(m.link, i));
g && (t = !0, this._handleNewLink(g));
}
if (this._activeProviderReplies.size === this._linkProviders.length && !t)
for (let g = 0; g < this._activeProviderReplies.size; g++) {
const m = (r = this._activeProviderReplies.get(g)) === 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, u.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, _;
!((r = this._currentLink) === null || r === void 0) && r.state && ((_ = (h = this._currentLink) === null || h === void 0 ? void 0 : h.state) === null || _ === void 0 ? void 0 : _.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 _ = this._positionFromMouseEvent(this._lastMouseEvent, this._element, this._mouseService);
_ && this._askForLink(_, !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, v.IBufferService)], d);
}, 9042: (R, 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(R, s, o) {
var a = this && this.__decorate || function(d, e, i, t) {
var r, h = arguments.length, _ = h < 3 ? e : t === null ? t = Object.getOwnPropertyDescriptor(e, i) : t;
if (typeof Reflect == "object" && typeof Reflect.decorate == "function")
_ = Reflect.decorate(d, e, i, t);
else
for (var g = d.length - 1; g >= 0; g--)
(r = d[g]) && (_ = (h < 3 ? r(_) : h > 3 ? r(e, i, _) : r(e, i)) || _);
return h > 3 && _ && Object.defineProperty(e, i, _), _;
}, 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 u = 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, _ = new n.CellData(), g = t.getTrimmedLength();
let m = -1, l = -1, p = !1;
for (let b = 0; b < g; b++)
if (l !== -1 || t.hasContent(b)) {
if (t.loadCell(b, _), _.hasExtendedAttrs() && _.extended.urlId) {
if (l === -1) {
l = b, m = _.extended.urlId;
continue;
}
p = _.extended.urlId !== m;
} else
l !== -1 && (p = !0);
if (p || l !== -1 && b === g - 1) {
const E = (i = this._oscLinkService.getLinkData(m)) === null || i === void 0 ? void 0 : i.uri;
if (E) {
const y = { start: { x: l + 1, y: d }, end: { x: b + (p || b !== g - 1 ? 0 : 1), y: d } };
let k = !1;
if (!(h != null && h.allowNonHttpProtocols))
try {
const B = new URL(E);
["http:", "https:"].includes(B.protocol) || (k = !0);
} catch (B) {
k = !0;
}
k || r.push({ text: E, range: y, activate: (B, I) => h ? h.activate(B, I, y) : v(0, I), hover: (B, I) => {
var U;
return (U = h == null ? void 0 : h.hover) === null || U === void 0 ? void 0 : U.call(h, B, I, y);
}, leave: (B, I) => {
var U;
return (U = h == null ? void 0 : h.leave) === null || U === void 0 ? void 0 : U.call(h, B, I, y);
} });
}
p = !1, _.hasExtendedAttrs() && _.extended.urlId ? (l = b, m = _.extended.urlId) : (l = -1, m = -1);
}
}
e(r);
}
};
function v(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 (t) {
}
i.location.href = e;
} else
console.warn("Opening link blocked as opener could not be cleared");
}
}
s.OscLinkProvider = u = a([f(0, c.IBufferService), f(1, c.IOptionsService), f(2, c.IOscLinkService)], u);
}, 6193: (R, 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: (R, 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: (R, 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), u = o(3730), v = o(1680), d = o(3107), e = o(5744), i = o(2950), t = o(1296), r = o(428), h = o(4269), _ = o(5114), g = o(8934), m = o(3230), l = o(9312), p = o(4725), b = o(6731), E = o(8055), y = o(8969), k = o(8460), B = o(844), I = o(6114), U = o(8437), W = o(2584), C = o(7399), w = o(5941), L = o(9074), D = o(2585), T = o(5435), P = o(4567), z = typeof window != "undefined" ? window.document : null;
class $ extends y.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(S = {}) {
super(S), this.browser = I, this._keyDownHandled = !1, this._keyDownSeen = !1, this._keyPressHandled = !1, this._unprocessedDeadKey = !1, this._accessibilityManager = this.register(new B.MutableDisposable()), this._onCursorMove = this.register(new k.EventEmitter()), this.onCursorMove = this._onCursorMove.event, this._onKey = this.register(new k.EventEmitter()), this.onKey = this._onKey.event, this._onRender = this.register(new k.EventEmitter()), this.onRender = this._onRender.event, this._onSelectionChange = this.register(new k.EventEmitter()), this.onSelectionChange = this._onSelectionChange.event, this._onTitleChange = this.register(new k.EventEmitter()), this.onTitleChange = this._onTitleChange.event, this._onBell = this.register(new k.EventEmitter()), this.onBell = this._onBell.event, this._onFocus = this.register(new k.EventEmitter()), this._onBlur = this.register(new k.EventEmitter()), this._onA11yCharEmitter = this.register(new k.EventEmitter()), this._onA11yTabEmitter = this.register(new k.EventEmitter()), this._onWillOpen = this.register(new k.EventEmitter()), this._setup(), this.linkifier2 = this.register(this._instantiationService.createInstance(n.Linkifier2)), this.linkifier2.registerLinkProvider(this._instantiationService.createInstance(u.OscLinkProvider)), this._decorationService = this._instantiationService.createInstance(L.DecorationService), this._instantiationService.setService(D.IDecorationService, this._decorationService), this.register(this._inputHandler.onRequestBell(() => this._onBell.fire())), this.register(this._inputHandler.onRequestRefreshRows((x, H) => this.refresh(x, H))), this.register(this._inputHandler.onRequestSendFocus(() => this._reportFocus())), this.register(this._inputHandler.onRequestReset(() => this.reset())), this.register(this._inputHandler.onRequestWindowsOptionsReport((x) => this._reportWindowsOptions(x))), this.register(this._inputHandler.onColor((x) => this._handleColorEvent(x))), this.register((0, k.forwardEvent)(this._inputHandler.onCursorMove, this._onCursorMove)), this.register((0, k.forwardEvent)(this._inputHandler.onTitleChange, this._onTitleChange)), this.register((0, k.forwardEvent)(this._inputHandler.onA11yChar, this._onA11yCharEmitter)), this.register((0, k.forwardEvent)(this._inputHandler.onA11yTab, this._onA11yTabEmitter)), this.register(this._bufferService.onResize((x) => this._afterResize(x.cols, x.rows))), this.register((0, B.toDisposable)(() => {
var x, H;
this._customKeyEventHandler = void 0, (H = (x = this.element) === null || x === void 0 ? void 0 : x.parentNode) === null || H === void 0 || H.removeChild(this.element);
}));
}
_handleColorEvent(S) {
if (this._themeService)
for (const x of S) {
let H, O = "";
switch (x.index) {
case 256:
H = "foreground", O = "10";
break;
case 257:
H = "background", O = "11";
break;
case 258:
H = "cursor", O = "12";
break;
default:
H = "ansi", O = "4;" + x.index;
}
switch (x.type) {
case 0:
const q = E.color.toColorRGB(H === "ansi" ? this._themeService.colors.ansi[x.index] : this._themeService.colors[H]);
this.coreService.triggerDataEvent(`${W.C0.ESC}]${O};${(0, w.toRgbString)(q)}${W.C1_ESCAPED.ST}`);
break;
case 1:
if (H === "ansi")
this._themeService.modifyColors((j) => j.ansi[x.index] = E.rgba.toColor(...x.color));
else {
const j = H;
this._themeService.modifyColors((X) => X[j] = E.rgba.toColor(...x.color));
}
break;
case 2:
this._themeService.restoreColor(x.index);
}
}
}
_setup() {
super._setup(), this._customKeyEventHandler = void 0;
}
get buffer() {
return this.buffers.active;
}
focus() {
this.textarea && this.textarea.focus({ preventScroll: !0 });
}
_handleScreenReaderModeOptionChange(S) {
S ? !this._accessibilityManager.value && this._renderService && (this._accessibilityManager.value = this._instantiationService.createInstance(P.AccessibilityManager, this)) : this._accessibilityManager.clear();
}
_handleTextAreaFocus(S) {
this.coreService.decPrivateModes.sendFocus && this.coreService.triggerDataEvent(W.C0.ESC + "[I"), this.updateCursorStyle(S), this.element.classList.add("focus"), this._showCursor(), this._onFocus.fire();
}
blur() {
var S;
return (S = this.textarea) === null || S === void 0 ? void 0 : S.blur();
}
_handleTextAreaBlur() {
this.textarea.value = "", this.refresh(this.buffer.y, this.buffer.y), this.coreService.decPrivateModes.sendFocus && this.coreService.triggerDataEvent(W.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 S = this.buffer.ybase + this.buffer.y, x = this.buffer.lines.get(S);
if (!x)
return;
const H = Math.min(this.buffer.x, this.cols - 1), O = this._renderService.dimensions.css.cell.height, q = x.getWidth(H), j = this._renderService.dimensions.css.cell.width * q, X = this.buffer.y * this._renderService.dimensions.css.cell.height, Q = H * this._renderService.dimensions.css.cell.width;
this.textarea.style.left = Q + "px", this.textarea.style.top = X + "px", this.textarea.style.width = j + "px", this.textarea.style.height = O + "px", this.textarea.style.lineHeight = O + "px", this.textarea.style.zIndex = "-5";
}
_initGlobal() {
this._bindKeys(), this.register((0, f.addDisposableDomListener)(this.element, "copy", (x) => {
this.hasSelection() && (0, a.copyHandler)(x, this._selectionService);
}));
const S = (x) => (0, a.handlePasteEvent)(x, this.textarea, this.coreService, this.optionsService);
this.register((0, f.addDisposableDomListener)(this.textarea, "paste", S)), this.register((0, f.addDisposableDomListener)(this.element, "paste", S)), I.isFirefox ? this.register((0, f.addDisposableDomListener)(this.element, "mousedown", (x) => {
x.button === 2 && (0, a.rightClickHandler)(x, this.textarea, this.screenElement, this._selectionService, this.options.rightClickSelectsWord);
})) : this.register((0, f.addDisposableDomListener)(this.element, "contextmenu", (x) => {
(0, a.rightClickHandler)(x, this.textarea, this.screenElement, this._selectionService, this.options.rightClickSelectsWord);
})), I.isLinux && this.register((0, f.addDisposableDomListener)(this.element, "auxclick", (x) => {
x.button === 1 && (0, a.moveTextAreaUnderMouseCursor)(x, this.textarea, this.screenElement);
}));
}
_bindKeys() {
this.register((0, f.addDisposableDomListener)(this.textarea, "keyup", (S) => this._keyUp(S), !0)), this.register((0, f.addDisposableDomListener)(this.textarea, "keydown", (S) => this._keyDown(S), !0)), this.register((0, f.addDisposableDomListener)(this.textarea, "keypress", (S) => this._keyPress(S), !0)), this.register((0, f.addDisposableDomListener)(this.textarea, "compositionstart", () => this._compositionHelper.compositionstart())), this.register((0, f.addDisposableDomListener)(this.textarea, "compositionupdate", (S) => this._compositionHelper.compositionupdate(S))), this.register((0, f.addDisposableDomListener)(this.textarea, "compositionend", () => this._compositionHelper.compositionend())), this.register((0, f.addDisposableDomListener)(this.textarea, "input", (S) => this._inputEvent(S), !0)), this.register(this.onRender(() => this._compositionHelper.updateCompositionElements()));
}
open(S) {
var x;
if (!S)
throw new Error("Terminal requires a parent element.");
S.isConnected || this._logService.debug("Terminal.open was called on an element that was not attached to the DOM"), this._document = S.ownerDocument, this.element = this._document.createElement("div"), this.element.dir = "ltr", this.element.classList.add("terminal"), this.element.classList.add("xterm"), S.appendChild(this.element);
const H = z.createDocumentFragment();
this._viewportElement = z.createElement("div"), this._viewportElement.classList.add("xterm-viewport"), H.appendChild(this._viewportElement), this._viewportScrollArea = z.createElement("div"), this._viewportScrollArea.classList.add("xterm-scroll-area"), this._viewportElement.appendChild(this._viewportScrollArea), this.screenElement = z.createElement("div"), this.screenElement.classList.add("xterm-screen"), this._helperContainer = z.createElement("div"), this._helperContainer.classList.add("xterm-helpers"), this.screenElement.appendChild(this._helperContainer), H.appendChild(this.screenElement), this.textarea = z.createElement("textarea"), this.textarea.classList.add("xterm-helper-textarea"), this.textarea.setAttribute("aria-label", c.promptLabel), I.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(_.CoreBrowserService, this.textarea, (x = this._document.defaultView) !== null && x !== void 0 ? x : window), this._instantiationService.setService(p.ICoreBrowserService, this._coreBrowserService), this.register((0, f.addDisposableDomListener)(this.textarea, "focus", (O) => this._handleTextAreaFocus(O))), 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(b.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((O) => this._onRender.fire(O))), this.onResize((O) => this._renderService.resize(O.cols, O.rows)), this._compositionView = z.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 (O) {
}
this._renderService.hasRenderer() || this._renderService.setRenderer(this._createRenderer()), this._mouseService = this._instantiationService.createInstance(g.MouseService), this._instantiationService.setService(p.IMouseService, this._mouseService), this.viewport = this._instantiationService.createInstance(v.Viewport, this._viewportElement, this._viewportScrollArea), this.viewport.onRequestScrollLines((O) => this.scrollLines(O.amount, O.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((O) => this.scrollLines(O.amount, O.suppressScrollEvent))), this.register(this._selectionService.onSelectionChange(() => this._onSelectionChange.fire())), this.register(this._selectionService.onRequestRedraw((O) => this._renderService.handleSelectionChanged(O.start, O.end, O.columnSelectMode))), this.register(this._selectionService.onLinuxMouseSelection((O) => {
this.textarea.value = O, this.textarea.focus(), this.textarea.select();
})), this.register(this._onScroll.event((O) => {
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", (O) => this._selectionService.handleMouseDown(O))), 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(P.AccessibilityManager, this)), this.register(this.optionsService.onSpecificOptionChange("screenReaderMode", (O) => this._handleScreenReaderModeOptionChange(O))), this.options.overviewRulerWidth && (this._overviewRulerRenderer = this.register(this._instantiationService.createInstance(e.OverviewRulerRenderer, this._viewportElement, this.screenElement))), this.optionsService.onSpecificOptionChange("overviewRulerWidth", (O) => {
!this._overviewRulerRenderer && O && 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 S = this, x = this.element;
function H(j) {
const X = S._mouseService.getMouseReportCoords(j, S.screenElement);
if (!X)
return !1;
let Q, ee;
switch (j.overrideType || j.type) {
case "mousemove":
ee = 32, j.buttons === void 0 ? (Q = 3, j.button !== void 0 && (Q = j.button < 3 ? j.button : 3)) : Q = 1 & j.buttons ? 0 : 4 & j.buttons ? 1 : 2 & j.buttons ? 2 : 3;
break;
case "mouseup":
ee = 0, Q = j.button < 3 ? j.button : 3;
break;
case "mousedown":
ee = 1, Q = j.button < 3 ? j.button : 3;
break;
case "wheel":
if (S.viewport.getLinesScrolled(j) === 0)
return !1;
ee = j.deltaY < 0 ? 0 : 1, Q = 4;
break;
default:
return !1;
}
return !(ee === void 0 || Q === void 0 || Q > 4) && S.coreMouseService.triggerMouseEvent({ col: X.col, row: X.row, x: X.x, y: X.y, button: Q, action: ee, ctrl: j.ctrlKey, alt: j.altKey, shift: j.shiftKey });
}
const O = { mouseup: null, wheel: null, mousedrag: null, mousemove: null }, q = { mouseup: (j) => (H(j), j.buttons || (this._document.removeEventListener("mouseup", O.mouseup), O.mousedrag && this._document.removeEventListener("mousemove", O.mousedrag)), this.cancel(j)), wheel: (j) => (H(j), this.cancel(j, !0)), mousedrag: (j) => {
j.buttons && H(j);
}, mousemove: (j) => {
j.buttons || H(j);
} };
this.register(this.coreMouseService.onProtocolChange((j) => {
j ? (this.optionsService.rawOptions.logLevel === "debug" && this._logService.debug("Binding to mouse events:", this.coreMouseService.explainEvents(j)), 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 & j ? O.mousemove || (x.addEventListener("mousemove", q.mousemove), O.mousemove = q.mousemove) : (x.removeEventListener("mousemove", O.mousemove), O.mousemove = null), 16 & j ? O.wheel || (x.addEventListener("wheel", q.wheel, { passive: !1 }), O.wheel = q.wheel) : (x.removeEventListener("wheel", O.wheel), O.wheel = null), 2 & j ? O.mouseup || (x.addEventListener("mouseup", q.mouseup), O.mouseup = q.mouseup) : (this._document.removeEventListener("mouseup", O.mouseup), x.removeEventListener("mouseup", O.mouseup), O.mouseup = null), 4 & j ? O.mousedrag || (O.mousedrag = q.mousedrag) : (this._document.removeEventListener("mousemove", O.mousedrag), O.mousedrag = null);
})), this.coreMouseService.activeProtocol = this.coreMouseService.activeProtocol, this.register((0, f.addDisposableDomListener)(x, "mousedown", (j) => {
if (j.preventDefault(), this.focus(), this.coreMouseService.areMouseEventsActive && !this._selectionService.shouldForceSelection(j))
return H(j), O.mouseup && this.