Enable oxlint's import/no-cycle rule (import plugin) so circular module dependencies are caught in CI, similar to eslint-plugin-import/no-cycle and biome no-import-cycles discussed in the issue. Relocate shared types and dependencies to remove cycles under src/common: - Types.ts: host IInsertEvent, IDeleteEvent, IParams, UnderlineStyle, IBuffer, and IBufferSet; drop imports from CircularList, buffer/Types, parser/Types, and Services - CoreTerminal.ts: define and export ICoreTerminal - ServiceRegistry.ts: define IServiceIdentifier (break Services registry loop) - UnicodeService: stop constructing UnicodeV6; CoreTerminal registers the default v6 provider after service creation - buffer/Types.ts and parser/Types.ts: re-export moved types for callers Fixes https://github.com/xtermjs/xterm.js/issues/5897 Co-authored-by: Cursor <cursoragent@cursor.com>
37 lines
1.4 KiB
TypeScript
37 lines
1.4 KiB
TypeScript
/**
|
|
* Copyright (c) 2021 The xterm.js authors. All rights reserved.
|
|
* @license MIT
|
|
*/
|
|
|
|
import { IBuffer as IBufferApi, IBufferNamespace as IBufferNamespaceApi } from '@xterm/xterm';
|
|
import { BufferApiView } from './BufferApiView';
|
|
import { ICoreTerminal } from '../CoreTerminal';
|
|
import { Disposable } from '../Lifecycle';
|
|
import { Emitter } from '../Event';
|
|
|
|
export class BufferNamespaceApi extends Disposable implements IBufferNamespaceApi {
|
|
private _normal: BufferApiView;
|
|
private _alternate: BufferApiView;
|
|
|
|
private readonly _onBufferChange = this._register(new Emitter<IBufferApi>());
|
|
public readonly onBufferChange = this._onBufferChange.event;
|
|
|
|
constructor(private _core: ICoreTerminal) {
|
|
super();
|
|
this._normal = new BufferApiView(this._core.buffers.normal, 'normal');
|
|
this._alternate = new BufferApiView(this._core.buffers.alt, 'alternate');
|
|
this._register(this._core.buffers.onBufferActivate(() => this._onBufferChange.fire(this.active)));
|
|
}
|
|
public get active(): IBufferApi {
|
|
if (this._core.buffers.active === this._core.buffers.normal) { return this.normal; }
|
|
if (this._core.buffers.active === this._core.buffers.alt) { return this.alternate; }
|
|
throw new Error('Active buffer is neither normal nor alternate');
|
|
}
|
|
public get normal(): IBufferApi {
|
|
return this._normal.init(this._core.buffers.normal);
|
|
}
|
|
public get alternate(): IBufferApi {
|
|
return this._alternate.init(this._core.buffers.alt);
|
|
}
|
|
}
|