diff --git a/gulpfile.js b/gulpfile.js index af4fdce0..8fe5bf9c 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -20,7 +20,7 @@ const webpack = require('webpack-stream'); const buildDir = process.env.BUILD_DIR || 'build'; const tsProject = ts.createProject('tsconfig.json'); -const srcDir = tsProject.config.compilerOptions.rootDir; +let srcDir = tsProject.config.compilerOptions.rootDir; let outDir = tsProject.config.compilerOptions.outDir; const addons = fs.readdirSync(`${__dirname}/src/addons`); @@ -31,58 +31,19 @@ if (path.normalize(outDir).indexOf(__dirname) !== 0) { outDir = `${__dirname}/${path.normalize(outDir)}`; } -/** - * Compile TypeScript sources to JavaScript files and create a source map file for each TypeScript - * file compiled. - */ -gulp.task('tsc', function () { - // Remove the ${outDir}/ directory to prevent confusion if files were deleted in ${srcDir}/ - fs.emptyDirSync(`${outDir}`); +gulp.task('css', function() { + return gulp.src(`${srcDir}/**/*.css`).pipe(gulp.dest(outDir)); +}); - // Build all TypeScript files (including tests) to ${outDir}/, based on the configuration defined in - // `tsconfig.json`. - let tsResult = tsProject.src().pipe(sourcemaps.init()).pipe(tsProject()); - let tsc = merge( - tsResult.js.pipe(sourcemaps.write('.', {includeContent: false, sourceRoot: ''})).pipe(gulp.dest(outDir)), - tsResult.dts.pipe(sourcemaps.write('.', {includeContent: false, sourceRoot: ''})).pipe(gulp.dest(outDir)) - ); - - let addonStreams = addons.map(function(addon) { - fs.emptyDirSync(`${outDir}/addons/${addon}`); - - let tsProjectAddon = ts.createProject(`./src/addons/${addon}/tsconfig.json`); - let tsResultAddon = tsProjectAddon.src().pipe(sourcemaps.init()).pipe(tsProjectAddon()); - let tscAddon = merge( - tsResultAddon.js - .pipe(sourcemaps.write('.', {includeContent: false, sourceRoot: ''})) - .pipe(gulp.dest(`${outDir}/addons/${addon}`)), - tsResultAddon.dts - .pipe(sourcemaps.write('.', {includeContent: false, sourceRoot: ''})) - .pipe(gulp.dest(`${outDir}/addons/${addon}`)) - ) - - return tscAddon; - }); - - // Copy all addons from ${srcDir}/ to ${outDir}/ - let copyAddons = gulp.src([ - `${srcDir}/addons/**/**` - ]).pipe(gulp.dest(`${outDir}/addons`)); - - // Copy stylesheets from ${srcDir}/ to ${outDir}/ - let copyStylesheets = gulp.src(`${srcDir}/**/*.css`).pipe(gulp.dest(outDir)); - - // Join all streams into a single array - let streams = [tsc].concat(addonStreams).concat([copyAddons, copyStylesheets]); - - return merge.apply(this, streams); +gulp.task('watch-css', function() { + return gulp.watch(`${srcDir}/**/*.css`, ['css']); }); /** * Bundle JavaScript files produced by the `tsc` task, into a single file named `xterm.js` with * Browserify. */ -gulp.task('browserify', ['tsc'], function() { +gulp.task('browserify', function() { // Ensure that the build directory exists fs.ensureDirSync(buildDir); @@ -108,7 +69,7 @@ gulp.task('browserify', ['tsc'], function() { return merge(bundleStream, copyStylesheets); }); -gulp.task('browserify-addons', ['tsc'], function() { +gulp.task('browserify-addons', function() { const bundles = addons.map((addon) => { const addonOptions = { basedir: `${buildDir}/addons/${addon}`, @@ -192,8 +153,9 @@ gulp.task('webpack', ['build'], function() { .pipe(gulp.dest('demo/dist/')); }); -gulp.task('watch', ['webpack'], () => { - gulp.watch(['./src/*', './src/**/*'], ['webpack']); + +gulp.task('watch-demo', ['webpack'], () => { + gulp.watch(['./demo/*', './lib/**/*'], ['webpack']); }); /** diff --git a/package.json b/package.json index 5c7574ee..54c93e62 100644 --- a/package.json +++ b/package.json @@ -12,9 +12,9 @@ "@types/jsdom": "^11.0.1", "@types/mocha": "^2.2.33", "@types/node": "6.0.108", - "@types/text-encoding": "0.0.32", "browserify": "^13.3.0", "chai": "3.5.0", + "concurrently": "^3.5.1", "express": "4.13.4", "express-ws": "2.0.0-rc.1", "fs-extra": "^1.0.0", @@ -37,7 +37,7 @@ "sorcery": "^0.10.0", "tslint": "^5.9.1", "tslint-consistent-codestyle": "^1.13.0", - "typescript": "~2.7.1", + "typescript": "2.8.3", "vinyl-buffer": "^1.0.0", "vinyl-source-stream": "^1.1.0", "webpack": "^3.10.0", @@ -45,17 +45,18 @@ "zmodem.js": "^0.1.5" }, "scripts": { - "start": "node demo/app", + "start": "concurrently --kill-others-on-fail --names 'demo,server' 'gulp watch-demo' 'node demo/app'", "start-zmodem": "node demo/zmodem/app", "lint": "tslint 'src/**/*.ts'", "test": "npm-run-all mocha lint", "mocha": "gulp test", "build:docs": "jsdoc -c jsdoc.json", "tsc": "tsc", + "prebuild": "concurrently --kill-others-on-fail --names \"lib,attach,fit,fullscreen,search,terminado,webLinks,winptyCompat,zmodem,css\" \"tsc\" \"tsc -p ./src/addons/attach\" \"tsc -p ./src/addons/fit\" \"tsc -p ./src/addons/fullscreen\" \"tsc -p ./src/addons/search\" \"tsc -p ./src/addons/terminado\" \"tsc -p ./src/addons/webLinks\" \"tsc -p ./src/addons/winptyCompat\" \"tsc -p ./src/addons/zmodem\" \"gulp css\"", "build": "gulp build", "prepublish": "npm run build", "coveralls": "gulp coveralls", "webpack": "gulp webpack", - "watch": "gulp watch" + "watch": "concurrently --kill-others-on-fail --names \"lib,attach,fit,fullscreen,search,terminado,webLinks,winptyCompat,zmodem,css\" \"tsc -w\" \"tsc -w -p ./src/addons/attach\" \"tsc -w -p ./src/addons/fit\" \"tsc -w -p ./src/addons/fullscreen\" \"tsc -w -p ./src/addons/search\" \"tsc -w -p ./src/addons/terminado\" \"tsc -w -p ./src/addons/webLinks\" \"tsc -w -p ./src/addons/winptyCompat\" \"tsc -w -p ./src/addons/zmodem\" \"gulp watch-css\"" } } diff --git a/src/AccessibilityManager.ts b/src/AccessibilityManager.ts index a7e205e3..ea300767 100644 --- a/src/AccessibilityManager.ts +++ b/src/AccessibilityManager.ts @@ -179,7 +179,7 @@ export class AccessibilityManager implements IDisposable { this._refreshRowsDimensions(); } - public _createAccessibilityTreeNode(): HTMLElement { + private _createAccessibilityTreeNode(): HTMLElement { const element = document.createElement('div'); element.setAttribute('role', 'listitem'); element.tabIndex = -1; diff --git a/src/Buffer.ts b/src/Buffer.ts index 8cc734f1..5ac2a4f2 100644 --- a/src/Buffer.ts +++ b/src/Buffer.ts @@ -338,9 +338,9 @@ export class Buffer implements IBuffer { } export class Marker extends EventEmitter implements IMarker { - private static NEXT_ID = 1; + private static _nextId = 1; - private _id: number = Marker.NEXT_ID++; + private _id: number = Marker._nextId++; public isDisposed: boolean = false; public disposables: IDisposable[] = []; diff --git a/src/CharWidth.ts b/src/CharWidth.ts index 2165d9ba..6e4aa37f 100644 --- a/src/CharWidth.ts +++ b/src/CharWidth.ts @@ -121,7 +121,7 @@ export const wcwidth = (function(opts: {nul: number, control: number}): (ucs: nu } const control = opts.control | 0; let table: number[] | Uint32Array = null; - function init_table(): number[] | Uint32Array { + function initTable(): number[] | Uint32Array { // lookup table for BMP const CODEPOINTS = 65536; // BMP holds 65536 codepoints const BITWIDTH = 2; // a codepoint can have a width of 0, 1 or 2 @@ -161,7 +161,7 @@ export const wcwidth = (function(opts: {nul: number, control: number}): (ucs: nu if (num < 127) { return 1; } - const t = table || init_table(); + const t = table || initTable(); if (num < 65536) { return t[num >> 4] >> ((num & 15) << 1) & 3; } diff --git a/src/EscapeSequenceParser.test.ts b/src/EscapeSequenceParser.test.ts index dffbccbc..5db6d7ff 100644 --- a/src/EscapeSequenceParser.test.ts +++ b/src/EscapeSequenceParser.test.ts @@ -169,12 +169,12 @@ describe('EscapeSequenceParser', function (): void { }); it('constructor', function (): void { let p: EscapeSequenceParser = new EscapeSequenceParser(); - chai.expect(p.transitions).equal(VT500_TRANSITION_TABLE); + chai.expect(p.TRANSITIONS).equal(VT500_TRANSITION_TABLE); p = new EscapeSequenceParser(VT500_TRANSITION_TABLE); - chai.expect(p.transitions).equal(VT500_TRANSITION_TABLE); + chai.expect(p.TRANSITIONS).equal(VT500_TRANSITION_TABLE); const tansitions: TransitionTable = new TransitionTable(10); p = new EscapeSequenceParser(tansitions); - chai.expect(p.transitions).equal(tansitions); + chai.expect(p.TRANSITIONS).equal(tansitions); }); it('inital states', function (): void { chai.expect(parser.initialState).equal(ParserState.GROUND); diff --git a/src/EscapeSequenceParser.ts b/src/EscapeSequenceParser.ts index 71a06138..2849dbc1 100644 --- a/src/EscapeSequenceParser.ts +++ b/src/EscapeSequenceParser.ts @@ -235,7 +235,7 @@ export class EscapeSequenceParser implements IEscapeSequenceParser { protected _dcsHandlerFb: IDcsHandler; protected _errorHandlerFb: (state: IParsingState) => IParsingState; - constructor(readonly transitions: TransitionTable = VT500_TRANSITION_TABLE) { + constructor(readonly TRANSITIONS: TransitionTable = VT500_TRANSITION_TABLE) { this.initialState = ParserState.GROUND; this.currentState = this.initialState; this._osc = ''; @@ -342,7 +342,7 @@ export class EscapeSequenceParser implements IEscapeSequenceParser { let osc = this._osc; let collect = this._collect; let params = this._params; - const table: Uint8Array | number[] = this.transitions.table; + const table: Uint8Array | number[] = this.TRANSITIONS.table; let dcsHandler: IDcsHandler | null = this._activeDcsHandler; let callback: Function | null = null; diff --git a/src/InputHandler.ts b/src/InputHandler.ts index 817efc71..dbf6dfb2 100644 --- a/src/InputHandler.ts +++ b/src/InputHandler.ts @@ -163,12 +163,12 @@ export class InputHandler implements IInputHandler { this._parser.setCsiHandler('X', (params, collect) => this.eraseChars(params)); this._parser.setCsiHandler('Z', (params, collect) => this.cursorBackwardTab(params)); this._parser.setCsiHandler('`', (params, collect) => this.charPosAbsolute(params)); - this._parser.setCsiHandler('a', (params, collect) => this.HPositionRelative(params)); + this._parser.setCsiHandler('a', (params, collect) => this.hPositionRelative(params)); this._parser.setCsiHandler('b', (params, collect) => this.repeatPrecedingCharacter(params)); this._parser.setCsiHandler('c', (params, collect) => this.sendDeviceAttributes(params, collect)); this._parser.setCsiHandler('d', (params, collect) => this.linePosAbsolute(params)); - this._parser.setCsiHandler('e', (params, collect) => this.VPositionRelative(params)); - this._parser.setCsiHandler('f', (params, collect) => this.HVPosition(params)); + this._parser.setCsiHandler('e', (params, collect) => this.vPositionRelative(params)); + this._parser.setCsiHandler('f', (params, collect) => this.hVPosition(params)); this._parser.setCsiHandler('g', (params, collect) => this.tabClear(params)); this._parser.setCsiHandler('h', (params, collect) => this.setMode(params, collect)); this._parser.setCsiHandler('l', (params, collect) => this.resetMode(params, collect)); @@ -949,7 +949,7 @@ export class InputHandler implements IInputHandler { * [columns] (default = [row,col+1]) (HPR) * reuse CSI Ps C ? */ - public HPositionRelative(params: number[]): void { + public hPositionRelative(params: number[]): void { let param = params[0]; if (param < 1) { param = 1; @@ -1063,7 +1063,7 @@ export class InputHandler implements IInputHandler { * [rows] (default = [row+1,column]) * reuse CSI Ps B ? */ - public VPositionRelative(params: number[]): void { + public vPositionRelative(params: number[]): void { let param = params[0]; if (param < 1) { param = 1; @@ -1083,7 +1083,7 @@ export class InputHandler implements IInputHandler { * Horizontal and Vertical Position [row;column] (default = * [1,1]) (HVP). */ - public HVPosition(params: number[]): void { + public hVPosition(params: number[]): void { if (params[0] < 1) params[0] = 1; if (params[1] < 1) params[1] = 1; diff --git a/src/Linkifier.test.ts b/src/Linkifier.test.ts index 12d40bfe..4c0415de 100644 --- a/src/Linkifier.test.ts +++ b/src/Linkifier.test.ts @@ -11,9 +11,9 @@ import { MockBuffer, MockTerminal } from './utils/TestUtils.test'; import { CircularList } from './utils/CircularList'; class TestLinkifier extends Linkifier { - constructor(_terminal: ITerminal) { - super(_terminal); - Linkifier.TIME_BEFORE_LINKIFY = 0; + constructor(terminal: ITerminal) { + super(terminal); + (Linkifier).TIME_BEFORE_LINKIFY = 0; } public get linkMatchers(): ILinkMatcher[] { return this._linkMatchers; } diff --git a/src/Linkifier.ts b/src/Linkifier.ts index ee7c2626..e548551a 100644 --- a/src/Linkifier.ts +++ b/src/Linkifier.ts @@ -17,7 +17,7 @@ export class Linkifier extends EventEmitter implements ILinkifier { * the costly operation of searching every row multiple times, potentially a * huge amount of times. */ - protected static TIME_BEFORE_LINKIFY = 200; + protected static readonly TIME_BEFORE_LINKIFY = 200; protected _linkMatchers: ILinkMatcher[] = []; diff --git a/src/Parser.ts b/src/Parser.ts index d3241307..519b9609 100644 --- a/src/Parser.ts +++ b/src/Parser.ts @@ -124,12 +124,12 @@ csiStateHandler['T'] = (handler, params, prefix) => { csiStateHandler['X'] = (handler, params, prefix) => handler.eraseChars(params); csiStateHandler['Z'] = (handler, params, prefix) => handler.cursorBackwardTab(params); csiStateHandler['`'] = (handler, params, prefix) => handler.charPosAbsolute(params); -csiStateHandler['a'] = (handler, params, prefix) => handler.HPositionRelative(params); +csiStateHandler['a'] = (handler, params, prefix) => handler.hPositionRelative(params); csiStateHandler['b'] = (handler, params, prefix) => handler.repeatPrecedingCharacter(params); csiStateHandler['c'] = (handler, params, prefix) => handler.sendDeviceAttributes(params); csiStateHandler['d'] = (handler, params, prefix) => handler.linePosAbsolute(params); -csiStateHandler['e'] = (handler, params, prefix) => handler.VPositionRelative(params); -csiStateHandler['f'] = (handler, params, prefix) => handler.HVPosition(params); +csiStateHandler['e'] = (handler, params, prefix) => handler.vPositionRelative(params); +csiStateHandler['f'] = (handler, params, prefix) => handler.hVPosition(params); csiStateHandler['g'] = (handler, params, prefix) => handler.tabClear(params); csiStateHandler['h'] = (handler, params, prefix) => handler.setMode(params); csiStateHandler['l'] = (handler, params, prefix) => handler.resetMode(params); diff --git a/src/Terminal.integration.ts b/src/Terminal.integration.ts index bb50d2d0..7b7cdbdd 100644 --- a/src/Terminal.integration.ts +++ b/src/Terminal.integration.ts @@ -79,23 +79,23 @@ function terminalToString(term: Terminal): string { // Skip tests on Windows since pty.open isn't supported if (os.platform() !== 'win32') { - const CONSOLE_LOG = console.log; + const consoleLog = console.log; // expect files need terminal at 80x25! - const COLS = 80; - const ROWS = 25; + const cols = 80; + const rows = 25; /** some helpers for pty interaction */ // we need a pty in between to get the termios decorations // for the basic test cases a raw pty device is enough - primitivePty = pty.native.open(COLS, ROWS); + primitivePty = pty.native.open(cols, rows); /** tests */ describe('xterm output comparison', () => { let xterm: TestTerminal; beforeEach(() => { - xterm = new TestTerminal({ cols: COLS, rows: ROWS }); + xterm = new TestTerminal({ cols: cols, rows: rows }); xterm.refresh = () => {}; xterm.viewport = { syncScrollArea: () => {} @@ -133,8 +133,9 @@ if (os.platform() !== 'win32') { xterm.innerWrite(); const fromEmulator = terminalToString(xterm); - console.log = CONSOLE_LOG; + console.log = consoleLog; const expected = fs.readFileSync(filename.split('.')[0] + '.text', 'utf8'); + // Some of the tests have whitespace on the right of lines, we trim all the linex // from xterm.js so ignore this for now at least. const expectedRightTrimmed = expected.split('\n').map(l => l.replace(/\s+$/, '')).join('\n'); diff --git a/src/Terminal.ts b/src/Terminal.ts index 3d36890e..af8fd21e 100644 --- a/src/Terminal.ts +++ b/src/Terminal.ts @@ -2212,7 +2212,42 @@ export class Terminal extends EventEmitter implements ITerminal, IDisposable, II // TODO: Remove when true color is implemented public matchColor(r1: number, g1: number, b1: number): number { - return matchColor_(r1, g1, b1); + const hash = (r1 << 16) | (g1 << 8) | b1; + + if (matchColorCache[hash] != null) { + return matchColorCache[hash]; + } + + let ldiff = Infinity; + let li = -1; + let i = 0; + let c: number; + let r2: number; + let g2: number; + let b2: number; + let diff: number; + + for (; i < DEFAULT_ANSI_COLORS.length; i++) { + c = DEFAULT_ANSI_COLORS[i].rgba; + r2 = c >>> 24; + g2 = c >>> 16 & 0xFF; + b2 = c >>> 8 & 0xFF; + // assume that alpha is 0xFF + + diff = matchColorDistance(r1, g1, b1, r2, g2, b2); + + if (diff === 0) { + li = i; + break; + } + + if (diff < ldiff) { + ldiff = diff; + li = i; + } + } + + return matchColorCache[hash] = li; } private _visualBell(): boolean { @@ -2268,43 +2303,3 @@ function matchColorDistance(r1: number, g1: number, b1: number, r2: number, g2: + Math.pow(59 * (g1 - g2), 2) + Math.pow(11 * (b1 - b2), 2); } - - -function matchColor_(r1: number, g1: number, b1: number): number { - const hash = (r1 << 16) | (g1 << 8) | b1; - - if (matchColorCache[hash] != null) { - return matchColorCache[hash]; - } - - let ldiff = Infinity; - let li = -1; - let i = 0; - let c: number; - let r2: number; - let g2: number; - let b2: number; - let diff: number; - - for (; i < DEFAULT_ANSI_COLORS.length; i++) { - c = DEFAULT_ANSI_COLORS[i].rgba; - r2 = c >>> 24; - g2 = c >>> 16 & 0xFF; - b2 = c >>> 8 & 0xFF; - // assume that alpha is 0xFF - - diff = matchColorDistance(r1, g1, b1, r2, g2, b2); - - if (diff === 0) { - li = i; - break; - } - - if (diff < ldiff) { - ldiff = diff; - li = i; - } - } - - return matchColorCache[hash] = li; -} diff --git a/src/Types.ts b/src/Types.ts index d9c09660..96eec3c4 100644 --- a/src/Types.ts +++ b/src/Types.ts @@ -138,12 +138,12 @@ export interface IInputHandler { /** CSI X */ eraseChars(params?: number[]): void; /** CSI Z */ cursorBackwardTab(params?: number[]): void; /** CSI ` */ charPosAbsolute(params?: number[]): void; - /** CSI a */ HPositionRelative(params?: number[]): void; + /** CSI a */ hPositionRelative(params?: number[]): void; /** CSI b */ repeatPrecedingCharacter(params?: number[]): void; /** CSI c */ sendDeviceAttributes(params?: number[], collect?: string): void; /** CSI d */ linePosAbsolute(params?: number[]): void; - /** CSI e */ VPositionRelative(params?: number[]): void; - /** CSI f */ HVPosition(params?: number[]): void; + /** CSI e */ vPositionRelative(params?: number[]): void; + /** CSI f */ hVPosition(params?: number[]): void; /** CSI g */ tabClear(params?: number[]): void; /** CSI h */ setMode(params?: number[], collect?: string): void; /** CSI l */ resetMode(params?: number[], collect?: string): void; diff --git a/src/addons/attach/tsconfig.json b/src/addons/attach/tsconfig.json index 19954249..12e75810 100644 --- a/src/addons/attach/tsconfig.json +++ b/src/addons/attach/tsconfig.json @@ -6,7 +6,8 @@ "outDir": "../../../lib/addons/attach/", "sourceMap": true, "removeComments": true, - "declaration": true + "declaration": true, + "preserveWatchOutput": true }, "include": [ "**/*.ts", diff --git a/src/addons/fit/tsconfig.json b/src/addons/fit/tsconfig.json index e1dce37f..f806af18 100644 --- a/src/addons/fit/tsconfig.json +++ b/src/addons/fit/tsconfig.json @@ -6,7 +6,8 @@ "outDir": "../../../lib/addons/fit/", "sourceMap": true, "removeComments": true, - "declaration": true + "declaration": true, + "preserveWatchOutput": true }, "include": [ "**/*.ts", diff --git a/src/addons/fullscreen/tsconfig.json b/src/addons/fullscreen/tsconfig.json index 5a06c490..2fbb295f 100644 --- a/src/addons/fullscreen/tsconfig.json +++ b/src/addons/fullscreen/tsconfig.json @@ -6,7 +6,8 @@ "outDir": "../../../lib/addons/fullscreen/", "sourceMap": true, "removeComments": true, - "declaration": true + "declaration": true, + "preserveWatchOutput": true }, "include": [ "**/*.ts", diff --git a/src/addons/search/tsconfig.json b/src/addons/search/tsconfig.json index d833bb28..47876a00 100644 --- a/src/addons/search/tsconfig.json +++ b/src/addons/search/tsconfig.json @@ -6,7 +6,8 @@ "outDir": "../../../lib/addons/search/", "sourceMap": true, "removeComments": true, - "declaration": true + "declaration": true, + "preserveWatchOutput": true }, "include": [ "**/*.ts", diff --git a/src/addons/terminado/tsconfig.json b/src/addons/terminado/tsconfig.json index 2c795b99..b664a5e0 100644 --- a/src/addons/terminado/tsconfig.json +++ b/src/addons/terminado/tsconfig.json @@ -6,7 +6,8 @@ "outDir": "../../../lib/addons/terminado/", "sourceMap": true, "removeComments": true, - "declaration": true + "declaration": true, + "preserveWatchOutput": true }, "include": [ "**/*.ts", diff --git a/src/addons/webLinks/tsconfig.json b/src/addons/webLinks/tsconfig.json index b34f544d..7dd999f6 100644 --- a/src/addons/webLinks/tsconfig.json +++ b/src/addons/webLinks/tsconfig.json @@ -6,7 +6,8 @@ "outDir": "../../../lib/addons/webLinks/", "sourceMap": true, "removeComments": true, - "declaration": true + "declaration": true, + "preserveWatchOutput": true }, "include": [ "**/*.ts", diff --git a/src/addons/winptyCompat/tsconfig.json b/src/addons/winptyCompat/tsconfig.json index fdca3e3d..ecad2563 100644 --- a/src/addons/winptyCompat/tsconfig.json +++ b/src/addons/winptyCompat/tsconfig.json @@ -6,7 +6,8 @@ "outDir": "../../../lib/addons/winptyCompat/", "sourceMap": true, "removeComments": true, - "declaration": true + "declaration": true, + "preserveWatchOutput": true }, "include": [ "**/*.ts", diff --git a/src/addons/zmodem/tsconfig.json b/src/addons/zmodem/tsconfig.json index f5693801..d4577108 100644 --- a/src/addons/zmodem/tsconfig.json +++ b/src/addons/zmodem/tsconfig.json @@ -6,7 +6,8 @@ "outDir": "../../../lib/addons/zmodem/", "sourceMap": true, "removeComments": true, - "declaration": true + "declaration": true, + "preserveWatchOutput": true }, "include": [ "**/*.ts", diff --git a/src/addons/zmodem/zmodem.ts b/src/addons/zmodem/zmodem.ts index 4683538f..23204f0f 100644 --- a/src/addons/zmodem/zmodem.ts +++ b/src/addons/zmodem/zmodem.ts @@ -46,13 +46,13 @@ function zmodemAttach(ws: WebSocket, opts: IZmodemOptions = {}): void { let zsentry; - function _shouldWrite(): boolean { + function shouldWrite(): boolean { return !!zsentry.get_confirmed_session() || !opts.noTerminalWriteOutsideSession; } zsentry = new zmodem.Sentry({ to_terminal: (octets: ArrayLike) => { - if (_shouldWrite()) { + if (shouldWrite()) { term.write( String.fromCharCode.apply(String, octets) ); @@ -70,7 +70,7 @@ function zmodemAttach(ws: WebSocket, opts: IZmodemOptions = {}): void { // may be specific to xterm.js’s demo, ultimately we // should reject anything that isn’t binary. if (typeof evt.data === 'string') { - if (_shouldWrite()) { + if (shouldWrite()) { term.write(evt.data); } } diff --git a/src/renderer/atlas/StaticCharAtlas.ts b/src/renderer/atlas/StaticCharAtlas.ts index cb4875ec..b6de82fc 100644 --- a/src/renderer/atlas/StaticCharAtlas.ts +++ b/src/renderer/atlas/StaticCharAtlas.ts @@ -26,7 +26,7 @@ export default class StaticCharAtlas extends BaseCharAtlas { return canvas; } - public _doWarmUp(): void { + protected _doWarmUp(): void { const result = generateStaticCharAtlasTexture(window, this._canvasFactory, this._config); if (result instanceof HTMLCanvasElement) { this._texture = result; diff --git a/tsconfig.json b/tsconfig.json index c33793f5..e39ea642 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -12,6 +12,7 @@ "outDir": "lib", "sourceMap": true, "removeComments": true, + "preserveWatchOutput": true, "noUnusedLocals": true, "noImplicitAny": true }, diff --git a/tslint.json b/tslint.json index 8b364077..2ae39796 100644 --- a/tslint.json +++ b/tslint.json @@ -94,7 +94,16 @@ "naming-convention": [ true, - {"type": "property", "modifiers": ["public", "static", "const"], "format": "UPPER_CASE"} + {"type": "default", "format": "camelCase", "leadingUnderscore": "forbid"}, + {"type": "type", "format": "PascalCase"}, + {"type": "class", "format": "PascalCase"}, + {"type": "property", "modifiers": ["const"], "format": "UPPER_CASE"}, + {"type": "member", "modifiers": ["protected"], "format": "camelCase", "leadingUnderscore": "allow"}, + // TODO: Change allow to require when there aren't many PRs out + // {"type": "member", "modifiers": ["protected"], "format": "camelCase", "leadingUnderscore": "require"}, + {"type": "member", "modifiers": ["private"], "format": "camelCase", "leadingUnderscore": "require"}, + {"type": "variable", "modifiers": ["const"], "format": ["camelCase", "UPPER_CASE"]}, + {"type": "interface", "prefix": "I"} ], "no-else-after-return": { "options": "allow-else-if"