Skip to content

Commit fe2723b

Browse files
authored
Merge branch 'master' into circle-line-custom-powerline-glyph
2 parents 7fecec6 + 48184cc commit fe2723b

File tree

21 files changed

+211
-1018
lines changed

21 files changed

+211
-1018
lines changed

.github/workflows/ci.yml

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ jobs:
3232
./addons/xterm-addon-canvas/out-test/* \
3333
./addons/xterm-addon-fit/out/* \
3434
./addons/xterm-addon-fit/out-test/* \
35-
./addons/xterm-addon-image/inwasm-builds/out/* \
3635
./addons/xterm-addon-image/out/* \
3736
./addons/xterm-addon-image/out-test/* \
3837
./addons/xterm-addon-ligatures/out/* \
@@ -73,6 +72,39 @@ jobs:
7372
- name: Lint API
7473
run: yarn lint-api
7574

75+
test-unit-coverage:
76+
needs: build
77+
runs-on: ubuntu-latest
78+
timeout-minutes: 10
79+
steps:
80+
- uses: actions/checkout@v3
81+
- name: Use Node.js 18.x
82+
uses: actions/setup-node@v3
83+
with:
84+
node-version: 18.x
85+
cache: 'yarn'
86+
- name: Install dependencies
87+
run: |
88+
yarn --frozen-lockfile
89+
yarn install-addons
90+
- uses: actions/download-artifact@v3
91+
with:
92+
name: build-artifacts
93+
- name: Unzip artifacts (Linux, macOS)
94+
if: runner.os != 'Windows'
95+
run: unzip -o compressed-build.zip
96+
- name: Unzip artifacts (Windows)
97+
if: runner.os == 'Windows'
98+
run: 7z x compressed-build.zip -aoa -o${{ github.workspace }}
99+
- name: Print directory structure
100+
run: ls -R
101+
- name: Unit test coverage
102+
run: |
103+
yarn test-unit-coverage --forbid-only
104+
EXIT_CODE=$?
105+
./node_modules/.bin/nyc report --reporter=cobertura
106+
exit $EXIT_CODE
107+
76108
test-unit-parallel:
77109
timeout-minutes: 20
78110
strategy:

addons/xterm-addon-canvas/src/BaseRenderLayer.ts

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,24 @@
33
* @license MIT
44
*/
55

6+
import { ReadonlyColorSet } from 'browser/Types';
7+
import { CellColorResolver } from 'browser/renderer/shared/CellColorResolver';
68
import { acquireTextureAtlas } from 'browser/renderer/shared/CharAtlasCache';
79
import { TEXT_BASELINE } from 'browser/renderer/shared/Constants';
810
import { tryDrawCustomChar } from 'browser/renderer/shared/CustomGlyphs';
911
import { throwIfFalsy } from 'browser/renderer/shared/RendererUtils';
10-
import { IRasterizedGlyph, IRenderDimensions, ISelectionRenderModel, ITextureAtlas } from 'browser/renderer/shared/Types';
1112
import { createSelectionRenderModel } from 'browser/renderer/shared/SelectionRenderModel';
13+
import { IRasterizedGlyph, IRenderDimensions, ISelectionRenderModel, ITextureAtlas } from 'browser/renderer/shared/Types';
1214
import { ICoreBrowserService, IThemeService } from 'browser/services/Services';
13-
import { ReadonlyColorSet } from 'browser/Types';
15+
import { EventEmitter, forwardEvent } from 'common/EventEmitter';
16+
import { Disposable, MutableDisposable, toDisposable } from 'common/Lifecycle';
17+
import { isSafari } from 'common/Platform';
18+
import { ICellData } from 'common/Types';
1419
import { CellData } from 'common/buffer/CellData';
1520
import { WHITESPACE_CELL_CODE } from 'common/buffer/Constants';
1621
import { IBufferService, IDecorationService, IOptionsService } from 'common/services/Services';
17-
import { ICellData, IDisposable } from 'common/Types';
1822
import { Terminal } from 'xterm';
1923
import { IRenderLayer } from './Types';
20-
import { CellColorResolver } from 'browser/renderer/shared/CellColorResolver';
21-
import { Disposable, toDisposable } from 'common/Lifecycle';
22-
import { isSafari } from 'common/Platform';
23-
import { EventEmitter, forwardEvent } from 'common/EventEmitter';
2424

2525
export abstract class BaseRenderLayer extends Disposable implements IRenderLayer {
2626
private _canvas: HTMLCanvasElement;
@@ -37,7 +37,7 @@ export abstract class BaseRenderLayer extends Disposable implements IRenderLayer
3737
private _bitmapGenerator: (BitmapGenerator | undefined)[] = [];
3838

3939
protected _charAtlas!: ITextureAtlas;
40-
private _charAtlasDisposable?: IDisposable;
40+
protected _charAtlasDisposable = this.register(new MutableDisposable());
4141

4242
public get canvas(): HTMLCanvasElement { return this._canvas; }
4343
public get cacheCanvas(): HTMLCanvasElement { return this._charAtlas?.pages[0].canvas!; }
@@ -74,7 +74,6 @@ export abstract class BaseRenderLayer extends Disposable implements IRenderLayer
7474

7575
this.register(toDisposable(() => {
7676
this._canvas.remove();
77-
this._charAtlas?.dispose();
7877
}));
7978
}
8079

