Merge pull request #4847 from tisilent/add-addon-public-api

Have addons implement their API at compile time
This commit is contained in:
Daniel Imms
2023-11-02 09:08:14 -07:00
committed by GitHub
25 changed files with 87 additions and 33 deletions
+3 -2
View File
@@ -5,13 +5,14 @@
* Implements the attach method, that attaches the terminal to a WebSocket stream.
*/
import { Terminal, IDisposable, ITerminalAddon } from '@xterm/xterm';
import type { Terminal, IDisposable, ITerminalAddon } from '@xterm/xterm';
import type { AttachAddon as IAttachApi } from '@xterm/addon-attach';
interface IAttachOptions {
bidirectional?: boolean;
}
export class AttachAddon implements ITerminalAddon {
export class AttachAddon implements ITerminalAddon , IAttachApi {
private _socket: WebSocket;
private _bidirectional: boolean;
private _disposables: IDisposable[] = [];
+6 -1
View File
@@ -13,7 +13,12 @@
"strict": true,
"types": [
"../../../node_modules/@types/mocha"
]
],
"paths": {
"@xterm/addon-attach": [
"../typings/addon-attach.d.ts"
]
}
},
"include": [
"./**/*",
+7 -2
View File
@@ -3,16 +3,17 @@
* @license MIT
*/
import type { ITerminalAddon, Terminal } from '@xterm/xterm';
import type { CanvasAddon as ICanvasApi } from '@xterm/addon-canvas';
import { ICharacterJoinerService, ICharSizeService, ICoreBrowserService, IRenderService, IThemeService } from 'browser/services/Services';
import { ITerminal } from 'browser/Types';
import { EventEmitter, forwardEvent } from 'common/EventEmitter';
import { Disposable, toDisposable } from 'common/Lifecycle';
import { setTraceLogger } from 'common/services/LogService';
import { IBufferService, IDecorationService, ILogService } from 'common/services/Services';
import { ITerminalAddon, Terminal } from '@xterm/xterm';
import { CanvasRenderer } from './CanvasRenderer';
export class CanvasAddon extends Disposable implements ITerminalAddon {
export class CanvasAddon extends Disposable implements ITerminalAddon , ICanvasApi {
private _terminal?: Terminal;
private _renderer?: CanvasRenderer;
@@ -65,4 +66,8 @@ export class CanvasAddon extends Disposable implements ITerminalAddon {
this._renderer = undefined;
}));
}
public clearTextureAtlas(): void {
this._renderer?.clearTextureAtlas();
}
}
+3
View File
@@ -17,6 +17,9 @@
],
"browser/*": [
"../../../src/browser/*"
],
"@xterm/addon-canvas": [
"../typings/addon-canvas.d.ts"
]
},
"strict": true,
+3 -2
View File
@@ -3,7 +3,8 @@
* @license MIT
*/
import { Terminal, ITerminalAddon } from '@xterm/xterm';
import type { Terminal, ITerminalAddon } from '@xterm/xterm';
import type { FitAddon as IFitApi } from '@xterm/addon-fit';
import { IRenderDimensions } from 'browser/renderer/shared/Types';
interface ITerminalDimensions {
@@ -21,7 +22,7 @@ interface ITerminalDimensions {
const MINIMUM_COLS = 2;
const MINIMUM_ROWS = 1;
export class FitAddon implements ITerminalAddon {
export class FitAddon implements ITerminalAddon , IFitApi {
private _terminal: Terminal | undefined;
public activate(terminal: Terminal): void {
+3
View File
@@ -17,6 +17,9 @@
"paths": {
"browser/*": [
"../../../src/browser/*"
],
"@xterm/addon-fit": [
"../typings/addon-fit.d.ts"
]
}
},
+3 -3
View File
@@ -3,14 +3,14 @@
* @license MIT
*/
import type { ITerminalAddon, IDisposable } from '@xterm/xterm';
import type { ImageAddon as IImageApi } from '@xterm/addon-image';
import { IIPHandler } from './IIPHandler';
import { ITerminalAddon, IDisposable } from '@xterm/xterm';
import { ImageRenderer } from './ImageRenderer';
import { ImageStorage, CELL_SIZE_DEFAULT } from './ImageStorage';
import { SixelHandler } from './SixelHandler';
import { ITerminalExt, IImageAddonOptions, IResetHandler } from './Types';
// default values of addon ctor options
const DEFAULT_OPTIONS: IImageAddonOptions = {
enableSizeReports: true,
@@ -48,7 +48,7 @@ const enum GaStatus {
}
export class ImageAddon implements ITerminalAddon {
export class ImageAddon implements ITerminalAddon , IImageApi {
private _opts: IImageAddonOptions;
private _defaultOpts: IImageAddonOptions;
private _storage: ImageStorage | undefined;
+2 -1
View File
@@ -14,7 +14,8 @@
"baseUrl": ".",
"paths": {
"browser/*": [ "../../../src/browser/*" ],
"common/*": [ "../../../src/common/*" ]
"common/*": [ "../../../src/common/*" ],
"@xterm/addon-image": [ "../typings/addon-image.d.ts" ]
}
},
"include": [
+3 -2
View File
@@ -3,7 +3,8 @@
* @license MIT
*/
import { Terminal } from '@xterm/xterm';
import type { Terminal } from '@xterm/xterm';
import type { LigaturesAddon as ILigaturesApi } from '@xterm/addon-ligatures';
import { enableLigatures } from '.';
import { ILigatureOptions } from './Types';
@@ -12,7 +13,7 @@ export interface ITerminalAddon {
dispose(): void;
}
export class LigaturesAddon implements ITerminalAddon {
export class LigaturesAddon implements ITerminalAddon , ILigaturesApi {
private readonly _fallbackLigatures: string[];
private _terminal: Terminal | undefined;
+6 -1
View File
@@ -10,7 +10,12 @@
"preserveWatchOutput": true,
"types": [
"../../../node_modules/@types/mocha"
]
],
"paths": {
"@xterm/addon-ligatures" : [
"../typings/addon-ligatures.d.ts"
]
}
},
"include": [
"./**/*",
+1 -2
View File
@@ -15,8 +15,7 @@
"xterm.js"
],
"scripts": {
"build": "../../node_modules/.bin/tsc -p .",
"prepackage": "npm run build",
"prepackage": "../../node_modules/.bin/tsc -p .",
"package": "../../node_modules/.bin/webpack",
"prepublishOnly": "npm run package"
},
+3 -2
View File
@@ -3,7 +3,8 @@
* @license MIT
*/
import { Terminal, IDisposable, ITerminalAddon, IDecoration } from '@xterm/xterm';
import type { Terminal, IDisposable, ITerminalAddon, IDecoration } from '@xterm/xterm';
import type { SearchAddon as ISearchApi } from '@xterm/addon-search';
import { EventEmitter } from 'common/EventEmitter';
import { Disposable, toDisposable, disposeArray, MutableDisposable } from 'common/Lifecycle';
@@ -61,7 +62,7 @@ const NON_WORD_CHARACTERS = ' ~!@#$%^&*()+`-=[]{}|\\;:"\',./<>?';
const LINES_CACHE_TIME_TO_LIVE = 15 * 1000; // 15 secs
const DEFAULT_HIGHLIGHT_LIMIT = 1000;
export class SearchAddon extends Disposable implements ITerminalAddon {
export class SearchAddon extends Disposable implements ITerminalAddon , ISearchApi {
private _terminal: Terminal | undefined;
private _cachedSearchTerm: string | undefined;
private _highlightedLines: Set<number> = new Set();
+3
View File
@@ -17,6 +17,9 @@
"paths": {
"common/*": [
"../../../src/common/*"
],
"@xterm/addon-search" : [
"../typings/addon-search.d.ts"
]
}
},
@@ -14,7 +14,10 @@
"paths": {
"common/*": ["../../../src/common/*"],
"browser/*": ["../../../src/browser/*"],
"SerializeAddon": ["../src/SerializeAddon"]
"SerializeAddon": ["../src/SerializeAddon"],
"@xterm/addon-serialize": [
"../typings/addon-serialize.d.ts"
]
}
},
"include": ["../**/*", "../../../typings/xterm.d.ts"],
+3 -2
View File
@@ -5,9 +5,10 @@
* (EXPERIMENTAL) This Addon is still under development
*/
import type { IBuffer, IBufferCell, IBufferRange, ITerminalAddon, Terminal } from '@xterm/xterm';
import type { SerializeAddon as ISerializeApi } from '@xterm/addon-serialize';
import { DEFAULT_ANSI_COLORS } from 'browser/services/ThemeService';
import { IAttributeData, IColor } from 'common/Types';
import { IBuffer, IBufferCell, IBufferRange, ITerminalAddon, Terminal } from '@xterm/xterm';
function constrain(value: number, low: number, high: number): number {
return Math.max(low, Math.min(value, high));
@@ -411,7 +412,7 @@ class StringSerializeHandler extends BaseSerializeHandler {
}
}
export class SerializeAddon implements ITerminalAddon {
export class SerializeAddon implements ITerminalAddon , ISerializeApi {
private _terminal: Terminal | undefined;
public activate(terminal: Terminal): void {
+3
View File
@@ -17,6 +17,9 @@
],
"browser/*": [
"../../../src/browser/*"
],
"@xterm/addon-serialize": [
"../typings/addon-serialize.d.ts"
]
},
"strict": true,
@@ -11,7 +11,10 @@
"paths": {
"common/*": ["../../../src/common/*"],
"browser/*": ["../../../src/browser/*"],
"UnicodeGraphemeProvider": ["../src/UnicodeGraphemeProvider"]
"UnicodeGraphemeProvider": ["../src/UnicodeGraphemeProvider"],
"@xterm/addon-unicode-graphemes": [
"../typings/addon-unicode-graphemes.d.ts"
]
}
},
"include": ["../**/*", "../../../typings/xterm.d.ts"],
@@ -5,11 +5,11 @@
* UnicodeVersionProvider for V15 with grapeme cluster handleing.
*/
import { Terminal, ITerminalAddon, IUnicodeHandling } from '@xterm/xterm';
import type { Terminal, ITerminalAddon, IUnicodeHandling } from '@xterm/xterm';
import type { UnicodeGraphemesAddon as IUnicodeGraphemesApi } from '@xterm/addon-unicode-graphemes';
import { UnicodeGraphemeProvider } from './UnicodeGraphemeProvider';
export class UnicodeGraphemesAddon implements ITerminalAddon {
export class UnicodeGraphemesAddon implements ITerminalAddon , IUnicodeGraphemesApi {
private _provider15Graphemes?: UnicodeGraphemeProvider;
private _provider15?: UnicodeGraphemeProvider;
private _unicode?: IUnicodeHandling;
@@ -15,6 +15,9 @@
"paths": {
"common/*": [
"../../../src/common/*"
],
"@xterm/addon-unicode-graphemes": [
"../typings/addon-unicode-graphemes.d.ts"
]
},
"types": [
+3 -3
View File
@@ -5,11 +5,11 @@
* UnicodeVersionProvider for V11.
*/
import { Terminal, ITerminalAddon } from '@xterm/xterm';
import type { Terminal, ITerminalAddon } from '@xterm/xterm';
import type { Unicode11Addon as IUnicode11Api } from '@xterm/addon-unicode11';
import { UnicodeV11 } from './UnicodeV11';
export class Unicode11Addon implements ITerminalAddon {
export class Unicode11Addon implements ITerminalAddon , IUnicode11Api {
public activate(terminal: Terminal): void {
terminal.unicode.register(new UnicodeV11());
}

Some files were not shown because too many files have changed in this diff Show More