Merge pull request #5514 from Tyriar/demo6
Ensure types are checked in demo, fix errors, emit to out-demo
This commit is contained in:
@@ -3,6 +3,7 @@ node_modules/
|
|||||||
.lock-wscript
|
.lock-wscript
|
||||||
lib/
|
lib/
|
||||||
out/
|
out/
|
||||||
|
out-demo/
|
||||||
out-test/
|
out-test/
|
||||||
out-esbuild/
|
out-esbuild/
|
||||||
out-esbuild-test/
|
out-esbuild-test/
|
||||||
|
|||||||
+19
-24
@@ -5,19 +5,15 @@
|
|||||||
* This file is the entry point for browserify.
|
* This file is the entry point for browserify.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/// <reference path="../typings/xterm.d.ts"/>
|
|
||||||
|
|
||||||
/* eslint-disable no-restricted-syntax */
|
|
||||||
|
|
||||||
// HACK: Playwright/WebKit on Windows does not support WebAssembly https://stackoverflow.com/q/62311688/1156119
|
// HACK: Playwright/WebKit on Windows does not support WebAssembly https://stackoverflow.com/q/62311688/1156119
|
||||||
import type { ImageAddon as ImageAddonType, IImageAddonOptions } from '@xterm/addon-image';
|
import type { ImageAddon as ImageAddonType } from '@xterm/addon-image';
|
||||||
let ImageAddon: typeof ImageAddonType | undefined; // eslint-disable-line @typescript-eslint/naming-convention
|
let ImageAddon: typeof ImageAddonType | undefined; // eslint-disable-line @typescript-eslint/naming-convention
|
||||||
if ('WebAssembly' in window) {
|
if ('WebAssembly' in window) {
|
||||||
const imageAddon = require('@xterm/addon-image');
|
const imageAddon = require('@xterm/addon-image');
|
||||||
ImageAddon = imageAddon.ImageAddon;
|
ImageAddon = imageAddon.ImageAddon;
|
||||||
}
|
}
|
||||||
|
|
||||||
import { Terminal, ITerminalOptions, type IDisposable, type ITheme } from '@xterm/xterm';
|
import { Terminal, ITerminalOptions, type ITheme } from '@xterm/xterm';
|
||||||
import { AttachAddon } from '@xterm/addon-attach';
|
import { AttachAddon } from '@xterm/addon-attach';
|
||||||
import { AddonsWindow } from './components/window/addonsWindow';
|
import { AddonsWindow } from './components/window/addonsWindow';
|
||||||
import { ControlBar } from './components/controlBar';
|
import { ControlBar } from './components/controlBar';
|
||||||
@@ -29,31 +25,30 @@ import { VtWindow } from './components/window/vtWindow';
|
|||||||
import { ClipboardAddon } from '@xterm/addon-clipboard';
|
import { ClipboardAddon } from '@xterm/addon-clipboard';
|
||||||
import { FitAddon } from '@xterm/addon-fit';
|
import { FitAddon } from '@xterm/addon-fit';
|
||||||
import { LigaturesAddon } from '@xterm/addon-ligatures';
|
import { LigaturesAddon } from '@xterm/addon-ligatures';
|
||||||
import { ProgressAddon, IProgressState } from '@xterm/addon-progress';
|
import { ProgressAddon } from '@xterm/addon-progress';
|
||||||
import { SearchAddon, ISearchOptions } from '@xterm/addon-search';
|
import { SearchAddon, ISearchOptions } from '@xterm/addon-search';
|
||||||
import { SerializeAddon } from '@xterm/addon-serialize';
|
import { SerializeAddon } from '@xterm/addon-serialize';
|
||||||
import { WebLinksAddon } from '@xterm/addon-web-links';
|
import { WebLinksAddon } from '@xterm/addon-web-links';
|
||||||
import { WebglAddon } from '@xterm/addon-webgl';
|
import { WebglAddon } from '@xterm/addon-webgl';
|
||||||
import { Unicode11Addon } from '@xterm/addon-unicode11';
|
import { Unicode11Addon } from '@xterm/addon-unicode11';
|
||||||
import { UnicodeGraphemesAddon } from '@xterm/addon-unicode-graphemes';
|
import { UnicodeGraphemesAddon } from '@xterm/addon-unicode-graphemes';
|
||||||
|
|
||||||
import { AddonCollection, type AddonType, type IDemoAddon } from './types';
|
import { AddonCollection, type AddonType, type IDemoAddon } from './types';
|
||||||
|
|
||||||
export interface IWindowWithTerminal extends Window {
|
export interface IWindowWithTerminal extends Window {
|
||||||
term: typeof Terminal;
|
term: typeof Terminal;
|
||||||
Terminal: typeof Terminal;
|
Terminal: typeof Terminal;
|
||||||
AttachAddon?: typeof AttachAddon; // eslint-disable-line @typescript-eslint/naming-convention
|
AttachAddon?: typeof AttachAddon;
|
||||||
ClipboardAddon?: typeof ClipboardAddon; // eslint-disable-line @typescript-eslint/naming-convention
|
ClipboardAddon?: typeof ClipboardAddon;
|
||||||
FitAddon?: typeof FitAddon; // eslint-disable-line @typescript-eslint/naming-convention
|
FitAddon?: typeof FitAddon;
|
||||||
ImageAddon?: typeof ImageAddon; // eslint-disable-line @typescript-eslint/naming-convention
|
ImageAddon?: typeof ImageAddon;
|
||||||
ProgressAddon?: typeof ProgressAddon; // eslint-disable-line @typescript-eslint/naming-convention
|
ProgressAddon?: typeof ProgressAddon;
|
||||||
SearchAddon?: typeof SearchAddon; // eslint-disable-line @typescript-eslint/naming-convention
|
SearchAddon?: typeof SearchAddon;
|
||||||
SerializeAddon?: typeof SerializeAddon; // eslint-disable-line @typescript-eslint/naming-convention
|
SerializeAddon?: typeof SerializeAddon;
|
||||||
WebLinksAddon?: typeof WebLinksAddon; // eslint-disable-line @typescript-eslint/naming-convention
|
WebLinksAddon?: typeof WebLinksAddon;
|
||||||
WebglAddon?: typeof WebglAddon; // eslint-disable-line @typescript-eslint/naming-convention
|
WebglAddon?: typeof WebglAddon;
|
||||||
Unicode11Addon?: typeof Unicode11Addon; // eslint-disable-line @typescript-eslint/naming-convention
|
Unicode11Addon?: typeof Unicode11Addon;
|
||||||
UnicodeGraphemesAddon?: typeof UnicodeGraphemesAddon; // eslint-disable-line @typescript-eslint/naming-convention
|
UnicodeGraphemesAddon?: typeof UnicodeGraphemesAddon;
|
||||||
LigaturesAddon?: typeof LigaturesAddon; // eslint-disable-line @typescript-eslint/naming-convention
|
LigaturesAddon?: typeof LigaturesAddon;
|
||||||
}
|
}
|
||||||
declare let window: IWindowWithTerminal;
|
declare let window: IWindowWithTerminal;
|
||||||
|
|
||||||
@@ -203,7 +198,7 @@ if (document.location.pathname === '/test') {
|
|||||||
window.WebglAddon = WebglAddon;
|
window.WebglAddon = WebglAddon;
|
||||||
} else {
|
} else {
|
||||||
const typedTerm = createTerminal();
|
const typedTerm = createTerminal();
|
||||||
|
|
||||||
controlBar = new ControlBar(document.getElementById('sidebar'), document.querySelector('.banner-tabs'), []);
|
controlBar = new ControlBar(document.getElementById('sidebar'), document.querySelector('.banner-tabs'), []);
|
||||||
addonsWindow = controlBar.registerWindow(new AddonsWindow(typedTerm, addons));
|
addonsWindow = controlBar.registerWindow(new AddonsWindow(typedTerm, addons));
|
||||||
actionElements = {
|
actionElements = {
|
||||||
@@ -217,7 +212,7 @@ if (document.location.pathname === '/test') {
|
|||||||
controlBar.registerWindow(new TestWindow(typedTerm, addons, { disposeRecreateButtonHandler, createNewWindowButtonHandler }));
|
controlBar.registerWindow(new TestWindow(typedTerm, addons, { disposeRecreateButtonHandler, createNewWindowButtonHandler }));
|
||||||
controlBar.registerWindow(new VtWindow(typedTerm, addons));
|
controlBar.registerWindow(new VtWindow(typedTerm, addons));
|
||||||
controlBar.activateDefaultTab();
|
controlBar.activateDefaultTab();
|
||||||
|
|
||||||
// TODO: Most of below should be encapsulated within windows
|
// TODO: Most of below should be encapsulated within windows
|
||||||
paddingElement = styleWindow.paddingElement;
|
paddingElement = styleWindow.paddingElement;
|
||||||
|
|
||||||
@@ -226,7 +221,7 @@ if (document.location.pathname === '/test') {
|
|||||||
addons.webgl.instance.onChangeTextureAtlas(e => gpuWindow.setTextureAtlas(e));
|
addons.webgl.instance.onChangeTextureAtlas(e => gpuWindow.setTextureAtlas(e));
|
||||||
addons.webgl.instance.onAddTextureAtlasCanvas(e => gpuWindow.appendTextureAtlas(e));
|
addons.webgl.instance.onAddTextureAtlasCanvas(e => gpuWindow.appendTextureAtlas(e));
|
||||||
addons.webgl.instance.onRemoveTextureAtlasCanvas(e => gpuWindow.removeTextureAtlas(e));
|
addons.webgl.instance.onRemoveTextureAtlasCanvas(e => gpuWindow.removeTextureAtlas(e));
|
||||||
|
|
||||||
paddingElement.value = '0';
|
paddingElement.value = '0';
|
||||||
addDomListener(paddingElement, 'change', setPadding);
|
addDomListener(paddingElement, 'change', setPadding);
|
||||||
addDomListener(actionElements.findNext, 'keydown', (e) => {
|
addDomListener(actionElements.findNext, 'keydown', (e) => {
|
||||||
@@ -576,7 +571,7 @@ function updateTerminalSize(): void {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
if (source instanceof HTMLCanvasElement) {
|
if (source instanceof HTMLCanvasElement) {
|
||||||
source = source.getContext('2d')?.getImageData(0, 0, source.width, source.height)!;
|
source = source.getContext('2d')!.getImageData(0, 0, source.width, source.height)!;
|
||||||
}
|
}
|
||||||
const canvas = document.createElement('canvas');
|
const canvas = document.createElement('canvas');
|
||||||
canvas.width = source.width;
|
canvas.width = source.width;
|
||||||
|
|||||||
@@ -3,10 +3,7 @@
|
|||||||
* @license MIT
|
* @license MIT
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/// <reference path="../../typings/xterm.d.ts"/>
|
|
||||||
|
|
||||||
import type { Terminal } from '@xterm/xterm';
|
import type { Terminal } from '@xterm/xterm';
|
||||||
import type { AddonCollection } from 'types';
|
|
||||||
|
|
||||||
export interface ITabConfig {
|
export interface ITabConfig {
|
||||||
id: string;
|
id: string;
|
||||||
@@ -28,7 +25,7 @@ export class ControlBar {
|
|||||||
private _resizeMode: 'none' | 'horizontal' | 'vertical' | 'corner' = 'none';
|
private _resizeMode: 'none' | 'horizontal' | 'vertical' | 'corner' = 'none';
|
||||||
|
|
||||||
private readonly _tabContainer: HTMLElement;
|
private readonly _tabContainer: HTMLElement;
|
||||||
private readonly _tabs: Map<string, { button: HTMLButtonElement; content: HTMLElement }> = new Map();
|
private readonly _tabs: Map<string, { button: HTMLButtonElement, content: HTMLElement }> = new Map();
|
||||||
private _activeTabId: string | null = null;
|
private _activeTabId: string | null = null;
|
||||||
|
|
||||||
constructor(sidebar: HTMLElement, tabContainer: HTMLElement, tabs: ITabConfig[]) {
|
constructor(sidebar: HTMLElement, tabContainer: HTMLElement, tabs: ITabConfig[]) {
|
||||||
@@ -152,7 +149,7 @@ export class ControlBar {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public registerWindow<T extends IControlWindow>(window: T, options?: { afterId?: string; hidden?: boolean; smallTab?: boolean }): T {
|
public registerWindow<T extends IControlWindow>(window: T, options?: { afterId?: string, hidden?: boolean, smallTab?: boolean }): T {
|
||||||
// Create button
|
// Create button
|
||||||
const button = document.createElement('button');
|
const button = document.createElement('button');
|
||||||
button.id = `${window.id}button`;
|
button.id = `${window.id}button`;
|
||||||
|
|||||||
@@ -3,13 +3,10 @@
|
|||||||
* @license MIT
|
* @license MIT
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/// <reference path="../../../typings/xterm.d.ts"/>
|
|
||||||
|
|
||||||
import type { Terminal } from '@xterm/xterm';
|
import type { Terminal } from '@xterm/xterm';
|
||||||
import { BaseWindow } from './baseWindow';
|
import { BaseWindow } from './baseWindow';
|
||||||
import type { IControlWindow } from '../controlBar';
|
import type { IControlWindow } from '../controlBar';
|
||||||
import type { AddonCollection } from 'types';
|
import type { AddonCollection } from '../../types';
|
||||||
import type { IImageAddonOptions } from '@xterm/addon-image';
|
|
||||||
|
|
||||||
export class AddonsWindow extends BaseWindow implements IControlWindow {
|
export class AddonsWindow extends BaseWindow implements IControlWindow {
|
||||||
public readonly id = 'addons';
|
public readonly id = 'addons';
|
||||||
@@ -277,4 +274,4 @@ function htmlSerializeButtonHandler(term: Terminal, addons: AddonCollection): vo
|
|||||||
document.execCommand('copy');
|
document.execCommand('copy');
|
||||||
document.removeEventListener('copy', listener);
|
document.removeEventListener('copy', listener);
|
||||||
document.getElementById('htmlserialize-output-result').innerText = 'Copied to clipboard';
|
document.getElementById('htmlserialize-output-result').innerText = 'Copied to clipboard';
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,27 +3,25 @@
|
|||||||
* @license MIT
|
* @license MIT
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/// <reference path="../../../typings/xterm.d.ts"/>
|
|
||||||
|
|
||||||
import type { AddonCollection } from '../../types';
|
import type { AddonCollection } from '../../types';
|
||||||
import type { IControlWindow } from '../controlBar';
|
import type { IControlWindow } from '../controlBar';
|
||||||
import type { Terminal } from '@xterm/xterm';
|
import type { Terminal } from '@xterm/xterm';
|
||||||
|
|
||||||
export abstract class BaseWindow implements IControlWindow {
|
export abstract class BaseWindow implements IControlWindow {
|
||||||
protected get _terminal(): Terminal { return this.__terminal; }
|
protected get _terminal(): Terminal { return this._terminalPrivate; }
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private __terminal: Terminal,
|
private _terminalPrivate: Terminal,
|
||||||
protected readonly _addons: AddonCollection,
|
protected readonly _addons: AddonCollection,
|
||||||
) {
|
) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
setTerminal(terminal: Terminal): void {
|
public setTerminal(terminal: Terminal): void {
|
||||||
this.__terminal = terminal;
|
this._terminalPrivate = terminal;
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract id: string;
|
public abstract id: string;
|
||||||
abstract label: string;
|
public abstract label: string;
|
||||||
abstract build(container: HTMLElement): void;
|
public abstract build(container: HTMLElement): void;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"module": "commonjs",
|
"module": "commonjs",
|
||||||
"target": "es2021",
|
"target": "es2021",
|
||||||
|
"outDir": "../out-demo/client",
|
||||||
"rootDir": ".",
|
"rootDir": ".",
|
||||||
"sourceMap": true,
|
"sourceMap": true,
|
||||||
"baseUrl": ".",
|
"baseUrl": ".",
|
||||||
@@ -21,7 +22,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"include": [
|
"include": [
|
||||||
"client.ts",
|
"./**/*",
|
||||||
"../../typings/xterm.d.ts"
|
"../../typings/xterm.d.ts"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,7 @@
|
|||||||
/// <reference path="../typings/xterm.d.ts"/>
|
/**
|
||||||
|
* Copyright (c) 2025 The xterm.js authors. All rights reserved.
|
||||||
|
* @license MIT
|
||||||
|
*/
|
||||||
|
|
||||||
import { Terminal } from '@xterm/xterm';
|
import { Terminal } from '@xterm/xterm';
|
||||||
|
|
||||||
|
|||||||
@@ -2,11 +2,12 @@
|
|||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"module": "commonjs",
|
"module": "commonjs",
|
||||||
"target": "es2021",
|
"target": "es2021",
|
||||||
|
"outDir": "../out-demo/server",
|
||||||
"rootDir": ".",
|
"rootDir": ".",
|
||||||
"sourceMap": true,
|
"sourceMap": true,
|
||||||
"esModuleInterop": true
|
"esModuleInterop": true
|
||||||
},
|
},
|
||||||
"include": [
|
"include": [
|
||||||
"server.ts"
|
"./**/*",
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
"files": [],
|
"files": [],
|
||||||
"include": [],
|
"include": [],
|
||||||
"references": [
|
"references": [
|
||||||
|
{ "path": "./demo" },
|
||||||
{ "path": "./src/browser" },
|
{ "path": "./src/browser" },
|
||||||
{ "path": "./src/headless" },
|
{ "path": "./src/headless" },
|
||||||
{ "path": "./test/benchmark" },
|
{ "path": "./test/benchmark" },
|
||||||
|
|||||||
Reference in New Issue
Block a user