mirror of
https://github.com/wavetermdev/xterm.js.git
synced 2026-08-05 13:43:48 -07:00
Merge pull request #5637 from Tyriar/remove_trace
Remove trace decorator and unused platform consts
This commit is contained in:
@@ -9,10 +9,9 @@ import { ICharacterJoinerService, ICharSizeService, ICoreBrowserService, IRender
|
||||
import { ITerminal } from 'browser/Types';
|
||||
import { Disposable, toDisposable } from 'common/Lifecycle';
|
||||
import { getSafariVersion, isSafari } from 'common/Platform';
|
||||
import { ICoreService, IDecorationService, ILogService, IOptionsService } from 'common/services/Services';
|
||||
import { ICoreService, IDecorationService, IOptionsService } from 'common/services/Services';
|
||||
import { IWebGL2RenderingContext } from './Types';
|
||||
import { WebglRenderer } from './WebglRenderer';
|
||||
import { setTraceLogger } from 'common/services/LogService';
|
||||
import { Emitter, EventUtils } from 'common/Event';
|
||||
|
||||
export class WebglAddon extends Disposable implements ITerminalAddon , IWebglApi {
|
||||
@@ -66,13 +65,8 @@ export class WebglAddon extends Disposable implements ITerminalAddon , IWebglApi
|
||||
const charSizeService: ICharSizeService = unsafeCore._charSizeService;
|
||||
const coreBrowserService: ICoreBrowserService = unsafeCore._coreBrowserService;
|
||||
const decorationService: IDecorationService = unsafeCore._decorationService;
|
||||
const logService: ILogService = unsafeCore._logService;
|
||||
const themeService: IThemeService = unsafeCore._themeService;
|
||||
|
||||
// Set trace logger just in case it hasn't been yet which could happen when the addon is
|
||||
// bundled separately to the core module
|
||||
setTraceLogger(logService);
|
||||
|
||||
this._renderer = this._register(new WebglRenderer(
|
||||
terminal,
|
||||
characterJoinerService,
|
||||
|
||||
@@ -39,8 +39,6 @@ export function getSafariVersion(): number {
|
||||
// and ISO third level shifts.
|
||||
// http://stackoverflow.com/q/19877924/577598
|
||||
export const isMac = ['Macintosh', 'MacIntel', 'MacPPC', 'Mac68K'].includes(platform);
|
||||
export const isIpad = platform === 'iPad';
|
||||
export const isIphone = platform === 'iPhone';
|
||||
export const isWindows = ['Windows', 'Win16', 'Win32', 'WinCE'].includes(platform);
|
||||
export const isLinux = platform.indexOf('Linux') >= 0;
|
||||
// Note that when this is true, isLinux will also be true.
|
||||
|
||||
@@ -43,9 +43,6 @@ export class LogService extends Disposable implements ILogService {
|
||||
super();
|
||||
this._updateLogLevel();
|
||||
this._register(this._optionsService.onSpecificOptionChange('logLevel', () => this._updateLogLevel()));
|
||||
|
||||
// For trace logging, assume the latest created log service is valid
|
||||
traceLogger = this;
|
||||
}
|
||||
|
||||
private _updateLogLevel(): void {
|
||||
@@ -95,30 +92,3 @@ export class LogService extends Disposable implements ILogService {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let traceLogger: ILogService;
|
||||
export function setTraceLogger(logger: ILogService): void {
|
||||
traceLogger = logger;
|
||||
}
|
||||
|
||||
/**
|
||||
* A decorator that can be used to automatically log trace calls to the decorated function.
|
||||
*/
|
||||
export function traceCall(_target: any, key: string, descriptor: any): any {
|
||||
if (typeof descriptor.value !== 'function') {
|
||||
throw new Error('not supported');
|
||||
}
|
||||
const fnKey = 'value';
|
||||
const fn = descriptor.value;
|
||||
descriptor[fnKey] = function (...args: any[]) {
|
||||
// Early exit
|
||||
if (traceLogger.logLevel !== LogLevelEnum.TRACE) {
|
||||
return fn.apply(this, args);
|
||||
}
|
||||
|
||||
traceLogger.trace(`GlyphRenderer#${fn.name}(${args.map(e => JSON.stringify(e)).join(', ')})`);
|
||||
const result = fn.apply(this, args);
|
||||
traceLogger.trace(`GlyphRenderer#${fn.name} return`, result);
|
||||
return result;
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user