@@ -122,9 +121,8 @@ export abstract class BaseRenderLayer extends Disposable implements IRenderLayer
122121
if (this._deviceCharWidth <= 0 && this._deviceCharHeight <= 0) {
123122
return;
124123
}
125-
this._charAtlasDisposable?.dispose();
126124
this._charAtlas = acquireTextureAtlas(this._terminal, this._optionsService.rawOptions, colorSet, this._deviceCellWidth, this._deviceCellHeight, this._deviceCharWidth, this._deviceCharHeight, this._coreBrowserService.dpr);
127-
this._charAtlasDisposable = forwardEvent(this._charAtlas.onAddTextureAtlasCanvas, this._onAddTextureAtlasCanvas);
125+
this._charAtlasDisposable.value = forwardEvent(this._charAtlas.onAddTextureAtlasCanvas, this._onAddTextureAtlasCanvas);
128126
this._charAtlas.warmUp();
129127
for (let i = 0; i < this._charAtlas.pages.length; i++) {
130128
this._bitmapGenerator[i] = new BitmapGenerator(this._charAtlas.pages[i].canvas);

addons/xterm-addon-canvas/src/CursorRenderLayer.ts

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { CursorBlinkStateManager } from 'browser/renderer/shared/CursorBlinkStat
77
import { IRenderDimensions, IRequestRedrawEvent } from 'browser/renderer/shared/Types';
88
import { ICoreBrowserService, IThemeService } from 'browser/services/Services';
99
import { IEventEmitter } from 'common/EventEmitter';
10-
import { toDisposable } from 'common/Lifecycle';
10+
import { MutableDisposable } from 'common/Lifecycle';
1111
import { isFirefox } from 'common/Platform';
1212
import { ICellData } from 'common/Types';
1313
import { CellData } from 'common/buffer/CellData';
@@ -26,7 +26,7 @@ interface ICursorState {
2626
export class CursorRenderLayer extends BaseRenderLayer {
2727
private _state: ICursorState;
2828
private _cursorRenderers: {[key: string]: (x: number, y: number, cell: ICellData) => void};
29-
private _cursorBlinkStateManager: CursorBlinkStateManager | undefined;
29+
private _cursorBlinkStateManager: MutableDisposable<CursorBlinkStateManager> = this.register(new MutableDisposable());
3030
private _cell: ICellData = new CellData();
3131

3232
constructor(
@@ -57,10 +57,6 @@ export class CursorRenderLayer extends BaseRenderLayer {
5757
};
5858
this.register(optionsService.onOptionChange(() => this._handleOptionsChanged()));
5959
this._handleOptionsChanged();
60-
this.register(toDisposable(() => {
61-
this._cursorBlinkStateManager?.dispose();
62-
this._cursorBlinkStateManager = undefined;
63-
}));
6460
}
6561

6662
public resize(dim: IRenderDimensions): void {
@@ -77,43 +73,42 @@ export class CursorRenderLayer extends BaseRenderLayer {
7773

7874
public reset(): void {
7975
this._clearCursor();
80-
this._cursorBlinkStateManager?.restartBlinkAnimation();
76+
this._cursorBlinkStateManager.value?.restartBlinkAnimation();
8177
this._handleOptionsChanged();
8278
}
8379

8480
public handleBlur(): void {
85-
this._cursorBlinkStateManager?.pause();
81+
this._cursorBlinkStateManager.value?.pause();
8682
this._onRequestRedraw.fire({ start: this._bufferService.buffer.y, end: this._bufferService.buffer.y });
8783
}
8884

8985
public handleFocus(): void {
90-
this._cursorBlinkStateManager?.resume();
86+
this._cursorBlinkStateManager.value?.resume();
9187
this._onRequestRedraw.fire({ start: this._bufferService.buffer.y, end: this._bufferService.buffer.y });
9288
}
9389

9490
private _handleOptionsChanged(): void {
9591
if (this._optionsService.rawOptions.cursorBlink) {
96-
if (!this._cursorBlinkStateManager) {
97-
this._cursorBlinkStateManager = new CursorBlinkStateManager(() => this._render(true), this._coreBrowserService);
92+
if (!this._cursorBlinkStateManager.value) {
93+
this._cursorBlinkStateManager.value = new CursorBlinkStateManager(() => this._render(true), this._coreBrowserService);
9894
}
9995
} else {
100-
this._cursorBlinkStateManager?.dispose();
101-
this._cursorBlinkStateManager = undefined;
96+
this._cursorBlinkStateManager.clear();
10297
}
10398
// Request a refresh from the terminal as management of rendering is being
10499
// moved back to the terminal
105100
this._onRequestRedraw.fire({ start: this._bufferService.buffer.y, end: this._bufferService.buffer.y });
106101
}
107102

108103
public handleCursorMove(): void {
109-
this._cursorBlinkStateManager?.restartBlinkAnimation();
104+
this._cursorBlinkStateManager.value?.restartBlinkAnimation();
110105
}
111106

112107
public handleGridChanged(startRow: number, endRow: number): void {
113-
if (!this._cursorBlinkStateManager || this._cursorBlinkStateManager.isPaused) {
108+
if (!this._cursorBlinkStateManager.value || this._cursorBlinkStateManager.value.isPaused) {
114109
this._render(false);
115110
} else {
116-
this._cursorBlinkStateManager.restartBlinkAnimation();
111+
this._cursorBlinkStateManager.value.restartBlinkAnimation();
117112
}
118113
}
119114

@@ -159,7 +154,7 @@ export class CursorRenderLayer extends BaseRenderLayer {
159154
}
160155

161156
// Don't draw the cursor if it's blinking
162-
if (this._cursorBlinkStateManager && !this._cursorBlinkStateManager.isCursorVisible) {
157+
if (this._cursorBlinkStateManager.value && !this._cursorBlinkStateManager.value.isCursorVisible) {
163158
this._clearCursor();
164159
return;
165160
}

addons/xterm-addon-image/inwasm-builds/out/base64.wasm.js/decode/definition.json

Lines changed: 0 additions & 1 deletion
This file was deleted.
Binary file not shown.

0 commit comments

Comments
 (0)