From b64cc0a9de04771df5c499c571682ac8e55c914d Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Sat, 18 May 2019 19:16:06 -0700 Subject: [PATCH] Fix ui project build --- src/ui/ColorManager.ts | 13 ++++++++----- src/ui/Types.ts | 24 ++++++++++++++++++++++++ src/ui/tsconfig.json | 8 ++------ 3 files changed, 34 insertions(+), 11 deletions(-) diff --git a/src/ui/ColorManager.ts b/src/ui/ColorManager.ts index 6d68c58d1..923b28234 100644 --- a/src/ui/ColorManager.ts +++ b/src/ui/ColorManager.ts @@ -3,8 +3,7 @@ * @license MIT */ -import { IColorManager, IColor, IColorSet } from './Types'; -import { ITheme } from 'xterm'; +import { IColorManager, IColor, IColorSet, ITheme } from './Types'; const DEFAULT_FOREGROUND = fromHex('#ffffff'); const DEFAULT_BACKGROUND = fromHex('#000000'); @@ -90,7 +89,11 @@ export class ColorManager implements IColorManager { const canvas = document.createElement('canvas'); canvas.width = 1; canvas.height = 1; - this._ctx = canvas.getContext('2d'); + const ctx = canvas.getContext('2d'); + if (!ctx) { + throw new Error('Could not get rendering context'); + } + this._ctx = ctx; this._ctx.globalCompositeOperation = 'copy'; this._litmusColor = this._ctx.createLinearGradient(0, 0, 1, 1); this.colors = { @@ -133,11 +136,11 @@ export class ColorManager implements IColorManager { } private _parseColor( - css: string, + css: string | undefined, fallback: IColor, allowTransparency: boolean = this.allowTransparency ): IColor { - if (!css) { + if (css === undefined) { return fallback; } diff --git a/src/ui/Types.ts b/src/ui/Types.ts index ef725ba6e..b7b0ac215 100644 --- a/src/ui/Types.ts +++ b/src/ui/Types.ts @@ -20,3 +20,27 @@ export interface IColorSet { selection: IColor; ansi: IColor[]; } + +export interface ITheme { + foreground?: string; + background?: string; + cursor?: string; + cursorAccent?: string; + selection?: string; + black?: string; + red?: string; + green?: string; + yellow?: string; + blue?: string; + magenta?: string; + cyan?: string; + white?: string; + brightBlack?: string; + brightRed?: string; + brightGreen?: string; + brightYellow?: string; + brightBlue?: string; + brightMagenta?: string; + brightCyan?: string; + brightWhite?: string; +} diff --git a/src/ui/tsconfig.json b/src/ui/tsconfig.json index b3613eeff..e07bd9c34 100644 --- a/src/ui/tsconfig.json +++ b/src/ui/tsconfig.json @@ -10,12 +10,8 @@ "../../node_modules/@types/mocha" ] }, - "include": [ - "./Lifecycle.ts", - "./RenderDebouncer.ts", - "./ScreenDprMonitor.ts" - ], + "include": [ "./**/*" ], "references": [ { "path": "../common" } ] -} \ No newline at end of file +}