Create headless project, fix compile

This commit is contained in:
Daniel Imms
2021-07-22 15:40:13 -07:00
parent 625e17ee1c
commit df17288c1e
20 changed files with 1545 additions and 23 deletions
+1
View File
@@ -9,6 +9,7 @@
"project": [
"src/browser/tsconfig.json",
"src/common/tsconfig.json",
"src/headless/tsconfig.json",
"test/api/tsconfig.json",
"test/benchmark/tsconfig.json",
"addons/xterm-addon-attach/src/tsconfig.json",
+28
View File
@@ -0,0 +1,28 @@
import { IBuffer } from 'common/buffer/Types';
import { CoreTerminal } from 'common/CoreTerminal';
import { IEvent } from 'common/EventEmitter';
import { ITerminalOptions as IInitializedTerminalOptions } from 'common/services/Services';
import { IMarker, ITerminalOptions } from 'common/Types';
export declare class Terminal extends CoreTerminal {
get options(): IInitializedTerminalOptions;
private _onBell;
get onBell(): IEvent<void>;
private _onCursorMove;
get onCursorMove(): IEvent<void>;
private _onTitleChange;
get onTitleChange(): IEvent<string>;
private _onA11yCharEmitter;
get onA11yChar(): IEvent<string>;
private _onA11yTabEmitter;
get onA11yTab(): IEvent<number>;
constructor(options?: ITerminalOptions);
dispose(): void;
get buffer(): IBuffer;
get markers(): IMarker[];
addMarker(cursorYOffset: number): IMarker | undefined;
bell(): void;
resize(x: number, y: number): void;
clear(): void;
reset(): void;
}
//# sourceMappingURL=Terminal.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"Terminal.d.ts","sourceRoot":"","sources":["../../src/headless/Terminal.ts"],"names":[],"mappings":"AAwBA,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAA8B,MAAM,EAAE,MAAM,qBAAqB,CAAC;AACzE,OAAO,EAAE,gBAAgB,IAAI,2BAA2B,EAAE,MAAM,0BAA0B,CAAC;AAC3F,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAgB,MAAM,cAAc,CAAC;AAEvE,qBAAa,QAAS,SAAQ,YAAY;IAExC,IAAW,OAAO,IAAI,2BAA2B,CAAwC;IAGzF,OAAO,CAAC,OAAO,CAA6B;IAC5C,IAAW,MAAM,IAAK,MAAM,CAAC,IAAI,CAAC,CAA+B;IACjE,OAAO,CAAC,aAAa,CAA4B;IACjD,IAAW,YAAY,IAAI,MAAM,CAAC,IAAI,CAAC,CAAqC;IAC5E,OAAO,CAAC,cAAc,CAA8B;IACpD,IAAW,aAAa,IAAI,MAAM,CAAC,MAAM,CAAC,CAAsC;IAEhF,OAAO,CAAC,kBAAkB,CAA8B;IACxD,IAAW,UAAU,IAAI,MAAM,CAAC,MAAM,CAAC,CAA0C;IACjF,OAAO,CAAC,iBAAiB,CAA8B;IACvD,IAAW,SAAS,IAAI,MAAM,CAAC,MAAM,CAAC,CAAyC;gBAe7E,OAAO,GAAE,gBAAqB;IAezB,OAAO,IAAI,IAAI;IAWtB,IAAW,MAAM,IAAI,OAAO,CAE3B;IAED,IAAW,OAAO,IAAI,OAAO,EAAE,CAE9B;IAEM,SAAS,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS;IASrD,IAAI,IAAI,IAAI;IAUZ,MAAM,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI;IAWlC,KAAK,IAAI,IAAI;IAwBb,KAAK,IAAI,IAAI;CAWrB"}
+130
View File
@@ -0,0 +1,130 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.Terminal = void 0;
var BufferLine_1 = require("common/buffer/BufferLine");
var CoreTerminal_1 = require("common/CoreTerminal");
var EventEmitter_1 = require("common/EventEmitter");
var Terminal = (function (_super) {
__extends(Terminal, _super);
function Terminal(options) {
if (options === void 0) { options = {}; }
var _this = _super.call(this, options) || this;
_this._onBell = new EventEmitter_1.EventEmitter();
_this._onCursorMove = new EventEmitter_1.EventEmitter();
_this._onTitleChange = new EventEmitter_1.EventEmitter();
_this._onA11yCharEmitter = new EventEmitter_1.EventEmitter();
_this._onA11yTabEmitter = new EventEmitter_1.EventEmitter();
_this._setup();
_this.register(_this._inputHandler.onRequestBell(function () { return _this.bell(); }));
_this.register(_this._inputHandler.onRequestReset(function () { return _this.reset(); }));
_this.register(EventEmitter_1.forwardEvent(_this._inputHandler.onCursorMove, _this._onCursorMove));
_this.register(EventEmitter_1.forwardEvent(_this._inputHandler.onTitleChange, _this._onTitleChange));
_this.register(EventEmitter_1.forwardEvent(_this._inputHandler.onA11yChar, _this._onA11yCharEmitter));
_this.register(EventEmitter_1.forwardEvent(_this._inputHandler.onA11yTab, _this._onA11yTabEmitter));
return _this;
}
Object.defineProperty(Terminal.prototype, "options", {
get: function () { return this.optionsService.options; },
enumerable: false,
configurable: true
});
Object.defineProperty(Terminal.prototype, "onBell", {
get: function () { return this._onBell.event; },
enumerable: false,
configurable: true
});
Object.defineProperty(Terminal.prototype, "onCursorMove", {
get: function () { return this._onCursorMove.event; },
enumerable: false,
configurable: true
});
Object.defineProperty(Terminal.prototype, "onTitleChange", {
get: function () { return this._onTitleChange.event; },
enumerable: false,
configurable: true
});
Object.defineProperty(Terminal.prototype, "onA11yChar", {
get: function () { return this._onA11yCharEmitter.event; },
enumerable: false,
configurable: true
});
Object.defineProperty(Terminal.prototype, "onA11yTab", {
get: function () { return this._onA11yTabEmitter.event; },
enumerable: false,
configurable: true
});
Terminal.prototype.dispose = function () {
if (this._isDisposed) {
return;
}
_super.prototype.dispose.call(this);
this.write = function () { };
};
Object.defineProperty(Terminal.prototype, "buffer", {
get: function () {
return this.buffers.active;
},
enumerable: false,
configurable: true
});
Object.defineProperty(Terminal.prototype, "markers", {
get: function () {
return this.buffer.markers;
},
enumerable: false,
configurable: true
});
Terminal.prototype.addMarker = function (cursorYOffset) {
if (this.buffer !== this.buffers.normal) {
return;
}
return this.buffer.addMarker(this.buffer.ybase + this.buffer.y + cursorYOffset);
};
Terminal.prototype.bell = function () {
this._onBell.fire();
};
Terminal.prototype.resize = function (x, y) {
if (x === this.cols && y === this.rows) {
return;
}
_super.prototype.resize.call(this, x, y);
};
Terminal.prototype.clear = function () {
if (this.buffer.ybase === 0 && this.buffer.y === 0) {
return;
}
this.buffer.lines.set(0, this.buffer.lines.get(this.buffer.ybase + this.buffer.y));
this.buffer.lines.length = 1;
this.buffer.ydisp = 0;
this.buffer.ybase = 0;
this.buffer.y = 0;
for (var i = 1; i < this.rows; i++) {
this.buffer.lines.push(this.buffer.getBlankLine(BufferLine_1.DEFAULT_ATTR_DATA));
}
this._onScroll.fire({ position: this.buffer.ydisp, source: 0 });
};
Terminal.prototype.reset = function () {
this.options.rows = this.rows;
this.options.cols = this.cols;
this._setup();
_super.prototype.reset.call(this);
};
return Terminal;
}(CoreTerminal_1.CoreTerminal));
exports.Terminal = Terminal;
//# sourceMappingURL=Terminal.js.map
File diff suppressed because one or more lines are too long
+48
View File
@@ -0,0 +1,48 @@
import { IEvent } from 'common/EventEmitter';
import { IBufferNamespace as IBufferNamespaceApi, IMarker, IParser, ITerminalOptions, IUnicodeHandling, Terminal as ITerminalApi } from 'xterm-core';
export declare class Terminal implements ITerminalApi {
private _core;
private _parser;
private _buffer;
constructor(options?: ITerminalOptions);
private _checkProposedApi;
get onCursorMove(): IEvent<void>;
get onLineFeed(): IEvent<void>;
get onData(): IEvent<string>;
get onBinary(): IEvent<string>;
get onTitleChange(): IEvent<string>;
get onResize(): IEvent<{
cols: number;
rows: number;
}>;
get parser(): IParser;
get unicode(): IUnicodeHandling;
get rows(): number;
get cols(): number;
get buffer(): IBufferNamespaceApi;
get markers(): ReadonlyArray<IMarker>;
resize(columns: number, rows: number): void;
registerMarker(cursorYOffset: number): IMarker | undefined;
addMarker(cursorYOffset: number): IMarker | undefined;
dispose(): void;
clear(): void;
write(data: string | Uint8Array, callback?: () => void): void;
writeUtf8(data: Uint8Array, callback?: () => void): void;
writeln(data: string | Uint8Array, callback?: () => void): void;
getOption(key: 'bellSound' | 'bellStyle' | 'cursorStyle' | 'fontFamily' | 'logLevel' | 'rendererType' | 'termName' | 'wordSeparator'): string;
getOption(key: 'allowTransparency' | 'altClickMovesCursor' | 'cancelEvents' | 'convertEol' | 'cursorBlink' | 'disableStdin' | 'macOptionIsMeta' | 'rightClickSelectsWord' | 'popOnBell' | 'visualBell'): boolean;
getOption(key: 'cols' | 'fontSize' | 'letterSpacing' | 'lineHeight' | 'rows' | 'tabStopWidth' | 'scrollback'): number;
getOption(key: string): any;
setOption(key: 'bellSound' | 'fontFamily' | 'termName' | 'wordSeparator', value: string): void;
setOption(key: 'fontWeight' | 'fontWeightBold', value: 'normal' | 'bold' | '100' | '200' | '300' | '400' | '500' | '600' | '700' | '800' | '900' | number): void;
setOption(key: 'logLevel', value: 'debug' | 'info' | 'warn' | 'error' | 'off'): void;
setOption(key: 'bellStyle', value: 'none' | 'visual' | 'sound' | 'both'): void;
setOption(key: 'cursorStyle', value: 'block' | 'underline' | 'bar'): void;
setOption(key: 'allowTransparency' | 'altClickMovesCursor' | 'cancelEvents' | 'convertEol' | 'cursorBlink' | 'disableStdin' | 'macOptionIsMeta' | 'rightClickSelectsWord' | 'popOnBell' | 'visualBell', value: boolean): void;
setOption(key: 'fontSize' | 'letterSpacing' | 'lineHeight' | 'tabStopWidth' | 'scrollback', value: number): void;
setOption(key: 'cols' | 'rows', value: number): void;
setOption(key: string, value: any): void;
reset(): void;
private _verifyIntegers;
}
//# sourceMappingURL=Terminal.d.ts.map
File diff suppressed because one or more lines are too long
+147
View File
@@ -0,0 +1,147 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Terminal = void 0;
var BufferNamespaceApi_1 = require("common/public/BufferNamespaceApi");
var ParserApi_1 = require("common/public/ParserApi");
var UnicodeApi_1 = require("common/public/UnicodeApi");
var Terminal_1 = require("headless/Terminal");
var Terminal = (function () {
function Terminal(options) {
this._core = new Terminal_1.Terminal(options);
}
Terminal.prototype._checkProposedApi = function () {
if (!this._core.optionsService.options.allowProposedApi) {
throw new Error('You must set the allowProposedApi option to true to use proposed API');
}
};
Object.defineProperty(Terminal.prototype, "onCursorMove", {
get: function () { return this._core.onCursorMove; },
enumerable: false,
configurable: true
});
Object.defineProperty(Terminal.prototype, "onLineFeed", {
get: function () { return this._core.onLineFeed; },
enumerable: false,
configurable: true
});
Object.defineProperty(Terminal.prototype, "onData", {
get: function () { return this._core.onData; },
enumerable: false,
configurable: true
});
Object.defineProperty(Terminal.prototype, "onBinary", {
get: function () { return this._core.onBinary; },
enumerable: false,
configurable: true
});
Object.defineProperty(Terminal.prototype, "onTitleChange", {
get: function () { return this._core.onTitleChange; },
enumerable: false,
configurable: true
});
Object.defineProperty(Terminal.prototype, "onResize", {
get: function () { return this._core.onResize; },
enumerable: false,
configurable: true
});
Object.defineProperty(Terminal.prototype, "parser", {
get: function () {
this._checkProposedApi();
if (!this._parser) {
this._parser = new ParserApi_1.ParserApi(this._core);
}
return this._parser;
},
enumerable: false,
configurable: true
});
Object.defineProperty(Terminal.prototype, "unicode", {
get: function () {
this._checkProposedApi();
return new UnicodeApi_1.UnicodeApi(this._core);
},
enumerable: false,
configurable: true
});
Object.defineProperty(Terminal.prototype, "rows", {
get: function () { return this._core.rows; },
enumerable: false,
configurable: true
});
Object.defineProperty(Terminal.prototype, "cols", {
get: function () { return this._core.cols; },
enumerable: false,
configurable: true
});
Object.defineProperty(Terminal.prototype, "buffer", {
get: function () {
this._checkProposedApi();
if (!this._buffer) {
this._buffer = new BufferNamespaceApi_1.BufferNamespaceApi(this._core);
}
return this._buffer;
},
enumerable: false,
configurable: true
});
Object.defineProperty(Terminal.prototype, "markers", {
get: function () {
this._checkProposedApi();
return this._core.markers;
},
enumerable: false,
configurable: true
});
Terminal.prototype.resize = function (columns, rows) {
this._verifyIntegers(columns, rows);
this._core.resize(columns, rows);
};
Terminal.prototype.registerMarker = function (cursorYOffset) {
this._checkProposedApi();
this._verifyIntegers(cursorYOffset);
return this._core.addMarker(cursorYOffset);
};
Terminal.prototype.addMarker = function (cursorYOffset) {
return this.registerMarker(cursorYOffset);
};
Terminal.prototype.dispose = function () {
this._core.dispose();
};
Terminal.prototype.clear = function () {
this._core.clear();
};
Terminal.prototype.write = function (data, callback) {
this._core.write(data, callback);
};
Terminal.prototype.writeUtf8 = function (data, callback) {
this._core.write(data, callback);
};
Terminal.prototype.writeln = function (data, callback) {
this._core.write(data);
this._core.write('\r\n', callback);
};
Terminal.prototype.getOption = function (key) {
return this._core.optionsService.getOption(key);
};
Terminal.prototype.setOption = function (key, value) {
this._core.optionsService.setOption(key, value);
};
Terminal.prototype.reset = function () {
this._core.reset();
};
Terminal.prototype._verifyIntegers = function () {
var values = [];
for (var _i = 0; _i < arguments.length; _i++) {
values[_i] = arguments[_i];
}
for (var _a = 0, values_1 = values; _a < values_1.length; _a++) {
var value = values_1[_a];
if (value === Infinity || isNaN(value) || value % 1 !== 0) {
throw new Error('This API only accepts integers');
}
}
};
return Terminal;
}());
exports.Terminal = Terminal;
//# sourceMappingURL=Terminal.js.map
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large Load Diff
+32
View File
@@ -0,0 +1,32 @@
import { IBuffer, IBufferSet } from 'common/buffer/Types';
import { IEvent } from 'common/EventEmitter';
import { IFunctionIdentifier, IParams } from 'common/parser/Types';
import { ICoreTerminal, IDisposable, IMarker, ITerminalOptions } from 'common/Types';
export interface ITerminal extends ICoreTerminal {
rows: number;
cols: number;
buffer: IBuffer;
buffers: IBufferSet;
markers: IMarker[];
options: ITerminalOptions;
onCursorMove: IEvent<void>;
onData: IEvent<string>;
onBinary: IEvent<string>;
onLineFeed: IEvent<void>;
onResize: IEvent<{
cols: number;
rows: number;
}>;
onTitleChange: IEvent<string>;
resize(columns: number, rows: number): void;
addCsiHandler(id: IFunctionIdentifier, callback: (params: IParams) => boolean): IDisposable;
addDcsHandler(id: IFunctionIdentifier, callback: (data: string, param: IParams) => boolean): IDisposable;
addEscHandler(id: IFunctionIdentifier, callback: () => boolean): IDisposable;
addOscHandler(ident: number, callback: (data: string) => boolean): IDisposable;
addMarker(cursorYOffset: number): IMarker | undefined;
dispose(): void;
clear(): void;
write(data: string | Uint8Array, callback?: () => void): void;
reset(): void;
}
//# sourceMappingURL=types.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/headless/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,mBAAmB,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AACnE,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAErF,MAAM,WAAW,SAAU,SAAQ,aAAa;IAC9C,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,UAAU,CAAC;IACpB,OAAO,EAAE,OAAO,EAAE,CAAC;IAEnB,OAAO,EAAE,gBAAgB,CAAC;IAE1B,YAAY,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC;IAC3B,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;IACvB,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;IACzB,UAAU,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC;IACzB,QAAQ,EAAE,MAAM,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACjD,aAAa,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;IAC9B,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5C,aAAa,CAAC,EAAE,EAAE,mBAAmB,EAAE,QAAQ,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,OAAO,GAAG,WAAW,CAAC;IAC5F,aAAa,CAAC,EAAE,EAAE,mBAAmB,EAAE,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,KAAK,OAAO,GAAG,WAAW,CAAC;IACzG,aAAa,CAAC,EAAE,EAAE,mBAAmB,EAAE,QAAQ,EAAE,MAAM,OAAO,GAAG,WAAW,CAAC;IAC7E,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,GAAG,WAAW,CAAC;IAC/E,SAAS,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC;IACtD,OAAO,IAAI,IAAI,CAAC;IAChB,KAAK,IAAI,IAAI,CAAC;IACd,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,EAAE,QAAQ,CAAC,EAAE,MAAM,IAAI,GAAG,IAAI,CAAC;IAC9D,KAAK,IAAI,IAAI,CAAC;CACf"}
+3
View File
@@ -0,0 +1,3 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=types.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/headless/types.ts"],"names":[],"mappings":""}
-21
View File
@@ -1,21 +0,0 @@
{
"extends": "../../tsconfig-library-base",
"compilerOptions": {
"lib": [
"es2015",
"es2016.Array.Include"
],
"outDir": "../../../xterm-core", // Temporary outdir to avoid collisions with 'xterm'
"types": [
"../../../node_modules/@types/mocha",
"../../../node_modules/@types/node"
],
"baseUrl": "../../",
"extendedDiagnostics": true
},
"include": [
"../**/*",
"../../../typings/xterm-core.d.ts",
"../../../typings/xterm.d.ts", // common/Types.d.ts imports from 'xterm'
],
}
+1 -1
View File
@@ -28,4 +28,4 @@ export interface ITerminal extends ICoreTerminal {
clear(): void;
write(data: string | Uint8Array, callback?: () => void): void;
reset(): void;
}
}
@@ -8,7 +8,7 @@ import { BufferNamespaceApi } from 'common/public/BufferNamespaceApi';
import { ParserApi } from 'common/public/ParserApi';
import { UnicodeApi } from 'common/public/UnicodeApi';
import { IBufferNamespace as IBufferNamespaceApi, IMarker, IParser, ITerminalOptions, IUnicodeHandling, Terminal as ITerminalApi } from 'xterm-core';
import { Terminal as TerminalCore } from '../Terminal';
import { Terminal as TerminalCore } from 'headless/Terminal';
export class Terminal implements ITerminalApi {
private _core: TerminalCore;
+27
View File
@@ -0,0 +1,27 @@
{
"extends": "../tsconfig-library-base",
"compilerOptions": {
"lib": [
"es2015",
"es2016.Array.Include"
],
"outDir": "../../headless", // Temporary outdir to avoid collisions with 'xterm'
"types": [
"../../node_modules/@types/mocha",
"../../node_modules/@types/node"
],
"baseUrl": "../",
"extendedDiagnostics": true,
"paths": {
"common/*": [ "./common/*" ]
}
},
"include": [
"./**/*",
"../../typings/xterm.d.ts", // common/Types.d.ts imports from 'xterm'
"../../typings/xterm-core.d.ts"
],
"references": [
{ "path": "../common" }
]
}
+1
View File
@@ -3,6 +3,7 @@
"include": [],
"references": [
{ "path": "./src/browser" },
{ "path": "./src/headless" },
{ "path": "./test/api" },
{ "path": "./test/benchmark" },
{ "path": "./addons/xterm-addon-attach" },