Skip to content

Commit

Permalink
Merge pull request #5089 from Tyriar/tyriar/dts
Browse files Browse the repository at this point in the history
Remove src dts files and correct exports
  • Loading branch information
Tyriar authored Jul 5, 2024
2 parents 039cd02 + a7b248e commit 5b5e262
Show file tree
Hide file tree
Showing 14 changed files with 40 additions and 30 deletions.
File renamed without changes.
37 changes: 16 additions & 21 deletions addons/addon-fit/test/FitAddon.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@ import { ITestContext, createTestContext, openTerminal, timeout } from '../../..
let ctx: ITestContext;
test.beforeAll(async ({ browser }) => {
ctx = await createTestContext(browser);
ctx.page.setViewportSize({ width: 1024, height: 768 });
await openTerminal(ctx);
});
test.afterAll(async () => await ctx.page.close());

test.describe('FitAddon', () => {
test.beforeEach(async function(): Promise<any> {
await ctx.page.evaluate(`document.querySelector('#terminal-container').style.display=''`);
await ctx.page.evaluate(`
window.term.reset()
window.fit?.dispose();
Expand All @@ -38,15 +40,14 @@ test.describe('FitAddon', () => {
// });

test('no terminal', async function(): Promise<any> {
await ctx.page.evaluate(`window.fit = new FitAddon();`);
strictEqual(await ctx.page.evaluate(`window.fit.proposeDimensions()`), undefined);
await ctx.page.evaluate(`window.fit2 = new FitAddon();`);
strictEqual(await ctx.page.evaluate(`window.fit2.proposeDimensions()`), undefined);
await ctx.page.evaluate(`window.fit2.dispose();`);
});

test.describe('proposeDimensions', () => {
// test.afterEach(() => unloadFit());

test('default', async function(): Promise<any> {
await loadFit();
await setDimensions();
const dimensions: {cols: number, rows: number} = await ctx.page.evaluate(`window.fit.proposeDimensions()`);
ok(dimensions.cols > 85);
ok(dimensions.cols < 88);
Expand All @@ -55,7 +56,7 @@ test.describe('FitAddon', () => {
});

test('width', async function(): Promise<any> {
await loadFit(1008);
await setDimensions(1008);
const dimensions: {cols: number, rows: number} = await ctx.page.evaluate(`window.fit.proposeDimensions()`);
ok(dimensions.cols > 108);
ok(dimensions.cols < 111);
Expand All @@ -64,7 +65,7 @@ test.describe('FitAddon', () => {
});

test('small', async function(): Promise<any> {
await loadFit(1, 1);
await setDimensions(1, 1);
deepEqual(await ctx.page.evaluate(`window.fit.proposeDimensions()`), {
cols: 2,
rows: 1
Expand All @@ -76,7 +77,7 @@ test.describe('FitAddon', () => {
await ctx.page.evaluate(`document.querySelector('#terminal-container').style.display='none'`);
await ctx.page.evaluate(`window.term = new Terminal()`);
await ctx.page.evaluate(`window.term.open(document.querySelector('#terminal-container'))`);
await loadFit();
await setDimensions();
const dimensions: { cols: number, rows: number } | undefined = await ctx.page.evaluate(`window.fit.proposeDimensions()`);
// The value of dims will be undefined if the char measure strategy falls back to the DOM
// method, so only assert if it's not undefined.
Expand All @@ -86,15 +87,12 @@ test.describe('FitAddon', () => {
ok(dimensions.rows > 24);
ok(dimensions.rows < 29);
}
await ctx.page.evaluate(`document.querySelector('#terminal-container').style.display='block'`);
});
});

test.describe('fit', () => {
test.afterEach(() => unloadFit());

test('default', async function(): Promise<any> {
await loadFit();
await setDimensions();
await ctx.page.evaluate(`window.fit.fit()`);
const cols: number = await ctx.proxy.cols;
const rows: number = await ctx.proxy.rows;
Expand All @@ -105,7 +103,7 @@ test.describe('FitAddon', () => {
});

test('width', async function(): Promise<any> {
await loadFit(1008);
await setDimensions(1008);
await ctx.page.evaluate(`window.fit.fit()`);
const cols: number = await ctx.proxy.cols;
const rows: number = await ctx.proxy.rows;
Expand All @@ -116,23 +114,20 @@ test.describe('FitAddon', () => {
});

test('small', async function(): Promise<any> {
await loadFit(1, 1);
await setDimensions(1, 1);
await ctx.page.evaluate(`window.fit.fit()`);
strictEqual(await ctx.proxy.cols, 2);
strictEqual(await ctx.proxy.rows, 1);
});
});
});

async function loadFit(width: number = 800, height: number = 450): Promise<void> {
async function setDimensions(width: number = 800, height: number = 450): Promise<void> {
await ctx.page.evaluate(`
window.fit = new FitAddon();
window.term.loadAddon(window.fit);
document.querySelector('#terminal-container').style.width='${width}px';
document.querySelector('#terminal-container').style.height='${height}px';
document.querySelector('#terminal-container').style.display='';
`);
}

async function unloadFit(): Promise<void> {
await ctx.page.evaluate(`window.fit.dispose();`);
// HACK: Await a short period as hiding #terminal-container can mess with other tests
await timeout(500);
}
File renamed without changes.
17 changes: 16 additions & 1 deletion addons/addon-image/test/ImageAddon.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,24 @@ import test from '@playwright/test';
import { readFileSync } from 'fs';
import { FINALIZER, introducer, sixelEncode } from 'sixel';
import { ITestContext, createTestContext, openTerminal, pollFor } from '../../../out-test/playwright/TestUtils';
import { IImageAddonOptions } from '../src/Types';
import { deepStrictEqual, ok, strictEqual } from 'assert';

/**
* Plugin ctor options.
*/
export interface IImageAddonOptions {
enableSizeReports: boolean;
pixelLimit: number;
storageLimit: number;
showPlaceholder: boolean;
sixelSupport: boolean;
sixelScrolling: boolean;
sixelPaletteLimit: number;
sixelSizeLimit: number;
iipSupport: boolean;
iipSizeLimit: number;
}

// eslint-disable-next-line
declare const ImageAddon: {
new(options?: Partial<IImageAddonOptions>): any;
Expand Down
File renamed without changes.
File renamed without changes.
8 changes: 4 additions & 4 deletions src/browser/Types.d.ts → src/browser/Types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ export interface ILinkifier2 extends IDisposable {
readonly currentLink: ILinkWithState | undefined;
}

interface ILink {
export interface ILink {
range: IBufferRange;
text: string;
decorations?: ILinkDecorations;
Expand All @@ -139,17 +139,17 @@ interface ILink {
dispose?(): void;
}

interface ILinkDecorations {
export interface ILinkDecorations {
pointerCursor: boolean;
underline: boolean;
}

interface IBufferRange {
export interface IBufferRange {
start: IBufferCellPosition;
end: IBufferCellPosition;
}

interface IBufferCellPosition {
export interface IBufferCellPosition {
x: number;
y: number;
}
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/common/InputHandler.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import { assert } from 'chai';
import { InputHandler } from 'common/InputHandler';
import { IBufferLine, IAttributeData, IColorEvent, ColorIndex, ColorRequestType, SpecialColorIndex } from 'common/Types';
import { IBufferLine, IAttributeData, IColorEvent, ColorRequestType, SpecialColorIndex } from 'common/Types';
import { DEFAULT_ATTR_DATA } from 'common/buffer/BufferLine';
import { CellData } from 'common/buffer/CellData';
import { Attributes, BgFlags, UnderlineStyle } from 'common/buffer/Constants';
Expand Down
2 changes: 1 addition & 1 deletion src/common/InputHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3456,6 +3456,6 @@ class DirtyRowTracker implements IDirtyRowTracker {
}
}

function isValidColorIndex(value: number): value is ColorIndex {
export function isValidColorIndex(value: number): value is ColorIndex {
return 0 <= value && value < 256;
}
4 changes: 2 additions & 2 deletions src/common/Types.d.ts → src/common/Types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -425,8 +425,8 @@ type Enumerate<N extends number, Acc extends number[] = []> = Acc['length'] exte
: Enumerate<N, [...Acc, Acc['length']]>;
type IntRange<F extends number, T extends number> = Exclude<Enumerate<T>, Enumerate<F>>;

type ColorIndex = IntRange<0, 256>; // number from 0 to 255
type AllColorIndex = ColorIndex | SpecialColorIndex;
export type ColorIndex = IntRange<0, 256>; // number from 0 to 255
export type AllColorIndex = ColorIndex | SpecialColorIndex;
export const enum SpecialColorIndex {
FOREGROUND = 256,
BACKGROUND = 257,
Expand Down
File renamed without changes.
File renamed without changes.

0 comments on commit 5b5e262

Please sign in to comment.