add public api

This commit is contained in:
tisilent
2023-10-18 00:29:56 +08:00
parent 4245283e05
commit 7dab4601d2
19 changed files with 56 additions and 17 deletions
+2 -1
View File
@@ -6,12 +6,13 @@
*/ */
import { Terminal, IDisposable, ITerminalAddon } from 'xterm'; import { Terminal, IDisposable, ITerminalAddon } from 'xterm';
import { AttachAddon as IAttachApi } from 'xterm-addon-attach';
interface IAttachOptions { interface IAttachOptions {
bidirectional?: boolean; bidirectional?: boolean;
} }
export class AttachAddon implements ITerminalAddon { export class AttachAddon implements ITerminalAddon , IAttachApi {
private _socket: WebSocket; private _socket: WebSocket;
private _bidirectional: boolean; private _bidirectional: boolean;
private _disposables: IDisposable[] = []; private _disposables: IDisposable[] = [];
+6 -1
View File
@@ -13,7 +13,12 @@
"strict": true, "strict": true,
"types": [ "types": [
"../../../node_modules/@types/mocha" "../../../node_modules/@types/mocha"
] ],
"paths": {
"xterm-addon-attach": [
"../typings/xterm-addon-attach.d.ts"
]
}
}, },
"include": [ "include": [
"./**/*", "./**/*",
+6 -1
View File
@@ -11,8 +11,9 @@ import { setTraceLogger } from 'common/services/LogService';
import { IBufferService, IDecorationService, ILogService } from 'common/services/Services'; import { IBufferService, IDecorationService, ILogService } from 'common/services/Services';
import { ITerminalAddon, Terminal } from 'xterm'; import { ITerminalAddon, Terminal } from 'xterm';
import { CanvasRenderer } from './CanvasRenderer'; import { CanvasRenderer } from './CanvasRenderer';
import { CanvasAddon as ICanvasApi } from 'xterm-addon-canvas';
export class CanvasAddon extends Disposable implements ITerminalAddon { export class CanvasAddon extends Disposable implements ITerminalAddon , ICanvasApi {
private _terminal?: Terminal; private _terminal?: Terminal;
private _renderer?: CanvasRenderer; private _renderer?: CanvasRenderer;
@@ -65,4 +66,8 @@ export class CanvasAddon extends Disposable implements ITerminalAddon {
this._renderer = undefined; this._renderer = undefined;
})); }));
} }
public clearTextureAtlas(): void {
this._renderer?.clearTextureAtlas();
}
} }
@@ -17,6 +17,9 @@
], ],
"browser/*": [ "browser/*": [
"../../../src/browser/*" "../../../src/browser/*"
],
"xterm-addon-canvas": [
"../typings/xterm-addon-canvas.d.ts"
] ]
}, },
"strict": true, "strict": true,
+2 -1
View File
@@ -5,6 +5,7 @@
import { Terminal, ITerminalAddon } from 'xterm'; import { Terminal, ITerminalAddon } from 'xterm';
import { IRenderDimensions } from 'browser/renderer/shared/Types'; import { IRenderDimensions } from 'browser/renderer/shared/Types';
import { FitAddon as IFitApi } from 'xterm-addon-fit';
interface ITerminalDimensions { interface ITerminalDimensions {
/** /**
@@ -21,7 +22,7 @@ interface ITerminalDimensions {
const MINIMUM_COLS = 2; const MINIMUM_COLS = 2;
const MINIMUM_ROWS = 1; const MINIMUM_ROWS = 1;
export class FitAddon implements ITerminalAddon { export class FitAddon implements ITerminalAddon , IFitApi {
private _terminal: Terminal | undefined; private _terminal: Terminal | undefined;
public activate(terminal: Terminal): void { public activate(terminal: Terminal): void {
+3
View File
@@ -17,6 +17,9 @@
"paths": { "paths": {
"browser/*": [ "browser/*": [
"../../../src/browser/*" "../../../src/browser/*"
],
"xterm-addon-fit": [
"../typings/xterm-addon-fit.d.ts"
] ]
} }
}, },
+2 -2
View File
@@ -9,7 +9,7 @@ import { ImageRenderer } from './ImageRenderer';
import { ImageStorage, CELL_SIZE_DEFAULT } from './ImageStorage'; import { ImageStorage, CELL_SIZE_DEFAULT } from './ImageStorage';
import { SixelHandler } from './SixelHandler'; import { SixelHandler } from './SixelHandler';
import { ITerminalExt, IImageAddonOptions, IResetHandler } from './Types'; import { ITerminalExt, IImageAddonOptions, IResetHandler } from './Types';
import { ImageAddon as IImageApi } from 'xterm-addon-image'
// default values of addon ctor options // default values of addon ctor options
const DEFAULT_OPTIONS: IImageAddonOptions = { const DEFAULT_OPTIONS: IImageAddonOptions = {
@@ -48,7 +48,7 @@ const enum GaStatus {
} }
export class ImageAddon implements ITerminalAddon { export class ImageAddon implements ITerminalAddon , IImageApi {
private _opts: IImageAddonOptions; private _opts: IImageAddonOptions;
private _defaultOpts: IImageAddonOptions; private _defaultOpts: IImageAddonOptions;
private _storage: ImageStorage | undefined; private _storage: ImageStorage | undefined;
+2 -1
View File
@@ -14,7 +14,8 @@
"baseUrl": ".", "baseUrl": ".",
"paths": { "paths": {
"browser/*": [ "../../../src/browser/*" ], "browser/*": [ "../../../src/browser/*" ],
"common/*": [ "../../../src/common/*" ] "common/*": [ "../../../src/common/*" ],
"xterm-addon-image": [ "../typings/xterm-addon-image.d.ts" ]
} }
}, },
"include": [ "include": [
@@ -6,13 +6,14 @@
import { Terminal } from 'xterm'; import { Terminal } from 'xterm';
import { enableLigatures } from '.'; import { enableLigatures } from '.';
import { ILigatureOptions } from './Types'; import { ILigatureOptions } from './Types';
import { LigaturesAddon as ILigaturesApi } from 'xterm-addon-ligatures';
export interface ITerminalAddon { export interface ITerminalAddon {
activate(terminal: Terminal): void; activate(terminal: Terminal): void;
dispose(): void; dispose(): void;
} }
export class LigaturesAddon implements ITerminalAddon { export class LigaturesAddon implements ITerminalAddon , ILigaturesApi {
private readonly _fallbackLigatures: string[]; private readonly _fallbackLigatures: string[];
private _terminal: Terminal | undefined; private _terminal: Terminal | undefined;
@@ -10,7 +10,10 @@
"preserveWatchOutput": true, "preserveWatchOutput": true,
"types": [ "types": [
"../../../node_modules/@types/mocha" "../../../node_modules/@types/mocha"
] ],
"paths": {
"xterm-addon-ligatures" : [ "../typings/xterm-addon-ligatures.d.ts" ]
}
}, },
"include": [ "include": [
"./**/*", "./**/*",
+1 -2
View File
@@ -15,8 +15,7 @@
"xterm.js" "xterm.js"
], ],
"scripts": { "scripts": {
"build": "../../node_modules/.bin/tsc -p .", "prepackage": "../../node_modules/.bin/tsc -p .",
"prepackage": "npm run build",
"package": "../../node_modules/.bin/webpack", "package": "../../node_modules/.bin/webpack",
"prepublishOnly": "npm run package" "prepublishOnly": "npm run package"
}, },
+2 -1
View File
@@ -6,6 +6,7 @@
import { Terminal, IDisposable, ITerminalAddon, IDecoration } from 'xterm'; import { Terminal, IDisposable, ITerminalAddon, IDecoration } from 'xterm';
import { EventEmitter } from 'common/EventEmitter'; import { EventEmitter } from 'common/EventEmitter';
import { Disposable, toDisposable, disposeArray, MutableDisposable } from 'common/Lifecycle'; import { Disposable, toDisposable, disposeArray, MutableDisposable } from 'common/Lifecycle';
import { SearchAddon as ISearchApi } from 'xterm-addon-search';
export interface ISearchOptions { export interface ISearchOptions {
regex?: boolean; regex?: boolean;
@@ -61,7 +62,7 @@ const NON_WORD_CHARACTERS = ' ~!@#$%^&*()+`-=[]{}|\\;:"\',./<>?';
const LINES_CACHE_TIME_TO_LIVE = 15 * 1000; // 15 secs const LINES_CACHE_TIME_TO_LIVE = 15 * 1000; // 15 secs
const DEFAULT_HIGHLIGHT_LIMIT = 1000; 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 _terminal: Terminal | undefined;
private _cachedSearchTerm: string | undefined; private _cachedSearchTerm: string | undefined;
private _highlightedLines: Set<number> = new Set(); private _highlightedLines: Set<number> = new Set();
@@ -17,6 +17,9 @@
"paths": { "paths": {
"common/*": [ "common/*": [
"../../../src/common/*" "../../../src/common/*"
],
"xterm-addon-search" : [
"../typings/xterm-addon-search.d.ts"
] ]
} }
}, },
@@ -7,9 +7,9 @@
import { Terminal, ITerminalAddon } from 'xterm'; import { Terminal, ITerminalAddon } from 'xterm';
import { UnicodeV11 } from './UnicodeV11'; import { UnicodeV11 } from './UnicodeV11';
import { Unicode11Addon as IUnicode11Api } from 'xterm-addon-unicode11';
export class Unicode11Addon implements ITerminalAddon , IUnicode11Api {
export class Unicode11Addon implements ITerminalAddon {
public activate(terminal: Terminal): void { public activate(terminal: Terminal): void {
terminal.unicode.register(new UnicodeV11()); terminal.unicode.register(new UnicodeV11());
} }
@@ -15,6 +15,9 @@
"paths": { "paths": {
"common/*": [ "common/*": [
"../../../src/common/*" "../../../src/common/*"
],
"xterm-addon-unicode11": [
"../typings/xterm-addon-unicode11.d.ts"
] ]
}, },
"types": [ "types": [
@@ -4,6 +4,7 @@
*/ */
import { Terminal, ITerminalAddon, IDisposable } from 'xterm'; import { Terminal, ITerminalAddon, IDisposable } from 'xterm';
import { WebLinksAddon as IWebLinksApi } from 'xterm-addon-web-links';
import { ILinkProviderOptions, WebLinkProvider } from './WebLinkProvider'; import { ILinkProviderOptions, WebLinkProvider } from './WebLinkProvider';
// consider everthing starting with http:// or https:// // consider everthing starting with http:// or https://
@@ -34,7 +35,7 @@ function handleLink(event: MouseEvent, uri: string): void {
} }
} }
export class WebLinksAddon implements ITerminalAddon { export class WebLinksAddon implements ITerminalAddon , IWebLinksApi {
private _terminal: Terminal | undefined; private _terminal: Terminal | undefined;
private _linkProvider: IDisposable | undefined; private _linkProvider: IDisposable | undefined;
@@ -13,7 +13,12 @@
"strict": true, "strict": true,
"types": [ "types": [
"../../../node_modules/@types/mocha" "../../../node_modules/@types/mocha"
] ],
"paths": {
"xterm-addon-web-links": [
"../typings/xterm-addon-web-links.d.ts"
]
}
}, },
"include": [ "include": [
"./**/*", "./**/*",
+2 -1
View File
@@ -10,10 +10,11 @@ import { Disposable, toDisposable } from 'common/Lifecycle';
import { getSafariVersion, isSafari } from 'common/Platform'; import { getSafariVersion, isSafari } from 'common/Platform';
import { ICoreService, IDecorationService, ILogService, IOptionsService } from 'common/services/Services'; import { ICoreService, IDecorationService, ILogService, IOptionsService } from 'common/services/Services';
import { ITerminalAddon, Terminal } from 'xterm'; import { ITerminalAddon, Terminal } from 'xterm';
import { WebglAddon as IWebglApi } from 'xterm-addon-webgl';
import { WebglRenderer } from './WebglRenderer'; import { WebglRenderer } from './WebglRenderer';
import { setTraceLogger } from 'common/services/LogService'; import { setTraceLogger } from 'common/services/LogService';
export class WebglAddon extends Disposable implements ITerminalAddon { export class WebglAddon extends Disposable implements ITerminalAddon , IWebglApi {
private _terminal?: Terminal; private _terminal?: Terminal;
private _renderer?: WebglRenderer; private _renderer?: WebglRenderer;
@@ -17,6 +17,9 @@
], ],
"browser/*": [ "browser/*": [
"../../../src/browser/*" "../../../src/browser/*"
],
"xterm-addon-webgl": [
"../typings/xterm-addon-webgl.d.ts"
] ]
}, },
"strict": true, "strict": true,