@xterm/addon-serialize
Advanced tools
Comparing version 0.14.0-beta.39 to 0.14.0-beta.40
@@ -1,2 +0,2 @@ | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.SerializeAddon=t():e.SerializeAddon=t()}(globalThis,(()=>(()=>{"use strict";var e={930:(e,t,s)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ColorContrastCache=void 0;const r=s(485);t.ColorContrastCache=class{constructor(){this._color=new r.TwoKeyMap,this._css=new r.TwoKeyMap}setCss(e,t,s){this._css.set(e,t,s)}getCss(e,t){return this._css.get(e,t)}setColor(e,t,s){this._color.set(e,t,s)}getColor(e,t){return this._color.get(e,t)}clear(){this._color.clear(),this._css.clear()}}},997:function(e,t,s){var r=this&&this.__decorate||function(e,t,s,r){var o,i=arguments.length,n=i<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,s):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,s,r);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(n=(i<3?o(n):i>3?o(t,s,n):o(t,s))||n);return i>3&&n&&Object.defineProperty(t,s,n),n},o=this&&this.__param||function(e,t){return function(s,r){t(s,r,e)}};Object.defineProperty(t,"__esModule",{value:!0}),t.ThemeService=t.DEFAULT_ANSI_COLORS=void 0;const i=s(930),n=s(160),a=s(345),l=s(859),c=s(97),h=n.css.toColor("#ffffff"),u=n.css.toColor("#000000"),_=n.css.toColor("#ffffff"),d=n.css.toColor("#000000"),C={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117};t.DEFAULT_ANSI_COLORS=Object.freeze((()=>{const e=[n.css.toColor("#2e3436"),n.css.toColor("#cc0000"),n.css.toColor("#4e9a06"),n.css.toColor("#c4a000"),n.css.toColor("#3465a4"),n.css.toColor("#75507b"),n.css.toColor("#06989a"),n.css.toColor("#d3d7cf"),n.css.toColor("#555753"),n.css.toColor("#ef2929"),n.css.toColor("#8ae234"),n.css.toColor("#fce94f"),n.css.toColor("#729fcf"),n.css.toColor("#ad7fa8"),n.css.toColor("#34e2e2"),n.css.toColor("#eeeeec")],t=[0,95,135,175,215,255];for(let s=0;s<216;s++){const r=t[s/36%6|0],o=t[s/6%6|0],i=t[s%6];e.push({css:n.channels.toCss(r,o,i),rgba:n.channels.toRgba(r,o,i)})}for(let t=0;t<24;t++){const s=8+10*t;e.push({css:n.channels.toCss(s,s,s),rgba:n.channels.toRgba(s,s,s)})}return e})());let f=class extends l.Disposable{get colors(){return this._colors}constructor(e){super(),this._optionsService=e,this._contrastCache=new i.ColorContrastCache,this._halfContrastCache=new i.ColorContrastCache,this._onChangeColors=this.register(new a.EventEmitter),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:h,background:u,cursor:_,cursorAccent:d,selectionForeground:void 0,selectionBackgroundTransparent:C,selectionBackgroundOpaque:n.color.blend(u,C),selectionInactiveBackgroundTransparent:C,selectionInactiveBackgroundOpaque:n.color.blend(u,C),ansi:t.DEFAULT_ANSI_COLORS.slice(),contrastCache:this._contrastCache,halfContrastCache:this._halfContrastCache},this._updateRestoreColors(),this._setTheme(this._optionsService.rawOptions.theme),this.register(this._optionsService.onSpecificOptionChange("minimumContrastRatio",(()=>this._contrastCache.clear()))),this.register(this._optionsService.onSpecificOptionChange("theme",(()=>this._setTheme(this._optionsService.rawOptions.theme))))}_setTheme(e={}){const s=this._colors;if(s.foreground=g(e.foreground,h),s.background=g(e.background,u),s.cursor=g(e.cursor,_),s.cursorAccent=g(e.cursorAccent,d),s.selectionBackgroundTransparent=g(e.selectionBackground,C),s.selectionBackgroundOpaque=n.color.blend(s.background,s.selectionBackgroundTransparent),s.selectionInactiveBackgroundTransparent=g(e.selectionInactiveBackground,s.selectionBackgroundTransparent),s.selectionInactiveBackgroundOpaque=n.color.blend(s.background,s.selectionInactiveBackgroundTransparent),s.selectionForeground=e.selectionForeground?g(e.selectionForeground,n.NULL_COLOR):void 0,s.selectionForeground===n.NULL_COLOR&&(s.selectionForeground=void 0),n.color.isOpaque(s.selectionBackgroundTransparent)){const e=.3;s.selectionBackgroundTransparent=n.color.opacity(s.selectionBackgroundTransparent,e)}if(n.color.isOpaque(s.selectionInactiveBackgroundTransparent)){const e=.3;s.selectionInactiveBackgroundTransparent=n.color.opacity(s.selectionInactiveBackgroundTransparent,e)}if(s.ansi=t.DEFAULT_ANSI_COLORS.slice(),s.ansi[0]=g(e.black,t.DEFAULT_ANSI_COLORS[0]),s.ansi[1]=g(e.red,t.DEFAULT_ANSI_COLORS[1]),s.ansi[2]=g(e.green,t.DEFAULT_ANSI_COLORS[2]),s.ansi[3]=g(e.yellow,t.DEFAULT_ANSI_COLORS[3]),s.ansi[4]=g(e.blue,t.DEFAULT_ANSI_COLORS[4]),s.ansi[5]=g(e.magenta,t.DEFAULT_ANSI_COLORS[5]),s.ansi[6]=g(e.cyan,t.DEFAULT_ANSI_COLORS[6]),s.ansi[7]=g(e.white,t.DEFAULT_ANSI_COLORS[7]),s.ansi[8]=g(e.brightBlack,t.DEFAULT_ANSI_COLORS[8]),s.ansi[9]=g(e.brightRed,t.DEFAULT_ANSI_COLORS[9]),s.ansi[10]=g(e.brightGreen,t.DEFAULT_ANSI_COLORS[10]),s.ansi[11]=g(e.brightYellow,t.DEFAULT_ANSI_COLORS[11]),s.ansi[12]=g(e.brightBlue,t.DEFAULT_ANSI_COLORS[12]),s.ansi[13]=g(e.brightMagenta,t.DEFAULT_ANSI_COLORS[13]),s.ansi[14]=g(e.brightCyan,t.DEFAULT_ANSI_COLORS[14]),s.ansi[15]=g(e.brightWhite,t.DEFAULT_ANSI_COLORS[15]),e.extendedAnsi){const r=Math.min(s.ansi.length-16,e.extendedAnsi.length);for(let o=0;o<r;o++)s.ansi[o+16]=g(e.extendedAnsi[o],t.DEFAULT_ANSI_COLORS[o+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(e){this._restoreColor(e),this._onChangeColors.fire(this.colors)}_restoreColor(e){if(void 0!==e)switch(e){case 256:this._colors.foreground=this._restoreColors.foreground;break;case 257:this._colors.background=this._restoreColors.background;break;case 258:this._colors.cursor=this._restoreColors.cursor;break;default:this._colors.ansi[e]=this._restoreColors.ansi[e]}else for(let e=0;e<this._restoreColors.ansi.length;++e)this._colors.ansi[e]=this._restoreColors.ansi[e]}modifyColors(e){e(this._colors),this._onChangeColors.fire(this.colors)}_updateRestoreColors(){this._restoreColors={foreground:this._colors.foreground,background:this._colors.background,cursor:this._colors.cursor,ansi:this._colors.ansi.slice()}}};function g(e,t){if(void 0!==e)try{return n.css.toColor(e)}catch{}return t}t.ThemeService=f,t.ThemeService=f=r([o(0,c.IOptionsService)],f)},160:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.rgba=t.rgb=t.css=t.color=t.channels=t.NULL_COLOR=void 0,t.toPaddedHex=u,t.contrastRatio=_;let s=0,r=0,o=0,i=0;var n,a,l,c,h;function u(e){const t=e.toString(16);return t.length<2?"0"+t:t}function _(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}t.NULL_COLOR={css:"#00000000",rgba:0},function(e){e.toCss=function(e,t,s,r){return void 0!==r?`#${u(e)}${u(t)}${u(s)}${u(r)}`:`#${u(e)}${u(t)}${u(s)}`},e.toRgba=function(e,t,s,r=255){return(e<<24|t<<16|s<<8|r)>>>0},e.toColor=function(t,s,r,o){return{css:e.toCss(t,s,r,o),rgba:e.toRgba(t,s,r,o)}}}(n||(t.channels=n={})),function(e){function t(e,t){return i=Math.round(255*t),[s,r,o]=h.toChannels(e.rgba),{css:n.toCss(s,r,o,i),rgba:n.toRgba(s,r,o,i)}}e.blend=function(e,t){if(i=(255&t.rgba)/255,1===i)return{css:t.css,rgba:t.rgba};const a=t.rgba>>24&255,l=t.rgba>>16&255,c=t.rgba>>8&255,h=e.rgba>>24&255,u=e.rgba>>16&255,_=e.rgba>>8&255;return s=h+Math.round((a-h)*i),r=u+Math.round((l-u)*i),o=_+Math.round((c-_)*i),{css:n.toCss(s,r,o),rgba:n.toRgba(s,r,o)}},e.isOpaque=function(e){return 255==(255&e.rgba)},e.ensureContrastRatio=function(e,t,s){const r=h.ensureContrastRatio(e.rgba,t.rgba,s);if(r)return n.toColor(r>>24&255,r>>16&255,r>>8&255)},e.opaque=function(e){const t=(255|e.rgba)>>>0;return[s,r,o]=h.toChannels(t),{css:n.toCss(s,r,o),rgba:t}},e.opacity=t,e.multiplyOpacity=function(e,s){return i=255&e.rgba,t(e,i*s/255)},e.toColorRGB=function(e){return[e.rgba>>24&255,e.rgba>>16&255,e.rgba>>8&255]}}(a||(t.color=a={})),function(e){let t,a;try{const e=document.createElement("canvas");e.width=1,e.height=1;const s=e.getContext("2d",{willReadFrequently:!0});s&&(t=s,t.globalCompositeOperation="copy",a=t.createLinearGradient(0,0,1,1))}catch{}e.toColor=function(e){if(e.match(/#[\da-f]{3,8}/i))switch(e.length){case 4:return s=parseInt(e.slice(1,2).repeat(2),16),r=parseInt(e.slice(2,3).repeat(2),16),o=parseInt(e.slice(3,4).repeat(2),16),n.toColor(s,r,o);case 5:return s=parseInt(e.slice(1,2).repeat(2),16),r=parseInt(e.slice(2,3).repeat(2),16),o=parseInt(e.slice(3,4).repeat(2),16),i=parseInt(e.slice(4,5).repeat(2),16),n.toColor(s,r,o,i);case 7:return{css:e,rgba:(parseInt(e.slice(1),16)<<8|255)>>>0};case 9:return{css:e,rgba:parseInt(e.slice(1),16)>>>0}}const l=e.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(l)return s=parseInt(l[1]),r=parseInt(l[2]),o=parseInt(l[3]),i=Math.round(255*(void 0===l[5]?1:parseFloat(l[5]))),n.toColor(s,r,o,i);if(!t||!a)throw new Error("css.toColor: Unsupported css format");if(t.fillStyle=a,t.fillStyle=e,"string"!=typeof t.fillStyle)throw new Error("css.toColor: Unsupported css format");if(t.fillRect(0,0,1,1),[s,r,o,i]=t.getImageData(0,0,1,1).data,255!==i)throw new Error("css.toColor: Unsupported css format");return{rgba:n.toRgba(s,r,o,i),css:e}}}(l||(t.css=l={})),function(e){function t(e,t,s){const r=e/255,o=t/255,i=s/255;return.2126*(r<=.03928?r/12.92:Math.pow((r+.055)/1.055,2.4))+.7152*(o<=.03928?o/12.92:Math.pow((o+.055)/1.055,2.4))+.0722*(i<=.03928?i/12.92:Math.pow((i+.055)/1.055,2.4))}e.relativeLuminance=function(e){return t(e>>16&255,e>>8&255,255&e)},e.relativeLuminance2=t}(c||(t.rgb=c={})),function(e){function t(e,t,s){const r=e>>24&255,o=e>>16&255,i=e>>8&255;let n=t>>24&255,a=t>>16&255,l=t>>8&255,h=_(c.relativeLuminance2(n,a,l),c.relativeLuminance2(r,o,i));for(;h<s&&(n>0||a>0||l>0);)n-=Math.max(0,Math.ceil(.1*n)),a-=Math.max(0,Math.ceil(.1*a)),l-=Math.max(0,Math.ceil(.1*l)),h=_(c.relativeLuminance2(n,a,l),c.relativeLuminance2(r,o,i));return(n<<24|a<<16|l<<8|255)>>>0}function a(e,t,s){const r=e>>24&255,o=e>>16&255,i=e>>8&255;let n=t>>24&255,a=t>>16&255,l=t>>8&255,h=_(c.relativeLuminance2(n,a,l),c.relativeLuminance2(r,o,i));for(;h<s&&(n<255||a<255||l<255);)n=Math.min(255,n+Math.ceil(.1*(255-n))),a=Math.min(255,a+Math.ceil(.1*(255-a))),l=Math.min(255,l+Math.ceil(.1*(255-l))),h=_(c.relativeLuminance2(n,a,l),c.relativeLuminance2(r,o,i));return(n<<24|a<<16|l<<8|255)>>>0}e.blend=function(e,t){if(i=(255&t)/255,1===i)return t;const a=t>>24&255,l=t>>16&255,c=t>>8&255,h=e>>24&255,u=e>>16&255,_=e>>8&255;return s=h+Math.round((a-h)*i),r=u+Math.round((l-u)*i),o=_+Math.round((c-_)*i),n.toRgba(s,r,o)},e.ensureContrastRatio=function(e,s,r){const o=c.relativeLuminance(e>>8),i=c.relativeLuminance(s>>8);if(_(o,i)<r){if(i<o){const i=t(e,s,r),n=_(o,c.relativeLuminance(i>>8));if(n<r){const t=a(e,s,r);return n>_(o,c.relativeLuminance(t>>8))?i:t}return i}const n=a(e,s,r),l=_(o,c.relativeLuminance(n>>8));if(l<r){const i=t(e,s,r);return l>_(o,c.relativeLuminance(i>>8))?n:i}return n}},e.reduceLuminance=t,e.increaseLuminance=a,e.toChannels=function(e){return[e>>24&255,e>>16&255,e>>8&255,255&e]}}(h||(t.rgba=h={}))},345:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.EventEmitter=void 0,t.forwardEvent=function(e,t){return e((e=>t.fire(e)))},t.runAndSubscribe=function(e,t){return t(void 0),e((e=>t(e)))},t.EventEmitter=class{constructor(){this._listeners=new Set,this._disposed=!1}get event(){return this._event||(this._event=e=>(this._listeners.add(e),{dispose:()=>{this._disposed||this._listeners.delete(e)}})),this._event}fire(e,t){const s=[];for(const e of this._listeners.values())s.push(e);for(let r=0;r<s.length;r++)s[r].call(void 0,e,t)}dispose(){this.clearListeners(),this._disposed=!0}clearListeners(){this._listeners&&this._listeners.clear()}}},859:(e,t)=>{function s(e){for(const t of e)t.dispose();e.length=0}Object.defineProperty(t,"__esModule",{value:!0}),t.MutableDisposable=t.Disposable=void 0,t.toDisposable=function(e){return{dispose:e}},t.disposeArray=s,t.getDisposeArrayDisposable=function(e){return{dispose:()=>s(e)}},t.Disposable=class{constructor(){this._disposables=[],this._isDisposed=!1}dispose(){this._isDisposed=!0;for(const e of this._disposables)e.dispose();this._disposables.length=0}register(e){return this._disposables.push(e),e}unregister(e){const t=this._disposables.indexOf(e);-1!==t&&this._disposables.splice(t,1)}},t.MutableDisposable=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(e){this._isDisposed||e===this._value||(this._value?.dispose(),this._value=e)}clear(){this.value=void 0}dispose(){this._isDisposed=!0,this._value?.dispose(),this._value=void 0}}},485:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.FourKeyMap=t.TwoKeyMap=void 0;class s{constructor(){this._data={}}set(e,t,s){this._data[e]||(this._data[e]={}),this._data[e][t]=s}get(e,t){return this._data[e]?this._data[e][t]:void 0}clear(){this._data={}}}t.TwoKeyMap=s,t.FourKeyMap=class{constructor(){this._data=new s}set(e,t,r,o,i){this._data.get(e,t)||this._data.set(e,t,new s),this._data.get(e,t).set(r,o,i)}get(e,t,s,r){return this._data.get(e,t)?.get(s,r)}clear(){this._data.clear()}}},726:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.serviceRegistry=void 0,t.getServiceDependencies=function(e){return e[r]||[]},t.createDecorator=function(e){if(t.serviceRegistry.has(e))return t.serviceRegistry.get(e);const o=function(e,t,i){if(3!==arguments.length)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");!function(e,t,o){t[s]===t?t[r].push({id:e,index:o}):(t[r]=[{id:e,index:o}],t[s]=t)}(o,e,i)};return o.toString=()=>e,t.serviceRegistry.set(e,o),o};const s="di$target",r="di$dependencies";t.serviceRegistry=new Map},97:(e,t,s)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.IDecorationService=t.IUnicodeService=t.IOscLinkService=t.IOptionsService=t.ILogService=t.LogLevelEnum=t.IInstantiationService=t.ICharsetService=t.ICoreService=t.ICoreMouseService=t.IBufferService=void 0;const r=s(726);var o;t.IBufferService=(0,r.createDecorator)("BufferService"),t.ICoreMouseService=(0,r.createDecorator)("CoreMouseService"),t.ICoreService=(0,r.createDecorator)("CoreService"),t.ICharsetService=(0,r.createDecorator)("CharsetService"),t.IInstantiationService=(0,r.createDecorator)("InstantiationService"),function(e){e[e.TRACE=0]="TRACE",e[e.DEBUG=1]="DEBUG",e[e.INFO=2]="INFO",e[e.WARN=3]="WARN",e[e.ERROR=4]="ERROR",e[e.OFF=5]="OFF"}(o||(t.LogLevelEnum=o={})),t.ILogService=(0,r.createDecorator)("LogService"),t.IOptionsService=(0,r.createDecorator)("OptionsService"),t.IOscLinkService=(0,r.createDecorator)("OscLinkService"),t.IUnicodeService=(0,r.createDecorator)("UnicodeService"),t.IDecorationService=(0,r.createDecorator)("DecorationService")}},t={};function s(r){var o=t[r];if(void 0!==o)return o.exports;var i=t[r]={exports:{}};return e[r].call(i.exports,i,i.exports,s),i.exports}var r={};return(()=>{var e=r;Object.defineProperty(e,"__esModule",{value:!0}),e.HTMLSerializeHandler=e.SerializeAddon=void 0;const t=s(997);function o(e,t,s){return Math.max(t,Math.min(e,s))}class i{constructor(e){this._buffer=e}serialize(e,t){const s=this._buffer.getNullCell(),r=this._buffer.getNullCell();let o=s;const i=e.start.y,n=e.end.y,a=e.start.x,l=e.end.x;this._beforeSerialize(n-i,i,n);for(let t=i;t<=n;t++){const i=this._buffer.getLine(t);if(i){const n=t===e.start.y?a:0,c=t===e.end.y?l:i.length;for(let e=n;e<c;e++){const n=i.getCell(e,o===s?r:s);n?(this._nextCell(n,o,t,e),o=n):console.warn(`Can't get cell at row=${t}, col=${e}`)}}this._rowEnd(t,t===n)}return this._afterSerialize(),this._serializeString(t)}_nextCell(e,t,s,r){}_rowEnd(e,t){}_beforeSerialize(e,t,s){}_afterSerialize(){}_serializeString(e){return""}}function n(e,t){return e.getFgColorMode()===t.getFgColorMode()&&e.getFgColor()===t.getFgColor()}function a(e,t){return e.getBgColorMode()===t.getBgColorMode()&&e.getBgColor()===t.getBgColor()}function l(e,t){return e.isInverse()===t.isInverse()&&e.isBold()===t.isBold()&&e.isUnderline()===t.isUnderline()&&e.isOverline()===t.isOverline()&&e.isBlink()===t.isBlink()&&e.isInvisible()===t.isInvisible()&&e.isItalic()===t.isItalic()&&e.isDim()===t.isDim()&&e.isStrikethrough()===t.isStrikethrough()}class c extends i{constructor(e,t){super(e),this._terminal=t,this._rowIndex=0,this._allRows=new Array,this._allRowSeparators=new Array,this._currentRow="",this._nullCellCount=0,this._cursorStyle=this._buffer.getNullCell(),this._cursorStyleRow=0,this._cursorStyleCol=0,this._backgroundCell=this._buffer.getNullCell(),this._firstRow=0,this._lastCursorRow=0,this._lastCursorCol=0,this._lastContentCursorRow=0,this._lastContentCursorCol=0,this._thisRowLastChar=this._buffer.getNullCell(),this._thisRowLastSecondChar=this._buffer.getNullCell(),this._nextRowFirstChar=this._buffer.getNullCell()}_beforeSerialize(e,t,s){this._allRows=new Array(e),this._lastContentCursorRow=t,this._lastCursorRow=t,this._firstRow=t}_rowEnd(e,t){this._nullCellCount>0&&!a(this._cursorStyle,this._backgroundCell)&&(this._currentRow+=`[${this._nullCellCount}X`);let s="";if(!t){e-this._firstRow>=this._terminal.rows&&this._buffer.getLine(this._cursorStyleRow)?.getCell(this._cursorStyleCol,this._backgroundCell);const t=this._buffer.getLine(e),r=this._buffer.getLine(e+1);if(r.isWrapped){s="";const o=t.getCell(t.length-1,this._thisRowLastChar),i=t.getCell(t.length-2,this._thisRowLastSecondChar),n=r.getCell(0,this._nextRowFirstChar),l=n.getWidth()>1;let c=!1;(n.getChars()&&l?this._nullCellCount<=1:this._nullCellCount<=0)&&((o.getChars()||0===o.getWidth())&&a(o,n)&&(c=!0),l&&(i.getChars()||0===i.getWidth())&&a(o,n)&&a(i,n)&&(c=!0)),c||(s="-".repeat(this._nullCellCount+1),s+="[1D[1X",this._nullCellCount>0&&(s+="[A",s+=`[${t.length-this._nullCellCount}C`,s+=`[${this._nullCellCount}X`,s+=`[${t.length-this._nullCellCount}D`,s+="[B"),this._lastContentCursorRow=e+1,this._lastContentCursorCol=0,this._lastCursorRow=e+1,this._lastCursorCol=0)}else s="\r\n",this._lastCursorRow=e+1,this._lastCursorCol=0}this._allRows[this._rowIndex]=this._currentRow,this._allRowSeparators[this._rowIndex++]=s,this._currentRow="",this._nullCellCount=0}_diffStyle(e,t){const s=[],r=!n(e,t),o=!a(e,t),i=!l(e,t);if(r||o||i)if(e.isAttributeDefault())t.isAttributeDefault()||s.push(0);else{if(r){const t=e.getFgColor();e.isFgRGB()?s.push(38,2,t>>>16&255,t>>>8&255,255&t):e.isFgPalette()?t>=16?s.push(38,5,t):s.push(8&t?90+(7&t):30+(7&t)):s.push(39)}if(o){const t=e.getBgColor();e.isBgRGB()?s.push(48,2,t>>>16&255,t>>>8&255,255&t):e.isBgPalette()?t>=16?s.push(48,5,t):s.push(8&t?100+(7&t):40+(7&t)):s.push(49)}i&&(e.isInverse()!==t.isInverse()&&s.push(e.isInverse()?7:27),e.isBold()!==t.isBold()&&s.push(e.isBold()?1:22),e.isUnderline()!==t.isUnderline()&&s.push(e.isUnderline()?4:24),e.isOverline()!==t.isOverline()&&s.push(e.isOverline()?53:55),e.isBlink()!==t.isBlink()&&s.push(e.isBlink()?5:25),e.isInvisible()!==t.isInvisible()&&s.push(e.isInvisible()?8:28),e.isItalic()!==t.isItalic()&&s.push(e.isItalic()?3:23),e.isDim()!==t.isDim()&&s.push(e.isDim()?2:22),e.isStrikethrough()!==t.isStrikethrough()&&s.push(e.isStrikethrough()?9:29))}return s}_nextCell(e,t,s,r){if(0===e.getWidth())return;const o=""===e.getChars(),i=this._diffStyle(e,this._cursorStyle);if(o?!a(this._cursorStyle,e):i.length>0){this._nullCellCount>0&&(a(this._cursorStyle,this._backgroundCell)||(this._currentRow+=`[${this._nullCellCount}X`),this._currentRow+=`[${this._nullCellCount}C`,this._nullCellCount=0),this._lastContentCursorRow=this._lastCursorRow=s,this._lastContentCursorCol=this._lastCursorCol=r,this._currentRow+=`[${i.join(";")}m`;const e=this._buffer.getLine(s);void 0!==e&&(e.getCell(r,this._cursorStyle),this._cursorStyleRow=s,this._cursorStyleCol=r)}o?this._nullCellCount+=e.getWidth():(this._nullCellCount>0&&(a(this._cursorStyle,this._backgroundCell)||(this._currentRow+=`[${this._nullCellCount}X`),this._currentRow+=`[${this._nullCellCount}C`,this._nullCellCount=0),this._currentRow+=e.getChars(),this._lastContentCursorRow=this._lastCursorRow=s,this._lastContentCursorCol=this._lastCursorCol=r+e.getWidth())}_serializeString(e){let t=this._allRows.length;this._buffer.length-this._firstRow<=this._terminal.rows&&(t=this._lastContentCursorRow+1-this._firstRow,this._lastCursorCol=this._lastContentCursorCol,this._lastCursorRow=this._lastContentCursorRow);let s="";for(let e=0;e<t;e++)s+=this._allRows[e],e+1<t&&(s+=this._allRowSeparators[e]);if(!e){const e=this._buffer.baseY+this._buffer.cursorY,t=this._buffer.cursorX,o=e=>{e>0?s+=`[${e}C`:e<0&&(s+=`[${-e}D`)};(e!==this._lastCursorRow||t!==this._lastCursorCol)&&((r=e-this._lastCursorRow)>0?s+=`[${r}B`:r<0&&(s+=`[${-r}A`),o(t-this._lastCursorCol))}var r;const o=this._terminal._core._inputHandler._curAttrData,i=this._diffStyle(o,this._cursorStyle);return i.length>0&&(s+=`[${i.join(";")}m`),s}}e.SerializeAddon=class{activate(e){this._terminal=e}_serializeBufferByScrollback(e,t,s){const r=t.length,i=void 0===s?r:o(s+e.rows,0,r);return this._serializeBufferByRange(e,t,{start:r-i,end:r-1},!1)}_serializeBufferByRange(e,t,s,r){return new c(t,e).serialize({start:{x:0,y:"number"==typeof s.start?s.start:s.start.line},end:{x:e.cols,y:"number"==typeof s.end?s.end:s.end.line}},r)}_serializeBufferAsHTML(e,t){const s=e.buffer.active,r=new h(s,e,t);if(!t.onlySelection){const i=s.length,n=t.scrollback,a=void 0===n?i:o(n+e.rows,0,i);return r.serialize({start:{x:0,y:i-a},end:{x:e.cols,y:i-1}})}const i=this._terminal?.getSelectionPosition();return void 0!==i?r.serialize({start:{x:i.start.x,y:i.start.y},end:{x:i.end.x,y:i.end.y}}):""}_serializeModes(e){let t="";const s=e.modes;if(s.applicationCursorKeysMode&&(t+="[?1h"),s.applicationKeypadMode&&(t+="[?66h"),s.bracketedPasteMode&&(t+="[?2004h"),s.insertMode&&(t+="[4h"),s.originMode&&(t+="[?6h"),s.reverseWraparoundMode&&(t+="[?45h"),s.sendFocusMode&&(t+="[?1004h"),!1===s.wraparoundMode&&(t+="[?7l"),"none"!==s.mouseTrackingMode)switch(s.mouseTrackingMode){case"x10":t+="[?9h";break;case"vt200":t+="[?1000h";break;case"drag":t+="[?1002h";break;case"any":t+="[?1003h"}return t}serialize(e){if(!this._terminal)throw new Error("Cannot use addon until it has been loaded");let t=e?.range?this._serializeBufferByRange(this._terminal,this._terminal.buffer.normal,e.range,!0):this._serializeBufferByScrollback(this._terminal,this._terminal.buffer.normal,e?.scrollback);return e?.excludeAltBuffer||"alternate"!==this._terminal.buffer.active.type||(t+=`[?1049h[H${this._serializeBufferByScrollback(this._terminal,this._terminal.buffer.alternate,void 0)}`),e?.excludeModes||(t+=this._serializeModes(this._terminal)),t}serializeAsHTML(e){if(!this._terminal)throw new Error("Cannot use addon until it has been loaded");return this._serializeBufferAsHTML(this._terminal,e||{})}dispose(){}};class h extends i{constructor(e,s,r){super(e),this._terminal=s,this._options=r,this._currentRow="",this._htmlContent="",s._core._themeService?this._ansiColors=s._core._themeService.colors.ansi:this._ansiColors=t.DEFAULT_ANSI_COLORS}_padStart(e,t,s){return t>>=0,s=s??" ",e.length>t?e:((t-=e.length)>s.length&&(s+=s.repeat(t/s.length)),s.slice(0,t)+e)}_beforeSerialize(e,t,s){this._htmlContent+="<html><body>\x3c!--StartFragment--\x3e<pre>";let r="#000000",o="#ffffff";this._options.includeGlobalBackground&&(r=this._terminal.options.theme?.foreground??"#ffffff",o=this._terminal.options.theme?.background??"#000000");const i=[];i.push("color: "+r+";"),i.push("background-color: "+o+";"),i.push("font-family: "+this._terminal.options.fontFamily+";"),i.push("font-size: "+this._terminal.options.fontSize+"px;"),this._htmlContent+="<div style='"+i.join(" ")+"'>"}_afterSerialize(){this._htmlContent+="</div>",this._htmlContent+="</pre>\x3c!--EndFragment--\x3e</body></html>"}_rowEnd(e,t){this._htmlContent+="<div><span>"+this._currentRow+"</span></div>",this._currentRow=""}_getHexColor(e,t){const s=t?e.getFgColor():e.getBgColor();return(t?e.isFgRGB():e.isBgRGB())?"#"+[s>>16&255,s>>8&255,255&s].map((e=>this._padStart(e.toString(16),2,"0"))).join(""):(t?e.isFgPalette():e.isBgPalette())?this._ansiColors[s].css:void 0}_diffStyle(e,t){const s=[],r=!n(e,t),o=!a(e,t),i=!l(e,t);if(r||o||i){const t=this._getHexColor(e,!0);t&&s.push("color: "+t+";");const r=this._getHexColor(e,!1);return r&&s.push("background-color: "+r+";"),e.isInverse()&&s.push("color: #000000; background-color: #BFBFBF;"),e.isBold()&&s.push("font-weight: bold;"),e.isUnderline()&&e.isOverline()?s.push("text-decoration: overline underline;"):e.isUnderline()?s.push("text-decoration: underline;"):e.isOverline()&&s.push("text-decoration: overline;"),e.isBlink()&&s.push("text-decoration: blink;"),e.isInvisible()&&s.push("visibility: hidden;"),e.isItalic()&&s.push("font-style: italic;"),e.isDim()&&s.push("opacity: 0.5;"),e.isStrikethrough()&&s.push("text-decoration: line-through;"),s}}_nextCell(e,t,s,r){if(0===e.getWidth())return;const o=""===e.getChars(),i=this._diffStyle(e,t);i&&(this._currentRow+=0===i.length?"</span><span>":"</span><span style='"+i.join(" ")+"'>"),this._currentRow+=o?" ":function(e){switch(e){case"&":return"&";case"<":return"<"}return e}(e.getChars())}_serializeString(){return this._htmlContent}}e.HTMLSerializeHandler=h})(),r})())); | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.SerializeAddon=e():t.SerializeAddon=e()}(globalThis,(()=>(()=>{"use strict";var t={920:(t,e,s)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.DEFAULT_ANSI_COLORS=void 0;const r=s(160);e.DEFAULT_ANSI_COLORS=Object.freeze((()=>{const t=[r.css.toColor("#2e3436"),r.css.toColor("#cc0000"),r.css.toColor("#4e9a06"),r.css.toColor("#c4a000"),r.css.toColor("#3465a4"),r.css.toColor("#75507b"),r.css.toColor("#06989a"),r.css.toColor("#d3d7cf"),r.css.toColor("#555753"),r.css.toColor("#ef2929"),r.css.toColor("#8ae234"),r.css.toColor("#fce94f"),r.css.toColor("#729fcf"),r.css.toColor("#ad7fa8"),r.css.toColor("#34e2e2"),r.css.toColor("#eeeeec")],e=[0,95,135,175,215,255];for(let s=0;s<216;s++){const i=e[s/36%6|0],o=e[s/6%6|0],n=e[s%6];t.push({css:r.channels.toCss(i,o,n),rgba:r.channels.toRgba(i,o,n)})}for(let e=0;e<24;e++){const s=8+10*e;t.push({css:r.channels.toCss(s,s,s),rgba:r.channels.toRgba(s,s,s)})}return t})())},160:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.rgba=e.rgb=e.css=e.color=e.channels=e.NULL_COLOR=void 0,e.toPaddedHex=c,e.contrastRatio=_;let s=0,r=0,i=0,o=0;var n,l,a,u,h;function c(t){const e=t.toString(16);return e.length<2?"0"+e:e}function _(t,e){return t<e?(e+.05)/(t+.05):(t+.05)/(e+.05)}e.NULL_COLOR={css:"#00000000",rgba:0},function(t){t.toCss=function(t,e,s,r){return void 0!==r?`#${c(t)}${c(e)}${c(s)}${c(r)}`:`#${c(t)}${c(e)}${c(s)}`},t.toRgba=function(t,e,s,r=255){return(t<<24|e<<16|s<<8|r)>>>0},t.toColor=function(e,s,r,i){return{css:t.toCss(e,s,r,i),rgba:t.toRgba(e,s,r,i)}}}(n||(e.channels=n={})),function(t){function e(t,e){return o=Math.round(255*e),[s,r,i]=h.toChannels(t.rgba),{css:n.toCss(s,r,i,o),rgba:n.toRgba(s,r,i,o)}}t.blend=function(t,e){if(o=(255&e.rgba)/255,1===o)return{css:e.css,rgba:e.rgba};const l=e.rgba>>24&255,a=e.rgba>>16&255,u=e.rgba>>8&255,h=t.rgba>>24&255,c=t.rgba>>16&255,_=t.rgba>>8&255;return s=h+Math.round((l-h)*o),r=c+Math.round((a-c)*o),i=_+Math.round((u-_)*o),{css:n.toCss(s,r,i),rgba:n.toRgba(s,r,i)}},t.isOpaque=function(t){return 255==(255&t.rgba)},t.ensureContrastRatio=function(t,e,s){const r=h.ensureContrastRatio(t.rgba,e.rgba,s);if(r)return n.toColor(r>>24&255,r>>16&255,r>>8&255)},t.opaque=function(t){const e=(255|t.rgba)>>>0;return[s,r,i]=h.toChannels(e),{css:n.toCss(s,r,i),rgba:e}},t.opacity=e,t.multiplyOpacity=function(t,s){return o=255&t.rgba,e(t,o*s/255)},t.toColorRGB=function(t){return[t.rgba>>24&255,t.rgba>>16&255,t.rgba>>8&255]}}(l||(e.color=l={})),function(t){let e,l;try{const t=document.createElement("canvas");t.width=1,t.height=1;const s=t.getContext("2d",{willReadFrequently:!0});s&&(e=s,e.globalCompositeOperation="copy",l=e.createLinearGradient(0,0,1,1))}catch{}t.toColor=function(t){if(t.match(/#[\da-f]{3,8}/i))switch(t.length){case 4:return s=parseInt(t.slice(1,2).repeat(2),16),r=parseInt(t.slice(2,3).repeat(2),16),i=parseInt(t.slice(3,4).repeat(2),16),n.toColor(s,r,i);case 5:return s=parseInt(t.slice(1,2).repeat(2),16),r=parseInt(t.slice(2,3).repeat(2),16),i=parseInt(t.slice(3,4).repeat(2),16),o=parseInt(t.slice(4,5).repeat(2),16),n.toColor(s,r,i,o);case 7:return{css:t,rgba:(parseInt(t.slice(1),16)<<8|255)>>>0};case 9:return{css:t,rgba:parseInt(t.slice(1),16)>>>0}}const a=t.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(a)return s=parseInt(a[1]),r=parseInt(a[2]),i=parseInt(a[3]),o=Math.round(255*(void 0===a[5]?1:parseFloat(a[5]))),n.toColor(s,r,i,o);if(!e||!l)throw new Error("css.toColor: Unsupported css format");if(e.fillStyle=l,e.fillStyle=t,"string"!=typeof e.fillStyle)throw new Error("css.toColor: Unsupported css format");if(e.fillRect(0,0,1,1),[s,r,i,o]=e.getImageData(0,0,1,1).data,255!==o)throw new Error("css.toColor: Unsupported css format");return{rgba:n.toRgba(s,r,i,o),css:t}}}(a||(e.css=a={})),function(t){function e(t,e,s){const r=t/255,i=e/255,o=s/255;return.2126*(r<=.03928?r/12.92:Math.pow((r+.055)/1.055,2.4))+.7152*(i<=.03928?i/12.92:Math.pow((i+.055)/1.055,2.4))+.0722*(o<=.03928?o/12.92:Math.pow((o+.055)/1.055,2.4))}t.relativeLuminance=function(t){return e(t>>16&255,t>>8&255,255&t)},t.relativeLuminance2=e}(u||(e.rgb=u={})),function(t){function e(t,e,s){const r=t>>24&255,i=t>>16&255,o=t>>8&255;let n=e>>24&255,l=e>>16&255,a=e>>8&255,h=_(u.relativeLuminance2(n,l,a),u.relativeLuminance2(r,i,o));for(;h<s&&(n>0||l>0||a>0);)n-=Math.max(0,Math.ceil(.1*n)),l-=Math.max(0,Math.ceil(.1*l)),a-=Math.max(0,Math.ceil(.1*a)),h=_(u.relativeLuminance2(n,l,a),u.relativeLuminance2(r,i,o));return(n<<24|l<<16|a<<8|255)>>>0}function l(t,e,s){const r=t>>24&255,i=t>>16&255,o=t>>8&255;let n=e>>24&255,l=e>>16&255,a=e>>8&255,h=_(u.relativeLuminance2(n,l,a),u.relativeLuminance2(r,i,o));for(;h<s&&(n<255||l<255||a<255);)n=Math.min(255,n+Math.ceil(.1*(255-n))),l=Math.min(255,l+Math.ceil(.1*(255-l))),a=Math.min(255,a+Math.ceil(.1*(255-a))),h=_(u.relativeLuminance2(n,l,a),u.relativeLuminance2(r,i,o));return(n<<24|l<<16|a<<8|255)>>>0}t.blend=function(t,e){if(o=(255&e)/255,1===o)return e;const l=e>>24&255,a=e>>16&255,u=e>>8&255,h=t>>24&255,c=t>>16&255,_=t>>8&255;return s=h+Math.round((l-h)*o),r=c+Math.round((a-c)*o),i=_+Math.round((u-_)*o),n.toRgba(s,r,i)},t.ensureContrastRatio=function(t,s,r){const i=u.relativeLuminance(t>>8),o=u.relativeLuminance(s>>8);if(_(i,o)<r){if(o<i){const o=e(t,s,r),n=_(i,u.relativeLuminance(o>>8));if(n<r){const e=l(t,s,r);return n>_(i,u.relativeLuminance(e>>8))?o:e}return o}const n=l(t,s,r),a=_(i,u.relativeLuminance(n>>8));if(a<r){const o=e(t,s,r);return a>_(i,u.relativeLuminance(o>>8))?n:o}return n}},t.reduceLuminance=e,t.increaseLuminance=l,t.toChannels=function(t){return[t>>24&255,t>>16&255,t>>8&255,255&t]}}(h||(e.rgba=h={}))}},e={};function s(r){var i=e[r];if(void 0!==i)return i.exports;var o=e[r]={exports:{}};return t[r](o,o.exports,s),o.exports}var r={};return(()=>{var t=r;Object.defineProperty(t,"__esModule",{value:!0}),t.HTMLSerializeHandler=t.SerializeAddon=void 0;const e=s(920);function i(t,e,s){return Math.max(e,Math.min(t,s))}class o{constructor(t){this._buffer=t}serialize(t,e){const s=this._buffer.getNullCell(),r=this._buffer.getNullCell();let i=s;const o=t.start.y,n=t.end.y,l=t.start.x,a=t.end.x;this._beforeSerialize(n-o,o,n);for(let e=o;e<=n;e++){const o=this._buffer.getLine(e);if(o){const n=e===t.start.y?l:0,u=e===t.end.y?a:o.length;for(let t=n;t<u;t++){const n=o.getCell(t,i===s?r:s);n?(this._nextCell(n,i,e,t),i=n):console.warn(`Can't get cell at row=${e}, col=${t}`)}}this._rowEnd(e,e===n)}return this._afterSerialize(),this._serializeString(e)}_nextCell(t,e,s,r){}_rowEnd(t,e){}_beforeSerialize(t,e,s){}_afterSerialize(){}_serializeString(t){return""}}function n(t,e){return t.getFgColorMode()===e.getFgColorMode()&&t.getFgColor()===e.getFgColor()}function l(t,e){return t.getBgColorMode()===e.getBgColorMode()&&t.getBgColor()===e.getBgColor()}function a(t,e){return t.isInverse()===e.isInverse()&&t.isBold()===e.isBold()&&t.isUnderline()===e.isUnderline()&&t.isOverline()===e.isOverline()&&t.isBlink()===e.isBlink()&&t.isInvisible()===e.isInvisible()&&t.isItalic()===e.isItalic()&&t.isDim()===e.isDim()&&t.isStrikethrough()===e.isStrikethrough()}class u extends o{constructor(t,e){super(t),this._terminal=e,this._rowIndex=0,this._allRows=new Array,this._allRowSeparators=new Array,this._currentRow="",this._nullCellCount=0,this._cursorStyle=this._buffer.getNullCell(),this._cursorStyleRow=0,this._cursorStyleCol=0,this._backgroundCell=this._buffer.getNullCell(),this._firstRow=0,this._lastCursorRow=0,this._lastCursorCol=0,this._lastContentCursorRow=0,this._lastContentCursorCol=0,this._thisRowLastChar=this._buffer.getNullCell(),this._thisRowLastSecondChar=this._buffer.getNullCell(),this._nextRowFirstChar=this._buffer.getNullCell()}_beforeSerialize(t,e,s){this._allRows=new Array(t),this._lastContentCursorRow=e,this._lastCursorRow=e,this._firstRow=e}_rowEnd(t,e){this._nullCellCount>0&&!l(this._cursorStyle,this._backgroundCell)&&(this._currentRow+=`[${this._nullCellCount}X`);let s="";if(!e){t-this._firstRow>=this._terminal.rows&&this._buffer.getLine(this._cursorStyleRow)?.getCell(this._cursorStyleCol,this._backgroundCell);const e=this._buffer.getLine(t),r=this._buffer.getLine(t+1);if(r.isWrapped){s="";const i=e.getCell(e.length-1,this._thisRowLastChar),o=e.getCell(e.length-2,this._thisRowLastSecondChar),n=r.getCell(0,this._nextRowFirstChar),a=n.getWidth()>1;let u=!1;(n.getChars()&&a?this._nullCellCount<=1:this._nullCellCount<=0)&&((i.getChars()||0===i.getWidth())&&l(i,n)&&(u=!0),a&&(o.getChars()||0===o.getWidth())&&l(i,n)&&l(o,n)&&(u=!0)),u||(s="-".repeat(this._nullCellCount+1),s+="[1D[1X",this._nullCellCount>0&&(s+="[A",s+=`[${e.length-this._nullCellCount}C`,s+=`[${this._nullCellCount}X`,s+=`[${e.length-this._nullCellCount}D`,s+="[B"),this._lastContentCursorRow=t+1,this._lastContentCursorCol=0,this._lastCursorRow=t+1,this._lastCursorCol=0)}else s="\r\n",this._lastCursorRow=t+1,this._lastCursorCol=0}this._allRows[this._rowIndex]=this._currentRow,this._allRowSeparators[this._rowIndex++]=s,this._currentRow="",this._nullCellCount=0}_diffStyle(t,e){const s=[],r=!n(t,e),i=!l(t,e),o=!a(t,e);if(r||i||o)if(t.isAttributeDefault())e.isAttributeDefault()||s.push(0);else{if(r){const e=t.getFgColor();t.isFgRGB()?s.push(38,2,e>>>16&255,e>>>8&255,255&e):t.isFgPalette()?e>=16?s.push(38,5,e):s.push(8&e?90+(7&e):30+(7&e)):s.push(39)}if(i){const e=t.getBgColor();t.isBgRGB()?s.push(48,2,e>>>16&255,e>>>8&255,255&e):t.isBgPalette()?e>=16?s.push(48,5,e):s.push(8&e?100+(7&e):40+(7&e)):s.push(49)}o&&(t.isInverse()!==e.isInverse()&&s.push(t.isInverse()?7:27),t.isBold()!==e.isBold()&&s.push(t.isBold()?1:22),t.isUnderline()!==e.isUnderline()&&s.push(t.isUnderline()?4:24),t.isOverline()!==e.isOverline()&&s.push(t.isOverline()?53:55),t.isBlink()!==e.isBlink()&&s.push(t.isBlink()?5:25),t.isInvisible()!==e.isInvisible()&&s.push(t.isInvisible()?8:28),t.isItalic()!==e.isItalic()&&s.push(t.isItalic()?3:23),t.isDim()!==e.isDim()&&s.push(t.isDim()?2:22),t.isStrikethrough()!==e.isStrikethrough()&&s.push(t.isStrikethrough()?9:29))}return s}_nextCell(t,e,s,r){if(0===t.getWidth())return;const i=""===t.getChars(),o=this._diffStyle(t,this._cursorStyle);if(i?!l(this._cursorStyle,t):o.length>0){this._nullCellCount>0&&(l(this._cursorStyle,this._backgroundCell)||(this._currentRow+=`[${this._nullCellCount}X`),this._currentRow+=`[${this._nullCellCount}C`,this._nullCellCount=0),this._lastContentCursorRow=this._lastCursorRow=s,this._lastContentCursorCol=this._lastCursorCol=r,this._currentRow+=`[${o.join(";")}m`;const t=this._buffer.getLine(s);void 0!==t&&(t.getCell(r,this._cursorStyle),this._cursorStyleRow=s,this._cursorStyleCol=r)}i?this._nullCellCount+=t.getWidth():(this._nullCellCount>0&&(l(this._cursorStyle,this._backgroundCell)||(this._currentRow+=`[${this._nullCellCount}X`),this._currentRow+=`[${this._nullCellCount}C`,this._nullCellCount=0),this._currentRow+=t.getChars(),this._lastContentCursorRow=this._lastCursorRow=s,this._lastContentCursorCol=this._lastCursorCol=r+t.getWidth())}_serializeString(t){let e=this._allRows.length;this._buffer.length-this._firstRow<=this._terminal.rows&&(e=this._lastContentCursorRow+1-this._firstRow,this._lastCursorCol=this._lastContentCursorCol,this._lastCursorRow=this._lastContentCursorRow);let s="";for(let t=0;t<e;t++)s+=this._allRows[t],t+1<e&&(s+=this._allRowSeparators[t]);if(!t){const t=this._buffer.baseY+this._buffer.cursorY,e=this._buffer.cursorX,i=t=>{t>0?s+=`[${t}C`:t<0&&(s+=`[${-t}D`)};(t!==this._lastCursorRow||e!==this._lastCursorCol)&&((r=t-this._lastCursorRow)>0?s+=`[${r}B`:r<0&&(s+=`[${-r}A`),i(e-this._lastCursorCol))}var r;const i=this._terminal._core._inputHandler._curAttrData,o=this._diffStyle(i,this._cursorStyle);return o.length>0&&(s+=`[${o.join(";")}m`),s}}t.SerializeAddon=class{activate(t){this._terminal=t}_serializeBufferByScrollback(t,e,s){const r=e.length,o=void 0===s?r:i(s+t.rows,0,r);return this._serializeBufferByRange(t,e,{start:r-o,end:r-1},!1)}_serializeBufferByRange(t,e,s,r){return new u(e,t).serialize({start:{x:0,y:"number"==typeof s.start?s.start:s.start.line},end:{x:t.cols,y:"number"==typeof s.end?s.end:s.end.line}},r)}_serializeBufferAsHTML(t,e){const s=t.buffer.active,r=new h(s,t,e);if(!e.onlySelection){const o=s.length,n=e.scrollback,l=void 0===n?o:i(n+t.rows,0,o);return r.serialize({start:{x:0,y:o-l},end:{x:t.cols,y:o-1}})}const o=this._terminal?.getSelectionPosition();return void 0!==o?r.serialize({start:{x:o.start.x,y:o.start.y},end:{x:o.end.x,y:o.end.y}}):""}_serializeModes(t){let e="";const s=t.modes;if(s.applicationCursorKeysMode&&(e+="[?1h"),s.applicationKeypadMode&&(e+="[?66h"),s.bracketedPasteMode&&(e+="[?2004h"),s.insertMode&&(e+="[4h"),s.originMode&&(e+="[?6h"),s.reverseWraparoundMode&&(e+="[?45h"),s.sendFocusMode&&(e+="[?1004h"),!1===s.wraparoundMode&&(e+="[?7l"),"none"!==s.mouseTrackingMode)switch(s.mouseTrackingMode){case"x10":e+="[?9h";break;case"vt200":e+="[?1000h";break;case"drag":e+="[?1002h";break;case"any":e+="[?1003h"}return e}serialize(t){if(!this._terminal)throw new Error("Cannot use addon until it has been loaded");let e=t?.range?this._serializeBufferByRange(this._terminal,this._terminal.buffer.normal,t.range,!0):this._serializeBufferByScrollback(this._terminal,this._terminal.buffer.normal,t?.scrollback);return t?.excludeAltBuffer||"alternate"!==this._terminal.buffer.active.type||(e+=`[?1049h[H${this._serializeBufferByScrollback(this._terminal,this._terminal.buffer.alternate,void 0)}`),t?.excludeModes||(e+=this._serializeModes(this._terminal)),e}serializeAsHTML(t){if(!this._terminal)throw new Error("Cannot use addon until it has been loaded");return this._serializeBufferAsHTML(this._terminal,t||{})}dispose(){}};class h extends o{constructor(t,s,r){super(t),this._terminal=s,this._options=r,this._currentRow="",this._htmlContent="",s._core._themeService?this._ansiColors=s._core._themeService.colors.ansi:this._ansiColors=e.DEFAULT_ANSI_COLORS}_padStart(t,e,s){return e>>=0,s=s??" ",t.length>e?t:((e-=t.length)>s.length&&(s+=s.repeat(e/s.length)),s.slice(0,e)+t)}_beforeSerialize(t,e,s){this._htmlContent+="<html><body>\x3c!--StartFragment--\x3e<pre>";let r="#000000",i="#ffffff";this._options.includeGlobalBackground&&(r=this._terminal.options.theme?.foreground??"#ffffff",i=this._terminal.options.theme?.background??"#000000");const o=[];o.push("color: "+r+";"),o.push("background-color: "+i+";"),o.push("font-family: "+this._terminal.options.fontFamily+";"),o.push("font-size: "+this._terminal.options.fontSize+"px;"),this._htmlContent+="<div style='"+o.join(" ")+"'>"}_afterSerialize(){this._htmlContent+="</div>",this._htmlContent+="</pre>\x3c!--EndFragment--\x3e</body></html>"}_rowEnd(t,e){this._htmlContent+="<div><span>"+this._currentRow+"</span></div>",this._currentRow=""}_getHexColor(t,e){const s=e?t.getFgColor():t.getBgColor();return(e?t.isFgRGB():t.isBgRGB())?"#"+[s>>16&255,s>>8&255,255&s].map((t=>this._padStart(t.toString(16),2,"0"))).join(""):(e?t.isFgPalette():t.isBgPalette())?this._ansiColors[s].css:void 0}_diffStyle(t,e){const s=[],r=!n(t,e),i=!l(t,e),o=!a(t,e);if(r||i||o){const e=this._getHexColor(t,!0);e&&s.push("color: "+e+";");const r=this._getHexColor(t,!1);return r&&s.push("background-color: "+r+";"),t.isInverse()&&s.push("color: #000000; background-color: #BFBFBF;"),t.isBold()&&s.push("font-weight: bold;"),t.isUnderline()&&t.isOverline()?s.push("text-decoration: overline underline;"):t.isUnderline()?s.push("text-decoration: underline;"):t.isOverline()&&s.push("text-decoration: overline;"),t.isBlink()&&s.push("text-decoration: blink;"),t.isInvisible()&&s.push("visibility: hidden;"),t.isItalic()&&s.push("font-style: italic;"),t.isDim()&&s.push("opacity: 0.5;"),t.isStrikethrough()&&s.push("text-decoration: line-through;"),s}}_nextCell(t,e,s,r){if(0===t.getWidth())return;const i=""===t.getChars(),o=this._diffStyle(t,e);o&&(this._currentRow+=0===o.length?"</span><span>":"</span><span style='"+o.join(" ")+"'>"),this._currentRow+=i?" ":function(t){switch(t){case"&":return"&";case"<":return"<"}return t}(t.getChars())}_serializeString(){return this._htmlContent}}t.HTMLSerializeHandler=h})(),r})())); | ||
//# sourceMappingURL=addon-serialize.js.map |
{ | ||
"name": "@xterm/addon-serialize", | ||
"version": "0.14.0-beta.39", | ||
"version": "0.14.0-beta.40", | ||
"author": { | ||
@@ -9,2 +9,3 @@ "name": "The xterm.js authors", | ||
"main": "lib/addon-serialize.js", | ||
"module": "lib/addon-serialize.mjs", | ||
"types": "typings/addon-serialize.d.ts", | ||
@@ -23,3 +24,3 @@ "repository": "https://github.com/xtermjs/xterm.js/tree/master/addons/addon-serialize", | ||
"prepublishOnly": "npm run package", | ||
"start-server-only": "node ../../demo/start-server-only", | ||
"start": "node ../../demo/start", | ||
"benchmark": "NODE_PATH=../../out:./out:./out-benchmark/ ../../node_modules/.bin/xterm-benchmark -r 5 -c benchmark/benchmark.json", | ||
@@ -26,0 +27,0 @@ "benchmark-baseline": "NODE_PATH=../../out:./out:./out-benchmark/ ../../node_modules/.bin/xterm-benchmark -r 5 -c benchmark/benchmark.json --baseline out-benchmark/benchmark/*benchmark.js", |
@@ -10,4 +10,4 @@ /** | ||
import type { IHTMLSerializeOptions, SerializeAddon as ISerializeApi, ISerializeOptions, ISerializeRange } from '@xterm/addon-serialize'; | ||
import { DEFAULT_ANSI_COLORS } from 'browser/services/ThemeService'; | ||
import { IAttributeData, IColor } from 'common/Types'; | ||
import { DEFAULT_ANSI_COLORS } from 'browser/Types'; | ||
@@ -14,0 +14,0 @@ function constrain(value: number, low: number, high: number): number { |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
203177
8
812