diff --git a/package.json b/package.json index 478c8a8e4d..b10b6b54e0 100644 --- a/package.json +++ b/package.json @@ -50,6 +50,7 @@ "start": "node demo/start", "start-zmodem": "node demo/zmodem/app", "lint": "tslint 'src/**/*.ts' './demo/**/*.ts'", + "pretest": "npm run layering", "test": "npm run mocha", "posttest": "npm run lint", "test-debug": "node --inspect-brk node_modules/.bin/gulp test", @@ -64,6 +65,7 @@ "coveralls": "nyc report --reporter=text-lcov | coveralls", "webpack": "gulp webpack", "watch": "concurrently --kill-others-on-fail --names \"lib,css\" \"tsc -w\" \"gulp watch-css\"", - "watch-addons": "concurrently --kill-others-on-fail --names \"attach,fit,fullscreen,search,terminado,webLinks,winptyCompat,zmodem\" \"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\"" + "watch-addons": "concurrently --kill-others-on-fail --names \"attach,fit,fullscreen,search,terminado,webLinks,winptyCompat,zmodem\" \"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\"", + "layering": "concurrently --kill-others-on-fail --names \"common,core\" \"tsc -p ./src/common\" \"tsc -p ./src/core\"" } } diff --git a/src/addons/fit/tsconfig.json b/src/addons/fit/tsconfig.json index bccb2ef177..f478e03f79 100644 --- a/src/addons/fit/tsconfig.json +++ b/src/addons/fit/tsconfig.json @@ -4,17 +4,20 @@ "target": "es5", "lib": [ "dom", - "es6", + "es5" ], "rootDir": ".", "outDir": "../../../lib/addons/fit/", "sourceMap": true, "removeComments": true, "declaration": true, - "preserveWatchOutput": true + "preserveWatchOutput": true, + "types": [ + "../../node_modules/@types/mocha", + "../.." + ] }, "include": [ - "**/*.ts", - "../../../typings/xterm.d.ts" + "**/*.ts" ] } diff --git a/src/addons/fullscreen/tsconfig.json b/src/addons/fullscreen/tsconfig.json index cdebd36d8a..40d0ae7146 100644 --- a/src/addons/fullscreen/tsconfig.json +++ b/src/addons/fullscreen/tsconfig.json @@ -4,17 +4,20 @@ "target": "es5", "lib": [ "dom", - "es6", + "es5" ], "rootDir": ".", "outDir": "../../../lib/addons/fullscreen/", "sourceMap": true, "removeComments": true, "declaration": true, - "preserveWatchOutput": true + "preserveWatchOutput": true, + "types": [ + "../../node_modules/@types/mocha", + "../.." + ] }, "include": [ - "**/*.ts", - "../../../typings/xterm.d.ts" + "**/*.ts" ] } diff --git a/src/addons/search/search.test.ts b/src/addons/search/search.test.ts index ccdebaf34b..1fe18b6a46 100644 --- a/src/addons/search/search.test.ts +++ b/src/addons/search/search.test.ts @@ -8,7 +8,6 @@ import * as search from './search'; import { SearchHelper } from './SearchHelper'; import { ISearchOptions, ISearchResult } from './Interfaces'; - class MockTerminalPlain {} class MockTerminal { @@ -16,7 +15,7 @@ class MockTerminal { public searchHelper: TestSearchHelper; public cols: number; constructor(options: any) { - this._core = new (require('../../../lib/Terminal').Terminal)(options); + this._core = new (require('../../../lib/Terminal')).Terminal(options); this.searchHelper = new TestSearchHelper(this as any); this.cols = options.cols; } diff --git a/src/addons/search/tsconfig.json b/src/addons/search/tsconfig.json index 5e9fa502e2..9998dc1bb9 100644 --- a/src/addons/search/tsconfig.json +++ b/src/addons/search/tsconfig.json @@ -3,18 +3,23 @@ "module": "commonjs", "target": "es5", "lib": [ - "dom", - "es6", + "es5" ], "rootDir": ".", "outDir": "../../../lib/addons/search/", "sourceMap": true, "removeComments": true, "declaration": true, - "preserveWatchOutput": true + "preserveWatchOutput": true, + "types": [ + "../../node_modules/@types/mocha", + "../.." + ] }, "include": [ - "**/*.ts", - "../../../typings/xterm.d.ts" + "**/*.ts" + ], + "exclude": [ + "**/*.test.ts" ] } diff --git a/src/addons/terminado/tsconfig.json b/src/addons/terminado/tsconfig.json index 66e90d90c7..0e30963dc4 100644 --- a/src/addons/terminado/tsconfig.json +++ b/src/addons/terminado/tsconfig.json @@ -3,18 +3,20 @@ "module": "commonjs", "target": "es5", "lib": [ - "dom", - "es6", + "es5" ], "rootDir": ".", "outDir": "../../../lib/addons/terminado/", "sourceMap": true, "removeComments": true, "declaration": true, - "preserveWatchOutput": true + "preserveWatchOutput": true, + "types": [ + "../../node_modules/@types/mocha", + "../.." + ] }, "include": [ - "**/*.ts", - "../../../typings/xterm.d.ts" + "**/*.ts" ] } diff --git a/src/addons/webLinks/tsconfig.json b/src/addons/webLinks/tsconfig.json index a1cc8968da..6f9db2cb96 100644 --- a/src/addons/webLinks/tsconfig.json +++ b/src/addons/webLinks/tsconfig.json @@ -4,17 +4,20 @@ "target": "es5", "lib": [ "dom", - "es6", + "es5", ], "rootDir": ".", "outDir": "../../../lib/addons/webLinks/", "sourceMap": true, "removeComments": true, "declaration": true, - "preserveWatchOutput": true + "preserveWatchOutput": true, + "types": [ + "../../node_modules/@types/mocha", + "../.." + ] }, "include": [ - "**/*.ts", - "../../../typings/xterm.d.ts" + "**/*.ts" ] } diff --git a/src/addons/winptyCompat/tsconfig.json b/src/addons/winptyCompat/tsconfig.json index 8a4fe2dc9c..6056da08cd 100644 --- a/src/addons/winptyCompat/tsconfig.json +++ b/src/addons/winptyCompat/tsconfig.json @@ -3,18 +3,20 @@ "module": "commonjs", "target": "es5", "lib": [ - "dom", - "es6", + "es5" ], "rootDir": ".", "outDir": "../../../lib/addons/winptyCompat/", "sourceMap": true, "removeComments": true, "declaration": true, - "preserveWatchOutput": true + "preserveWatchOutput": true, + "types": [ + "../../node_modules/@types/mocha", + "../.." + ] }, "include": [ - "**/*.ts", - "../../../typings/xterm.d.ts" + "**/*.ts" ] } diff --git a/src/addons/zmodem/tsconfig.json b/src/addons/zmodem/tsconfig.json index e2fdfeb048..5dd438a373 100644 --- a/src/addons/zmodem/tsconfig.json +++ b/src/addons/zmodem/tsconfig.json @@ -3,18 +3,20 @@ "module": "commonjs", "target": "es5", "lib": [ - "dom", - "es6", + "es5" ], "rootDir": ".", "outDir": "../../../lib/addons/zmodem/", "sourceMap": true, "removeComments": true, "declaration": true, - "preserveWatchOutput": true + "preserveWatchOutput": true, + "types": [ + "../../node_modules/@types/mocha", + "../.." + ] }, "include": [ - "**/*.ts", - "../../../typings/xterm.d.ts" + "**/*.ts" ] } diff --git a/src/common/EventEmitter.ts b/src/common/EventEmitter.ts index ae8f0069dc..f9c0c0014e 100644 --- a/src/common/EventEmitter.ts +++ b/src/common/EventEmitter.ts @@ -14,7 +14,7 @@ export class EventEmitter extends Disposable implements IEventEmitter, IDisposab super(); // Restore the previous events if available, this will happen if the // constructor is called multiple times on the same object (terminal reset). - this._events = this._events || {}; + this._events = (this)._events || {}; } public on(type: string, listener: XtermListener): void { diff --git a/src/common/tsconfig.json b/src/common/tsconfig.json new file mode 100644 index 0000000000..19dd02731c --- /dev/null +++ b/src/common/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "target": "es5", + "lib": [ + "es5" + ], + "rootDir": ".", + "noEmit": true, + "strict": true, + "pretty": true, + "types": [ + "../../node_modules/@types/mocha", + "../../" + ] + }, + "include": [ + "./**/*" + ] +} diff --git a/src/core/data/Charsets.ts b/src/core/data/Charsets.ts index b49ee77f23..5fc36ac1f9 100644 --- a/src/core/data/Charsets.ts +++ b/src/core/data/Charsets.ts @@ -10,12 +10,12 @@ import { ICharset } from '../Types'; * to be represented within the terminal with only 8-bit encoding. See ISO 2022 * for a discussion on character sets. Only VT100 character sets are supported. */ -export const CHARSETS: { [key: string]: ICharset } = {}; +export const CHARSETS: { [key: string]: ICharset | null } = {}; /** * The default character set, US. */ -export const DEFAULT_CHARSET: ICharset = CHARSETS['B']; +export const DEFAULT_CHARSET: ICharset | null = CHARSETS['B']; /** * DEC Special Character and Line Drawing Set. diff --git a/src/core/input/Keyboard.test.ts b/src/core/input/Keyboard.test.ts index 1104fc616f..e984683197 100644 --- a/src/core/input/Keyboard.test.ts +++ b/src/core/input/Keyboard.test.ts @@ -2,6 +2,7 @@ import { assert } from 'chai'; import { evaluateKeyboardEvent } from './Keyboard'; import { IKeyboardResult } from '../Types'; +import { IKeyboardEvent } from '../../common/Types'; /** * A helper function for testing which allows passing in a partial event and defaults will be filled @@ -20,12 +21,12 @@ function testEvaluateKeyboardEvent(partialEvent: { isMac?: boolean; macOptionIsMeta?: boolean; } = {}): IKeyboardResult { - const event = { + const event: IKeyboardEvent = { altKey: partialEvent.altKey || false, ctrlKey: partialEvent.ctrlKey || false, shiftKey: partialEvent.shiftKey || false, metaKey: partialEvent.metaKey || false, - keyCode: partialEvent.keyCode !== undefined ? partialEvent.keyCode : undefined, + keyCode: partialEvent.keyCode !== undefined ? partialEvent.keyCode : 0, key: partialEvent.key || '', type: partialEvent.type || '' }; diff --git a/src/core/tsconfig.json b/src/core/tsconfig.json new file mode 100644 index 0000000000..4f024a28dc --- /dev/null +++ b/src/core/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "target": "es5", + "lib": [ + "es5" + ], + "rootDir": ".", + "noEmit": true, + "strict": true, + "pretty": true, + "types": [ + "../../node_modules/@types/mocha", + "../../" + ] + }, + "include": [ + "./**/*", + "../common/**/*" + ] +} diff --git a/typings/xterm.d.ts b/typings/xterm.d.ts index 49f3810f5f..3982874ee9 100644 --- a/typings/xterm.d.ts +++ b/typings/xterm.d.ts @@ -7,6 +7,8 @@ * to be stable and consumed by external programs. */ +/// + declare module 'xterm' { /** * A string representing text font weight.