2022-10-27 14:13:23 -04:00
|
|
|
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var i,s=t();for(i in s)("object"==typeof exports?exports:e)[i]=s[i]}}(self,function(){return(()=>{"use strict";var i={4567:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.AccessibilityManager=void 0;const s=i(9042),r=i(6114),n=i(9924),o=i(3656),a=i(844),h=i(5596),l=i(9631);class c extends a.Disposable{constructor(e,t){super(),this._terminal=e,this._renderService=t,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="",this._accessibilityTreeRoot=document.createElement("div"),this._accessibilityTreeRoot.classList.add("xterm-accessibility"),this._accessibilityTreeRoot.tabIndex=0,this._rowContainer=document.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let e=0;e<this._terminal.rows;e++)this._rowElements[e]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[e]);if(this._topBoundaryFocusListener=e=>this._onBoundaryFocus(e,0),this._bottomBoundaryFocusListener=e=>this._onBoundaryFocus(e,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions(),this._accessibilityTreeRoot.appendChild(this._rowContainer),this._renderRowsDebouncer=new n.TimeBasedDebouncer(this._renderRows.bind(this)),this._refreshRows(),this._liveRegion=document.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityTreeRoot.appendChild(this._liveRegion),!this._terminal.element)throw new Error("Cannot enable accessibility before Terminal.open");this._terminal.element.insertAdjacentElement("afterbegin",this._accessibilityTreeRoot),this.register(this._renderRowsDebouncer),this.register(this._terminal.onResize(e=>this._onResize(e.rows))),this.register(this._terminal.onRender(e=>this._refreshRows(e.start,e.end))),this.register(this._terminal.onScroll(()=>this._refreshRows())),this.register(this._terminal.onA11yChar(e=>this._onChar(e))),this.register(this._terminal.onLineFeed(()=>this._onChar("\n"))),this.register(this._terminal.onA11yTab(e=>this._onTab(e))),this.register(this._terminal.onKey(e=>this._onKey(e.key))),this.register(this._terminal.onBlur(()=>this._clearLiveRegion())),this.register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this._screenDprMonitor=new h.ScreenDprMonitor(window),this.register(this._screenDprMonitor),this._screenDprMonitor.setListener(()=>this._refreshRowsDimensions()),this.register((0,o.addDisposableDomListener)(window,"resize",()=>this._refreshRowsDimensions()))}dispose(){super.dispose(),(0,l.removeElementFromParent)(this._accessibilityTreeRoot),this._rowElements.length=0}_onBoundaryFocus(i,s){var r=i.target,e=this._rowElements[0===s?1:this._rowElements.length-2];if(r.getAttribute("aria-posinset")!==(0===s?"1":""+this._terminal.buffer.lines.length)&&i.relatedTarget===e){let e,t;if(0===s?(e=r,t=this._rowElements.pop(),this._rowContainer.removeChild(t)):(e=this._rowElements.shift(),t=r,this._rowContainer.removeChild(e)),e.removeEventListener("focus",this._topBoundaryFocusListener),t.removeEventListener("focus",this._bottomBoundaryFocusListener),0===s){const i=this._createAccessibilityTreeNode();this._rowElements.unshift(i),this._rowContainer.insertAdjacentElement("afterbegin",i)}else{const i=this._createAccessibilityTreeNode();this._rowElements.push(i),this._rowContainer.appendChild(i)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(0===s?-1:1),this._rowElements[0===s?1:this._rowElements.length-2].focus(),i.preventDefault(),i.stopImmediatePropagation()}}_onResize(e){this._rowElements[this
|