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>
41 lines
2.1 KiB
TypeScript
41 lines
2.1 KiB
TypeScript
/**
|
|
* Copyright (c) 2021 The xterm.js authors. All rights reserved.
|
|
* @license MIT
|
|
*/
|
|
|
|
import { IParams } from '../parser/Types';
|
|
import { IDisposable, IFunctionIdentifier, IParser } from '@xterm/xterm';
|
|
import { ICoreTerminal } from '../CoreTerminal';
|
|
|
|
export class ParserApi implements IParser {
|
|
constructor(private _core: ICoreTerminal) { }
|
|
|
|
public registerCsiHandler(id: IFunctionIdentifier, callback: (params: (number | number[])[]) => boolean | Promise<boolean>): IDisposable {
|
|
return this._core.registerCsiHandler(id, (params: IParams) => callback(params.toArray()));
|
|
}
|
|
public addCsiHandler(id: IFunctionIdentifier, callback: (params: (number | number[])[]) => boolean | Promise<boolean>): IDisposable {
|
|
return this.registerCsiHandler(id, callback);
|
|
}
|
|
public registerDcsHandler(id: IFunctionIdentifier, callback: (data: string, param: (number | number[])[]) => boolean | Promise<boolean>): IDisposable {
|
|
return this._core.registerDcsHandler(id, (data: string, params: IParams) => callback(data, params.toArray()));
|
|
}
|
|
public addDcsHandler(id: IFunctionIdentifier, callback: (data: string, param: (number | number[])[]) => boolean | Promise<boolean>): IDisposable {
|
|
return this.registerDcsHandler(id, callback);
|
|
}
|
|
public registerEscHandler(id: IFunctionIdentifier, handler: () => boolean | Promise<boolean>): IDisposable {
|
|
return this._core.registerEscHandler(id, handler);
|
|
}
|
|
public addEscHandler(id: IFunctionIdentifier, handler: () => boolean | Promise<boolean>): IDisposable {
|
|
return this.registerEscHandler(id, handler);
|
|
}
|
|
public registerOscHandler(ident: number, callback: (data: string) => boolean | Promise<boolean>): IDisposable {
|
|
return this._core.registerOscHandler(ident, callback);
|
|
}
|
|
public addOscHandler(ident: number, callback: (data: string) => boolean | Promise<boolean>): IDisposable {
|
|
return this.registerOscHandler(ident, callback);
|
|
}
|
|
public registerApcHandler(id: IFunctionIdentifier, callback: (data: string) => boolean | Promise<boolean>): IDisposable {
|
|
return this._core.registerApcHandler(id, callback);
|
|
}
|
|
}
|