From ae70ef0fa2855aa5fa0ba0f6c293460f8c3822f7 Mon Sep 17 00:00:00 2001 From: javacs3 Date: Sun, 25 Aug 2019 22:34:20 +0800 Subject: [PATCH] resolve SerializeAddon importing workaround --- .../src/SerializeAddon.ts | 25 +------------------ src/public/Terminal.ts | 15 ++++++++++- typings/xterm.d.ts | 16 ++++++------ 3 files changed, 23 insertions(+), 33 deletions(-) diff --git a/addons/xterm-addon-serialize/src/SerializeAddon.ts b/addons/xterm-addon-serialize/src/SerializeAddon.ts index b5d6e08d..b8b57b6b 100644 --- a/addons/xterm-addon-serialize/src/SerializeAddon.ts +++ b/addons/xterm-addon-serialize/src/SerializeAddon.ts @@ -3,30 +3,7 @@ * @license MIT */ -import { Terminal, ITerminalAddon, IBuffer, IBufferCell, CellColor } from 'xterm'; - -// TODO: Workaround here, will remove this later -// If I use `import { CellStyle } from 'xterm'` instead, demo page will raise bellow error -// -// ERROR in ./addons/xterm-addon-serialize/out/SerializeAddon.js -// Module not found: Error: Can't resolve 'xterm' in '/Users/javacs3/Lab/Playground/xterm.js/addons/xterm-addon-serialize/out' -// @ ./addons/xterm-addon-serialize/out/SerializeAddon.js 16:14-30 -// @ ./demo/client.ts -// -// Looks like typescript generate this line `var xterm_1 = require("xterm");` that leads to the error; -// -enum CellStyle { - default = 0, - // foreground style - inverse = 0x4000000 >>> 24, - bold = 0x8000000 >>> 24, - underline = 0x10000000 >>> 24, - blink = 0x20000000 >>> 24, - invisible = 0x40000000 >>> 24, - // background style - italic = 0x4000000 >>> 16, - dim = 0x8000000 >>> 16 -} +import { Terminal, ITerminalAddon, IBuffer, IBufferCell, CellColor, CellStyle } from 'xterm'; function crop(value: number | undefined, low: number, high: number, initial: number): number { if (value === undefined) { diff --git a/src/public/Terminal.ts b/src/public/Terminal.ts index 28758642..baae367c 100644 --- a/src/public/Terminal.ts +++ b/src/public/Terminal.ts @@ -3,7 +3,7 @@ * @license MIT */ -import { Terminal as ITerminalApi, ITerminalOptions, IMarker, IDisposable, ILinkMatcherOptions, ITheme, ILocalizableStrings, ITerminalAddon, ISelectionPosition, IBuffer as IBufferApi, IBufferLine as IBufferLineApi, IBufferCell as IBufferCellApi, CellColor as ICellColorApi, CellStyle } from 'xterm'; +import { Terminal as ITerminalApi, ITerminalOptions, IMarker, IDisposable, ILinkMatcherOptions, ITheme, ILocalizableStrings, ITerminalAddon, ISelectionPosition, IBuffer as IBufferApi, IBufferLine as IBufferLineApi, IBufferCell as IBufferCellApi, CellColor as ICellColorApi } from 'xterm'; import { ITerminal } from '../Types'; import { IBufferLine, ICellData } from 'common/Types'; import { IBuffer } from 'common/buffer/Types'; @@ -221,6 +221,19 @@ class BufferLineApiView implements IBufferLineApi { } } +export enum CellStyle { + default = 0, + // foreground style + inverse = 0x4000000 >>> 24, + bold = 0x8000000 >>> 24, + underline = 0x10000000 >>> 24, + blink = 0x20000000 >>> 24, + invisible = 0x40000000 >>> 24, + // background style + italic = 0x4000000 >>> 16, + dim = 0x8000000 >>> 16 +} + const COLOR_MASK = Attributes.CM_MASK | Attributes.RGB_MASK; export class CellColor implements ICellColorApi { diff --git a/typings/xterm.d.ts b/typings/xterm.d.ts index ae11a8f1..6fcc1e53 100644 --- a/typings/xterm.d.ts +++ b/typings/xterm.d.ts @@ -958,16 +958,16 @@ declare module 'xterm' { } export enum CellStyle { - default = 0, + default, // foreground style - inverse = 0x4000000 >>> 24, - bold = 0x8000000 >>> 24, - underline = 0x10000000 >>> 24, - blink = 0x20000000 >>> 24, - invisible = 0x40000000 >>> 24, + inverse, + bold, + underline, + blink, + invisible, // background style - italic = 0x4000000 >>> 16, - dim = 0x8000000 >>> 16 + italic, + dim } export class CellColor {