Use scoped packages, fix some typing issues

This commit is contained in:
Daniel Imms
2019-06-01 15:07:59 -07:00
parent 6817a20092
commit 6c18f5c1fe
37 changed files with 124 additions and 129 deletions
@@ -1,5 +1,5 @@
{
"name": "xterm-addon-attach",
"name": "@xterm/addon-attach",
"version": "0.1.0-beta8",
"author": {
"name": "The xterm.js authors",
@@ -12,11 +12,6 @@ interface IAttachOptions {
inputUtf8?: boolean;
}
// TODO: To be removed once UTF8 PR is in xterm.js package.
interface INewTerminal extends Terminal {
writeUtf8(data: Uint8Array): void;
}
export class AttachAddon implements ITerminalAddon {
private _socket: WebSocket;
private _bidirectional: boolean;
@@ -34,14 +29,14 @@ export class AttachAddon implements ITerminalAddon {
public activate(terminal: Terminal): void {
if (this._utf8) {
this._disposables.push(addSocketListener(this._socket, 'message',
(ev: MessageEvent | Event | CloseEvent) => (terminal as INewTerminal).writeUtf8(new Uint8Array((ev as any).data as ArrayBuffer))));
(ev: MessageEvent | Event | CloseEvent) => terminal.writeUtf8(new Uint8Array((ev as any).data as ArrayBuffer))));
} else {
this._disposables.push(addSocketListener(this._socket, 'message',
(ev: MessageEvent | Event | CloseEvent) => (terminal as INewTerminal).write((ev as any).data as string)));
(ev: MessageEvent | Event | CloseEvent) => terminal.write((ev as any).data as string)));
}
if (this._bidirectional) {
this._disposables.push(terminal.addDisposableListener('data', data => this._sendData(data)));
this._disposables.push(terminal.onData(data => this._sendData(data)));
}
this._disposables.push(addSocketListener(this._socket, 'close', () => this.dispose()));
@@ -14,6 +14,6 @@
},
"include": [
"./**/*",
"../../../typings/xterm.d.ts"
"../../../../typings/xterm.d.ts"
]
}
+29
View File
@@ -0,0 +1,29 @@
/**
* Copyright (c) 2017 The xterm.js authors. All rights reserved.
* @license MIT
*/
import { Terminal, ILinkMatcherOptions, ITerminalAddon } from 'xterm';
declare module '@xterm/addon-attach' {
export interface IAttachOptions {
/**
* Whether input should be written to the backend. Defaults to `true`.
*/
bidirectional?: boolean;
/**
* Whether to use UTF8 binary transport for incoming messages. Defaults to `false`.
* Note: This must be in line with the server side of the websocket.
* Always send string messages from the backend if this options is false,
* otherwise always binary UTF8 data.
*/
inputUtf8?: boolean;
}
export class AttachAddon implements ITerminalAddon {
constructor(socket: WebSocket, options?: IAttachOptions);
public activate(terminal: Terminal): void;
public dispose(): void;
}
}
@@ -1,5 +1,5 @@
{
"name": "xterm-addon-fit",
"name": "@xterm/addon-fit",
"version": "0.1.0-beta7",
"author": {
"name": "The xterm.js authors",
@@ -14,6 +14,6 @@
},
"include": [
"./**/*",
"../../../typings/xterm.d.ts"
"../../../../typings/xterm.d.ts"
]
}
@@ -5,7 +5,7 @@
import { Terminal, ITerminalAddon } from 'xterm';
declare module 'xterm-addon-fit' {
declare module '@xterm/addon-fit' {
/**
* An xterm.js addon that enables resizing the terminal to the dimensions of
* its containing element.
@@ -1,5 +1,5 @@
{
"name": "xterm-addon-search",
"name": "@xterm/addon-search",
"version": "0.1.0-beta4",
"author": {
"name": "The xterm.js authors",
@@ -13,6 +13,6 @@
},
"include": [
"./**/*",
"../../../typings/xterm.d.ts"
"../../../../typings/xterm.d.ts"
]
}
+68
View File
@@ -0,0 +1,68 @@
/**
* Copyright (c) 2017 The xterm.js authors. All rights reserved.
* @license MIT
*/
import { Terminal, ILinkMatcherOptions, IDisposable, ITerminalAddon } from 'xterm';
declare module '@xterm/addon-search' {
/**
* Options for a search.
*/
export interface ISearchOptions {
/**
* Whether the search term is a regex.
*/
regex?: boolean;
/**
* Whether to search for a whole word, the result is only valid if it's
* suppounded in "non-word" characters such as `_`, `(`, `)` or space.
*/
wholeWord?: boolean;
/**
* Whether the search is case sensitive.
*/
caseSensitive?: boolean;
/**
* Whether to do an indcremental search, this will expand the selection if it
* still matches the term the user typed. Note that this only affects
* `findNext`, not `findPrevious`.
*/
incremental?: boolean;
}
/**
* An xterm.js addon that provides search functionality.
*/
export class SearchAddon implements ITerminalAddon {
/**
* Activates the addon
* @param terminal The terminal the addon is being loaded in.
*/
public activate(terminal: Terminal): void;
/**
* Disposes the addon.
*/
public dispose(): void;
/**
* Search forwards for the next result that matches the search term and
* options.
* @param term The search term.
* @param searchOptions The options for the search.
*/
public findNext(term: string, searchOptions?: ISearchOptions): boolean;
/**
* Search backwards for the previous result that matches the search term and
* options.
* @param term The search term.
* @param searchOptions The options for the search.
*/
public findPrevious(term: string, searchOptions?: ISearchOptions): boolean;
}
}
@@ -1,5 +1,5 @@
{
"name": "xterm-addon-web-links",
"name": "@xtermaddon-web-links",
"version": "0.1.0-beta7",
"author": {
"name": "The xterm.js authors",
@@ -14,6 +14,6 @@
},
"include": [
"./**/*",
"../../../typings/xterm.d.ts"
"../../../../typings/xterm.d.ts"
]
}
@@ -6,7 +6,7 @@
import { Terminal, IDisposable, ILinkMatcherOptions } from 'xterm';
declare module 'xterm-addon-web-links' {
declare module '@xterm/addon-web-links' {
// TODO: This is temporary, link to xterm when the new version is published
export interface ITerminalAddon extends IDisposable {
activate(terminal: Terminal): void;
-27
View File
@@ -1,27 +0,0 @@
/**
* Copyright (c) 2017 The xterm.js authors. All rights reserved.
* @license MIT
*/
import { Terminal, ILinkMatcherOptions, ITerminalAddon } from 'xterm';
export interface IAttachOptions {
/**
* Whether input should be written to the backend. Defaults to `true`.
*/
bidirectional?: boolean;
/**
* Whether to use UTF8 binary transport for incoming messages. Defaults to `false`.
* Note: This must be in line with the server side of the websocket.
* Always send string messages from the backend if this options is false,
* otherwise always binary UTF8 data.
*/
inputUtf8?: boolean;
}
export class AttachAddon implements ITerminalAddon {
constructor(socket: WebSocket, options?: IAttachOptions);
public activate(terminal: Terminal): void;
public dispose(): void;
}
-71
View File
@@ -1,71 +0,0 @@
/**
* Copyright (c) 2017 The xterm.js authors. All rights reserved.
* @license MIT
*/
import { Terminal, ILinkMatcherOptions, IDisposable } from 'xterm';
// TODO: This is temporary, link to xterm when the new version is published
export interface ITerminalAddon extends IDisposable {
activate(terminal: Terminal): void;
}
/**
* Options for a search.
*/
export interface ISearchOptions {
/**
* Whether the search term is a regex.
*/
regex?: boolean;
/**
* Whether to search for a whole word, the result is only valid if it's
* suppounded in "non-word" characters such as `_`, `(`, `)` or space.
*/
wholeWord?: boolean;
/**
* Whether the search is case sensitive.
*/
caseSensitive?: boolean;
/**
* Whether to do an indcremental search, this will expand the selection if it
* still matches the term the user typed. Note that this only affects
* `findNext`, not `findPrevious`.
*/
incremental?: boolean;
}
/**
* An xterm.js addon that provides search functionality.
*/
export class SearchAddon implements ITerminalAddon {
/**
* Activates the addon
* @param terminal The terminal the addon is being loaded in.
*/
public activate(terminal: Terminal): void;
/**
* Disposes the addon.
*/
public dispose(): void;
/**
* Search forwards for the next result that matches the search term and
* options.
* @param term The search term.
* @param searchOptions The options for the search.
*/
public findNext(term: string, searchOptions?: ISearchOptions): boolean;
/**
* Search backwards for the previous result that matches the search term and
* options.
* @param term The search term.
* @param searchOptions The options for the search.
*/
public findPrevious(term: string, searchOptions?: ISearchOptions): boolean;
}
+4 -4
View File
@@ -12,10 +12,10 @@ import { Terminal } from '../out/public/Terminal';
// Use webpacked version (yarn package)
// import { Terminal } from '../lib/xterm';
import { AttachAddon } from 'xterm-addon-attach';
import { FitAddon } from 'xterm-addon-fit';
import { SearchAddon, ISearchOptions } from 'xterm-addon-search';
import { WebLinksAddon } from 'xterm-addon-web-links';
import { AttachAddon } from '@xterm/addon-attach';
import { FitAddon } from '@xterm/addon-fit';
import { SearchAddon, ISearchOptions } from '@xterm/addon-search';
import { WebLinksAddon } from '@xterm/addon-web-links';
// Pulling in the module's types relies on the <reference> above, it's looks a
// little weird here as we're importing "this" module
+4 -4
View File
@@ -6,10 +6,10 @@
"sourceMap": true,
"baseUrl": ".",
"paths": {
"xterm-addon-attach": ["../addons/xterm-addon-attach"],
"xterm-addon-fit": ["../addons/xterm-addon-fit"],
"xterm-addon-search": ["../addons/xterm-addon-search"],
"xterm-addon-web-links": ["../addons/xterm-addon-web-links"]
"@xterm/addon-attach": ["../addons/@xterm/addon-attach"],
"@xterm/addon-fit": ["../addons/@xterm/addon-fit"],
"@xterm/addon-search": ["../addons/@xterm/addon-search"],
"@xterm/addon-web-links": ["../addons/@xterm/addon-web-links"]
}
},
"include": [
+2 -1
View File
@@ -18,7 +18,8 @@
"build": "tsc -b ./tsconfig.all.json",
"prepare": "npm run build",
"prepublishOnly": "npm run package",
"watch": "tsc -b -w ./tsconfig.all.json --preserveWatchOutput"
"watch": "tsc -b -w ./tsconfig.all.json --preserveWatchOutput",
"clean": "rm -rf lib out addons/@xterm/*/lib"
},
"devDependencies": {
"@types/chai": "^3.4.34",
+4 -4
View File
@@ -3,9 +3,9 @@
"include": [],
"references": [
{ "path": "./src" },
{ "path": "./addons/xterm-addon-attach/src" },
{ "path": "./addons/xterm-addon-fit/src" },
{ "path": "./addons/xterm-addon-search/src" },
{ "path": "./addons/xterm-addon-web-links/src" }
{ "path": "./addons/@xterm/addon-attach/src" },
{ "path": "./addons/@xterm/addon-fit/src" },
{ "path": "./addons/@xterm/addon-search/src" },
{ "path": "./addons/@xterm/addon-web-links/src" }
]
}