gotty/js/dist/gotty-bundle.js

3 lines
614 KiB
JavaScript
Raw Normal View History

2022-02-26 20:08:53 -05:00
/*! For license information please see gotty-bundle.js.LICENSE.txt */
2025-10-28 19:51:34 -05:00
(()=>{var e={50:e=>{var t;self,t=()=>(()=>{"use strict";var e={6:(e,t)=>{function i(e){try{const t=new URL(e),i=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(i.toLocaleLowerCase())}catch(e){return!1}}Object.defineProperty(t,"__esModule",{value:!0}),t.LinkComputer=t.WebLinkProvider=void 0,t.WebLinkProvider=class{constructor(e,t,i,r={}){this._terminal=e,this._regex=t,this._handler=i,this._options=r}provideLinks(e,t){const i=r.computeLink(e,this._regex,this._terminal,this._handler);t(this._addCallbacks(i))}_addCallbacks(e){return e.map(e=>(e.leave=this._options.leave,e.hover=(t,i)=>{if(this._options.hover){const{range:r}=e;this._options.hover(t,i,r)}},e))}};class r{static computeLink(e,t,s,o){const n=new RegExp(t.source,(t.flags||"")+"g"),[a,h]=r._getWindowedLineStrings(e-1,s),l=a.join("");let c;const u=[];for(;c=n.exec(l);){const e=c[0];if(!i(e))continue;const[t,n]=r._mapStrIdx(s,h,0,c.index),[a,l]=r._mapStrIdx(s,t,n,e.length);if(-1===t||-1===n||-1===a||-1===l)continue;const d={start:{x:n+1,y:t+1},end:{x:l,y:a+1}};u.push({range:d,text:e,activate:o})}return u}static _getWindowedLineStrings(e,t){let i,r=e,s=e,o=0,n="";const a=[];if(i=t.buffer.active.getLine(e)){const e=i.translateToString(!0);if(i.isWrapped&&" "!==e[0]){for(o=0;(i=t.buffer.active.getLine(--r))&&o<2048&&(n=i.translateToString(!0),o+=n.length,a.push(n),i.isWrapped&&-1===n.indexOf(" ")););a.reverse()}for(a.push(e),o=0;(i=t.buffer.active.getLine(++s))&&i.isWrapped&&o<2048&&(n=i.translateToString(!0),o+=n.length,a.push(n),-1===n.indexOf(" ")););}return[a,r]}static _mapStrIdx(e,t,i,r){const s=e.buffer.active,o=s.getNullCell();let n=i;for(;r;){const e=s.getLine(t);if(!e)return[-1,-1];for(let i=n;i<e.length;++i){e.getCell(i,o);const n=o.getChars();if(o.getWidth()&&(r-=n.length||1,i===e.length-1&&""===n)){const e=s.getLine(t+1);e&&e.isWrapped&&(e.getCell(0,o),2===o.getWidth()&&(r+=1))}if(r<0)return[t,i]}t++,n=0}return[t,n]}}t.LinkComputer=r}},t={};function i(r){var s=t[r];if(void 0!==s)return s.exports;var o=t[r]={exports:{}};return e[r](o,o.exports,i),o.exports}var r={};return(()=>{var e=r;Object.defineProperty(e,"__esModule",{value:!0}),e.WebLinksAddon=void 0;const t=i(6),s=/(https?|HTTPS?):[/]{2}[^\s"'!*(){}|\\\^<>`]*[^\s"':,.!?{}|\\\^~\[\]`()<>]/;function o(e,t){const i=window.open();if(i){try{i.opener=null}catch{}i.location.href=t}else console.warn("Opening link blocked as opener could not be cleared")}e.WebLinksAddon=class{constructor(e=o,t={}){this._handler=e,this._options=t}activate(e){this._terminal=e;const i=this._options,r=i.urlRegex||s;this._linkProvider=this._terminal.registerLinkProvider(new t.WebLinkProvider(this._terminal,r,this._handler,i))}dispose(){this._linkProvider?.dispose()}}})(),r})(),e.exports=t()},59:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WebTTY=t.msgSetReconnect=t.msgSetPreferences=t.msgSetWindowTitle=t.msgPong=t.msgOutput=t.msgUnknownOutput=t.msgResizeTerminal=t.msgPing=t.msgInput=t.msgInputUnknown=t.protocols=void 0,t.protocols=["webtty"],t.msgInputUnknown="0",t.msgInput="1",t.msgPing="2",t.msgResizeTerminal="3",t.msgUnknownOutput="0",t.msgOutput="1",t.msgPong="2",t.msgSetWindowTitle="3",t.msgSetPreferences="4",t.msgSetReconnect="5";var i=function(){function e(e,t,i,r){this.term=e,this.connectionFactory=t,this.args=i,this.authToken=r,this.reconnect=-1}return e.prototype.open=function(){var e,i,r=this,s=this.connectionFactory.create(),o=function(){s.onOpen(function(){var i=r.term.info();s.send(JSON.stringify({Arguments:r.args,AuthToken:r.authToken}));var o=function(e,i){s.send(t.msgResizeTerminal+JSON.stringify({columns:e,rows:i}))};r.term.onResize(o),o(i.columns,i.rows),r.term.onInput(function(e){s.send(t.msgInput+e)}),e=setInterval(function(){s.send(t.msgPing)},3e4)}),s.onReceive(function(e){var i=e.slice(1);switch(e[0]){case t.msgOutput:r.term.output(atob(i));break;case t.msgPong:break;case t.msgSetWindowTitle:r.term.setWindowTitle(i);break;case t.msgSetP
2022-02-26 20:08:53 -05:00
//# sourceMappingURL=gotty-bundle.js.map