Remove TypeScript path mappings in favor of relative imports
Fixes https://github.com/xtermjs/xterm.js/issues/5896 TypeScript path mappings for common/*, browser/*, and headless/* were not rewritten in emitted JavaScript, which forced webpack resolve aliases and NODE_PATH workarounds so runtime could resolve modules. That added build complexity and broke tooling such as ESLint import/no-cycle. Changes: - Convert ~750 imports across src/, addons/, and test/ to relative paths - Remove common/browser/headless paths and src catch-all mappings from tsconfigs (keep @xterm/addon-* demo and addon typings paths) - Remove webpack resolve.alias for common, browser, headless, and vs - Drop NODE_PATH from unit tests, benchmarks, and VS Code launch config - Fix addon-image IIPImageStorage to import ./Types after removing catch-all * Verified: npm run build, esbuild, package, package-headless Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -3,12 +3,12 @@
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
import { Disposable } from 'common/Lifecycle';
|
||||
import { IAttributeData, IBufferLine } from 'common/Types';
|
||||
import { BufferSet } from 'common/buffer/BufferSet';
|
||||
import { IBuffer, IBufferSet } from 'common/buffer/Types';
|
||||
import { IBufferService, ILogService, IOptionsService, type IBufferResizeEvent } from 'common/services/Services';
|
||||
import { Emitter } from 'common/Event';
|
||||
import { Disposable } from '../Lifecycle';
|
||||
import { IAttributeData, IBufferLine } from '../Types';
|
||||
import { BufferSet } from '../buffer/BufferSet';
|
||||
import { IBuffer, IBufferSet } from '../buffer/Types';
|
||||
import { IBufferService, ILogService, IOptionsService, type IBufferResizeEvent } from './Services';
|
||||
import { Emitter } from '../Event';
|
||||
|
||||
export const enum BufferServiceConstants {
|
||||
MINIMUM_COLS = 2, // Less than 2 can mess with wide chars
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
import { ICharsetService } from 'common/services/Services';
|
||||
import { ICharset } from 'common/Types';
|
||||
import { ICharsetService } from './Services';
|
||||
import { ICharset } from '../Types';
|
||||
|
||||
export class CharsetService implements ICharsetService {
|
||||
public serviceBrand: any;
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
import { ICoreService } from 'common/services/Services';
|
||||
import { CoreService } from 'common/services/CoreService';
|
||||
import { MockBufferService, MockLogService, MockOptionsService } from 'common/TestUtils.test';
|
||||
import { ICoreService } from './Services';
|
||||
import { CoreService } from './CoreService';
|
||||
import { MockBufferService, MockLogService, MockOptionsService } from '../TestUtils.test';
|
||||
import { assert } from 'chai';
|
||||
|
||||
describe('CoreService', () => {
|
||||
|
||||
@@ -3,10 +3,10 @@
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
import { Disposable } from 'common/Lifecycle';
|
||||
import { IDecPrivateModes, IKittyKeyboardState, IModes } from 'common/Types';
|
||||
import { IBufferService, ICoreService, ILogService, IOptionsService } from 'common/services/Services';
|
||||
import { Emitter } from 'common/Event';
|
||||
import { Disposable } from '../Lifecycle';
|
||||
import { IDecPrivateModes, IKittyKeyboardState, IModes } from '../Types';
|
||||
import { IBufferService, ICoreService, ILogService, IOptionsService } from './Services';
|
||||
import { Emitter } from '../Event';
|
||||
|
||||
const DEFAULT_MODES: IModes = Object.freeze({
|
||||
insertMode: false
|
||||
|
||||
@@ -5,12 +5,12 @@
|
||||
|
||||
import { assert } from 'chai';
|
||||
import { DecorationLineCache, DecorationService } from './DecorationService';
|
||||
import { IMarker } from 'common/Types';
|
||||
import { Disposable } from 'common/Lifecycle';
|
||||
import { Emitter } from 'common/Event';
|
||||
import { MockLogService, MockBufferService, MockOptionsService } from 'common/TestUtils.test';
|
||||
import { Buffer } from 'common/buffer/Buffer';
|
||||
import { DEFAULT_ATTR_DATA } from 'common/buffer/BufferLine';
|
||||
import { IMarker } from '../Types';
|
||||
import { Disposable } from '../Lifecycle';
|
||||
import { Emitter } from '../Event';
|
||||
import { MockLogService, MockBufferService, MockOptionsService } from '../TestUtils.test';
|
||||
import { Buffer } from '../buffer/Buffer';
|
||||
import { DEFAULT_ATTR_DATA } from '../buffer/BufferLine';
|
||||
|
||||
function createFakeMarker(line: number): IMarker {
|
||||
return Object.freeze(new class extends Disposable {
|
||||
|
||||
@@ -3,15 +3,15 @@
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
import type { IDeleteEvent, IInsertEvent } from 'common/CircularList';
|
||||
import { MicrotaskTimer } from 'common/Async';
|
||||
import { css } from 'common/Color';
|
||||
import { Disposable, DisposableStore, MutableDisposable, toDisposable } from 'common/Lifecycle';
|
||||
import { IBufferService, IDecorationService, IInternalDecoration, ILogService } from 'common/services/Services';
|
||||
import { SortedList } from 'common/SortedList';
|
||||
import { IColor, ICircularList } from 'common/Types';
|
||||
import type { IDeleteEvent, IInsertEvent } from '../CircularList';
|
||||
import { MicrotaskTimer } from '../Async';
|
||||
import { css } from '../Color';
|
||||
import { Disposable, DisposableStore, MutableDisposable, toDisposable } from '../Lifecycle';
|
||||
import { IBufferService, IDecorationService, IInternalDecoration, ILogService } from './Services';
|
||||
import { SortedList } from '../SortedList';
|
||||
import { IColor, ICircularList } from '../Types';
|
||||
import { IDecoration, IDecorationOptions, IMarker } from '@xterm/xterm';
|
||||
import { Emitter } from 'common/Event';
|
||||
import { Emitter } from '../Event';
|
||||
|
||||
// Work variables to avoid garbage collection
|
||||
let $xmin = 0;
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { IInstantiationService, IServiceIdentifier } from 'common/services/Services';
|
||||
import { getServiceDependencies } from 'common/services/ServiceRegistry';
|
||||
import { IInstantiationService, IServiceIdentifier } from './Services';
|
||||
import { getServiceDependencies } from './ServiceRegistry';
|
||||
|
||||
export class ServiceCollection {
|
||||
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
import { Disposable } from 'common/Lifecycle';
|
||||
import { ILogService, IOptionsService, LogLevelEnum } from 'common/services/Services';
|
||||
import { Disposable } from '../Lifecycle';
|
||||
import { ILogService, IOptionsService, LogLevelEnum } from './Services';
|
||||
|
||||
type LogType = (message?: any, ...optionalParams: any[]) => void;
|
||||
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
* Copyright (c) 2019 The xterm.js authors. All rights reserved.
|
||||
* @license MIT
|
||||
*/
|
||||
import { MouseStateService } from 'common/services/MouseStateService';
|
||||
import { MouseStateService } from './MouseStateService';
|
||||
import { assert } from 'chai';
|
||||
import { ICoreMouseEvent, CoreMouseEventType } from 'common/Types';
|
||||
import { ICoreMouseEvent, CoreMouseEventType } from '../Types';
|
||||
|
||||
function toBytes(s: string | undefined): number[] {
|
||||
if (!s) {
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
* Copyright (c) 2019 The xterm.js authors. All rights reserved.
|
||||
* @license MIT
|
||||
*/
|
||||
import { IMouseStateService } from 'common/services/Services';
|
||||
import { ICoreMouseProtocol, ICoreMouseEvent, CoreMouseEncoding, CoreMouseEventType, CoreMouseButton, CoreMouseAction } from 'common/Types';
|
||||
import { Disposable } from 'common/Lifecycle';
|
||||
import { Emitter } from 'common/Event';
|
||||
import { IMouseStateService } from './Services';
|
||||
import { ICoreMouseProtocol, ICoreMouseEvent, CoreMouseEncoding, CoreMouseEventType, CoreMouseButton, CoreMouseAction } from '../Types';
|
||||
import { Disposable } from '../Lifecycle';
|
||||
import { Emitter } from '../Event';
|
||||
|
||||
/**
|
||||
* Supported default protocols.
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
*/
|
||||
|
||||
import { assert } from 'chai';
|
||||
import { OptionsService, DEFAULT_OPTIONS } from 'common/services/OptionsService';
|
||||
import { IDisposable } from 'common/Types';
|
||||
import { OptionsService, DEFAULT_OPTIONS } from './OptionsService';
|
||||
import { IDisposable } from '../Types';
|
||||
|
||||
describe('OptionsService', () => {
|
||||
describe('constructor', () => {
|
||||
|
||||
@@ -3,11 +3,11 @@
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
import { Disposable, toDisposable } from 'common/Lifecycle';
|
||||
import { isMac } from 'common/Platform';
|
||||
import { CursorStyle, IDisposable } from 'common/Types';
|
||||
import { FontWeight, IOptionsService, ITerminalOptions } from 'common/services/Services';
|
||||
import { Emitter } from 'common/Event';
|
||||
import { Disposable, toDisposable } from '../Lifecycle';
|
||||
import { isMac } from '../Platform';
|
||||
import { CursorStyle, IDisposable } from '../Types';
|
||||
import { FontWeight, IOptionsService, ITerminalOptions } from './Services';
|
||||
import { Emitter } from '../Event';
|
||||
|
||||
export const DEFAULT_OPTIONS: Readonly<Required<ITerminalOptions>> = {
|
||||
cols: 80,
|
||||
|
||||
@@ -4,12 +4,12 @@
|
||||
*/
|
||||
|
||||
import { assert } from 'chai';
|
||||
import { AttributeData } from 'common/buffer/AttributeData';
|
||||
import { BufferService } from 'common/services/BufferService';
|
||||
import { OptionsService } from 'common/services/OptionsService';
|
||||
import { OscLinkService } from 'common/services/OscLinkService';
|
||||
import { IBufferService, IOptionsService, IOscLinkService } from 'common/services/Services';
|
||||
import { MockLogService } from 'common/TestUtils.test';
|
||||
import { AttributeData } from '../buffer/AttributeData';
|
||||
import { BufferService } from './BufferService';
|
||||
import { OptionsService } from './OptionsService';
|
||||
import { OscLinkService } from './OscLinkService';
|
||||
import { IBufferService, IOptionsService, IOscLinkService } from './Services';
|
||||
import { MockLogService } from '../TestUtils.test';
|
||||
|
||||
describe('OscLinkService', () => {
|
||||
describe('constructor', () => {
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
* Copyright (c) 2022 The xterm.js authors. All rights reserved.
|
||||
* @license MIT
|
||||
*/
|
||||
import { IBufferService, IOscLinkService } from 'common/services/Services';
|
||||
import { IMarker, IOscLinkData } from 'common/Types';
|
||||
import { IBufferService, IOscLinkService } from './Services';
|
||||
import { IMarker, IOscLinkData } from '../Types';
|
||||
|
||||
export class OscLinkService implements IOscLinkService {
|
||||
public serviceBrand: any;
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { IServiceIdentifier } from 'common/services/Services';
|
||||
import { IServiceIdentifier } from './Services';
|
||||
|
||||
const enum Constants {
|
||||
DI_TARGET = 'di$target',
|
||||
|
||||
@@ -4,10 +4,10 @@
|
||||
*/
|
||||
|
||||
import type { IDecoration, IDecorationOptions, ILinkHandler, ILogger, IWindowsPty, IOverviewRulerOptions } from '@xterm/xterm';
|
||||
import { CoreMouseEncoding, CoreMouseEventType, CursorInactiveStyle, CursorStyle, IAttributeData, ICharset, IColor, ICoreMouseEvent, ICoreMouseProtocol, IDecPrivateModes, IDisposable, IKittyKeyboardState, IModes, IOscLinkData, IWindowOptions } from 'common/Types';
|
||||
import { IBuffer, IBufferSet } from 'common/buffer/Types';
|
||||
import { createDecorator } from 'common/services/ServiceRegistry';
|
||||
import type { Emitter, IEvent } from 'common/Event';
|
||||
import { CoreMouseEncoding, CoreMouseEventType, CursorInactiveStyle, CursorStyle, IAttributeData, ICharset, IColor, ICoreMouseEvent, ICoreMouseProtocol, IDecPrivateModes, IDisposable, IKittyKeyboardState, IModes, IOscLinkData, IWindowOptions } from '../Types';
|
||||
import { IBuffer, IBufferSet } from '../buffer/Types';
|
||||
import { createDecorator } from './ServiceRegistry';
|
||||
import type { Emitter, IEvent } from '../Event';
|
||||
|
||||
export const IBufferService = createDecorator<IBufferService>('BufferService');
|
||||
export interface IBufferService {
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
*/
|
||||
|
||||
import { assert } from 'chai';
|
||||
import { UnicodeService } from 'common/services/UnicodeService';
|
||||
import { IUnicodeVersionProvider } from 'common/services/Services';
|
||||
import { UnicodeService } from './UnicodeService';
|
||||
import { IUnicodeVersionProvider } from './Services';
|
||||
|
||||
class DummyProvider implements IUnicodeVersionProvider {
|
||||
public version = '123';
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
import { UnicodeV6 } from 'common/input/UnicodeV6';
|
||||
import { IUnicodeService, IUnicodeVersionProvider, UnicodeCharProperties, UnicodeCharWidth } from 'common/services/Services';
|
||||
import { Emitter } from 'common/Event';
|
||||
import { UnicodeV6 } from '../input/UnicodeV6';
|
||||
import { IUnicodeService, IUnicodeVersionProvider, UnicodeCharProperties, UnicodeCharWidth } from './Services';
|
||||
import { Emitter } from '../Event';
|
||||
|
||||
export class UnicodeService implements IUnicodeService {
|
||||
public serviceBrand: any;
|
||||
|
||||
Reference in New Issue
Block a user